Browse Source

Update mautrix-go to add auth type to register requests

Tulir Asokan 4 năm trước cách đây
mục cha
commit
0b5eeef689
4 tập tin đã thay đổi với 13 bổ sung6 xóa
  1. 2 2
      crypto.go
  2. 1 1
      go.mod
  3. 4 0
      go.sum
  4. 6 3
      user.go

+ 2 - 2
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",

+ 1 - 1
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

+ 4 - 0
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=

+ 6 - 3
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)