Skip to content

Commit

Permalink
Force-lowercase mobile source ID in google account pairing
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Apr 22, 2024
1 parent 4cac563 commit c93884f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 6 additions & 2 deletions libgm/pair_google.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"fmt"
"io"
"math/big"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -89,8 +90,11 @@ func (c *Client) signInGaiaGetToken(ctx context.Context) (*gmproto.SignInGaiaRes
return nil, err
}
c.updateTachyonAuthToken(resp.GetTokenData())
c.AuthData.Mobile = resp.GetDeviceData().GetDeviceWrapper().GetDevice()
c.AuthData.Browser = resp.GetDeviceData().GetDeviceWrapper().GetDevice()
device := 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
}

Expand Down
4 changes: 4 additions & 0 deletions user.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
"go.mau.fi/mautrix-gmessages/libgm"
"go.mau.fi/mautrix-gmessages/libgm/events"
"go.mau.fi/mautrix-gmessages/libgm/gmproto"
"go.mau.fi/mautrix-gmessages/libgm/util"
)

type User struct {
Expand Down Expand Up @@ -600,6 +601,9 @@ func (user *User) Connect() bool {
}
user.zlog.Debug().Msg("Connecting to Google Messages")
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)
err := user.Client.Connect()
if err != nil {
Expand Down

0 comments on commit c93884f

Please sign in to comment.