|
@@ -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",
|