From 0b5eeef689a506ee90e93e48eeefaeaa48bf7026 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Thu, 4 Mar 2021 19:35:07 +0200 Subject: [PATCH] Update mautrix-go to add auth type to register requests --- crypto.go | 4 ++-- go.mod | 2 +- go.sum | 4 ++++ user.go | 9 ++++++--- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/crypto.go b/crypto.go index ac1bb0f..8335f09 100644 --- a/crypto.go +++ b/crypto.go @@ -125,14 +125,14 @@ func (helper *CryptoHelper) loginBot() (*mautrix.Client, error) { if err != nil { return nil, fmt.Errorf("failed to get supported login flows: %w", err) } - if !flows.HasFlow(mautrix.AuthTypeAppservice) { + if !flows.HasFlow(mautrix.AuthTypeHalfyAppservice) { 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: mautrix.AuthTypeAppservice, + Type: mautrix.AuthTypeHalfyAppservice, Identifier: mautrix.UserIdentifier{Type: mautrix.IdentifierTypeUser, User: string(helper.bridge.AS.BotMXID())}, DeviceID: deviceID, InitialDeviceDisplayName: "WhatsApp Bridge", diff --git a/go.mod b/go.mod index 363f063..d8bb2a7 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( gopkg.in/yaml.v2 v2.3.0 maunium.net/go/mauflag v1.0.0 maunium.net/go/maulogger/v2 v2.2.4 - maunium.net/go/mautrix v0.8.6 + maunium.net/go/mautrix v0.8.7-0.20210304173449-b87e026581a5 ) replace github.com/Rhymen/go-whatsapp => github.com/tulir/go-whatsapp v0.4.0-rc.3 diff --git a/go.sum b/go.sum index dddf47c..afb7f33 100644 --- a/go.sum +++ b/go.sum @@ -488,5 +488,9 @@ maunium.net/go/mautrix v0.8.5 h1:GNW8mde745M6H54Bpw9TJBAgME+iphS0kGvO+Vx1J0Q= maunium.net/go/mautrix v0.8.5/go.mod h1:W3yDq9H5qSqo14Gu6rWF9uE5NXLIcmqF7oY0pv5lZs8= maunium.net/go/mautrix v0.8.6 h1:JhiA8I+JE3+X8d/JqCIeweDA9lOVwbUlj86Y8RtvDMg= maunium.net/go/mautrix v0.8.6/go.mod h1:mckyHSKKyI0PQF2K9MgWMMDUWH1meCNggE28ILTLuMg= +maunium.net/go/mautrix v0.8.7-0.20210304173149-2ab811a476a6 h1:Nsoc66dDiB/PDwqFmh3MgsJtaG+0AzMzCNS4qRKKqRU= +maunium.net/go/mautrix v0.8.7-0.20210304173149-2ab811a476a6/go.mod h1:mckyHSKKyI0PQF2K9MgWMMDUWH1meCNggE28ILTLuMg= +maunium.net/go/mautrix v0.8.7-0.20210304173449-b87e026581a5 h1:Tbx+LMN+PkJBRdHPxfWh0CVicxrAgkKPF5KGIbdJT1g= +maunium.net/go/mautrix v0.8.7-0.20210304173449-b87e026581a5/go.mod h1:mckyHSKKyI0PQF2K9MgWMMDUWH1meCNggE28ILTLuMg= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= diff --git a/user.go b/user.go index 5f44a2b..31193c2 100644 --- a/user.go +++ b/user.go @@ -752,9 +752,12 @@ func (user *User) UpdateDirectChats(chats map[id.UserID][]id.RoomID) { var err error if user.bridge.Config.Homeserver.Asmux { urlPath := intent.BuildBaseURL("_matrix", "client", "unstable", "net.maunium.asmux", "dms") - _, err = intent.MakeFullRequest(method, urlPath, http.Header{ - "X-Asmux-Auth": {user.bridge.AS.Registration.AppToken}, - }, chats, nil) + _, err = intent.MakeFullRequest(mautrix.FullRequest{ + Method: method, + URL: urlPath, + Headers: http.Header{"X-Asmux-Auth": {user.bridge.AS.Registration.AppToken}}, + RequestJSON: chats, + }) } else { existingChats := make(map[id.UserID][]id.RoomID) err = intent.GetAccountData(event.AccountDataDirectChats.Type, &existingChats)