Drop support for appservice login with unstable prefix

This commit is contained in:
Tulir Asokan 2022-04-29 22:04:28 +03:00
parent 4c0d43fee7
commit 8b39175b76
3 changed files with 5 additions and 7 deletions

View file

@ -133,16 +133,14 @@ func (helper *CryptoHelper) loginBot() (*mautrix.Client, error) {
flows, err := client.GetLoginFlows()
if err != nil {
return nil, fmt.Errorf("failed to get supported login flows: %w", err)
}
flow := flows.FirstFlowOfType(mautrix.AuthTypeAppservice, mautrix.AuthTypeHalfyAppservice)
if flow == nil {
} else if !flows.HasFlow(mautrix.AuthTypeAppservice) {
return nil, fmt.Errorf("homeserver does not support appservice login")
}
// We set the API token to the AS token here to authenticate the appservice login
// It'll get overridden after the login
client.AccessToken = helper.bridge.AS.Registration.AppToken
resp, err := client.Login(&mautrix.ReqLogin{
Type: flow.Type,
Type: mautrix.AuthTypeAppservice,
Identifier: mautrix.UserIdentifier{Type: mautrix.IdentifierTypeUser, User: string(helper.bridge.AS.BotMXID())},
DeviceID: deviceID,
InitialDeviceDisplayName: "WhatsApp Bridge",

2
go.mod
View file

@ -17,7 +17,7 @@ require (
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
maunium.net/go/mauflag v1.0.0
maunium.net/go/maulogger/v2 v2.3.2
maunium.net/go/mautrix v0.10.13-0.20220429121644-4db0cd5f4c09
maunium.net/go/mautrix v0.10.13-0.20220429190332-58e10ec2ac33
)
require (

4
go.sum
View file

@ -197,5 +197,5 @@ maunium.net/go/mauflag v1.0.0 h1:YiaRc0tEI3toYtJMRIfjP+jklH45uDHtT80nUamyD4M=
maunium.net/go/mauflag v1.0.0/go.mod h1:nLivPOpTpHnpzEh8jEdSL9UqO9+/KBJFmNRlwKfkPeA=
maunium.net/go/maulogger/v2 v2.3.2 h1:1XmIYmMd3PoQfp9J+PaHhpt80zpfmMqaShzUTC7FwY0=
maunium.net/go/maulogger/v2 v2.3.2/go.mod h1:TYWy7wKwz/tIXTpsx8G3mZseIRiC5DoMxSZazOHy68A=
maunium.net/go/mautrix v0.10.13-0.20220429121644-4db0cd5f4c09 h1:wZeeldiN1mf70SYeXVRPzXrVK3jfV9VGDUnT+lQulHY=
maunium.net/go/mautrix v0.10.13-0.20220429121644-4db0cd5f4c09/go.mod h1:lm1eZygpN3wlLyexPh+Z56DEvOuC4tY5/JacJWr+/AE=
maunium.net/go/mautrix v0.10.13-0.20220429190332-58e10ec2ac33 h1:5Xut2Xx/aqVGIhPAa6EtyLm9RVJLutwtp0rZO1KUuxI=
maunium.net/go/mautrix v0.10.13-0.20220429190332-58e10ec2ac33/go.mod h1:lm1eZygpN3wlLyexPh+Z56DEvOuC4tY5/JacJWr+/AE=