Force-lowercase mobile source ID in google account pairing

This commit is contained in:
Tulir Asokan 2024-04-22 18:19:27 +02:00
parent 4cac56381b
commit c93884f6e6
2 changed files with 10 additions and 2 deletions

View file

@ -29,6 +29,7 @@ import (
"fmt" "fmt"
"io" "io"
"math/big" "math/big"
"strings"
"sync" "sync"
"time" "time"
@ -89,8 +90,11 @@ func (c *Client) signInGaiaGetToken(ctx context.Context) (*gmproto.SignInGaiaRes
return nil, err return nil, err
} }
c.updateTachyonAuthToken(resp.GetTokenData()) c.updateTachyonAuthToken(resp.GetTokenData())
c.AuthData.Mobile = resp.GetDeviceData().GetDeviceWrapper().GetDevice() device := resp.GetDeviceData().GetDeviceWrapper().GetDevice()
c.AuthData.Browser = resp.GetDeviceData().GetDeviceWrapper().GetDevice() lowercaseDevice := proto.Clone(device).(*gmproto.Device)
lowercaseDevice.SourceID = strings.ToLower(device.SourceID)
c.AuthData.Mobile = lowercaseDevice
c.AuthData.Browser = device
return resp, nil return resp, nil
} }

View file

@ -43,6 +43,7 @@ import (
"go.mau.fi/mautrix-gmessages/libgm" "go.mau.fi/mautrix-gmessages/libgm"
"go.mau.fi/mautrix-gmessages/libgm/events" "go.mau.fi/mautrix-gmessages/libgm/events"
"go.mau.fi/mautrix-gmessages/libgm/gmproto" "go.mau.fi/mautrix-gmessages/libgm/gmproto"
"go.mau.fi/mautrix-gmessages/libgm/util"
) )
type User struct { type User struct {
@ -600,6 +601,9 @@ func (user *User) Connect() bool {
} }
user.zlog.Debug().Msg("Connecting to Google Messages") user.zlog.Debug().Msg("Connecting to Google Messages")
user.BridgeState.Send(status.BridgeState{StateEvent: status.StateConnecting, Error: GMConnecting}) user.BridgeState.Send(status.BridgeState{StateEvent: status.StateConnecting, Error: GMConnecting})
if user.Session.Mobile.Network == util.GoogleNetwork {
user.Session.Mobile.SourceID = strings.ToLower(user.Session.Mobile.SourceID)
}
user.createClient(user.Session) user.createClient(user.Session)
err := user.Client.Connect() err := user.Client.Connect()
if err != nil { if err != nil {