Properly set phone ID when pairing with google account
This commit is contained in:
parent
2ca85cf2bd
commit
6c4d8d8744
4 changed files with 7 additions and 6 deletions
|
@ -9,5 +9,6 @@ type QR struct {
|
|||
}
|
||||
|
||||
type PairSuccessful struct {
|
||||
*gmproto.PairedData
|
||||
PhoneID string
|
||||
QRData *gmproto.PairedData
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ func (c *Client) completePairing(data *gmproto.PairedData) {
|
|||
c.AuthData.Mobile = data.Mobile
|
||||
c.AuthData.Browser = data.Browser
|
||||
|
||||
c.triggerEvent(&events.PairSuccessful{PairedData: data})
|
||||
c.triggerEvent(&events.PairSuccessful{PhoneID: data.GetMobile().GetSourceID(), QRData: data})
|
||||
|
||||
go func() {
|
||||
// Sleep for a bit to let the phone save the pair data. If we reconnect too quickly,
|
||||
|
|
|
@ -297,7 +297,7 @@ func (c *Client) DoGaiaPairing(emojiCallback func(string)) error {
|
|||
c.AuthData.RequestCrypto.AESKey = doHKDF(ps.NextKey, encryptionKeyInfo, []byte("client"))
|
||||
c.AuthData.RequestCrypto.HMACKey = doHKDF(ps.NextKey, encryptionKeyInfo, []byte("server"))
|
||||
c.AuthData.PairingID = ps.UUID
|
||||
c.triggerEvent(&events.PairSuccessful{})
|
||||
c.triggerEvent(&events.PairSuccessful{PhoneID: c.AuthData.Mobile.GetSourceID()})
|
||||
|
||||
go func() {
|
||||
// Sleep for a bit to let the phone save the pair data. If we reconnect too quickly,
|
||||
|
|
6
user.go
6
user.go
|
@ -698,14 +698,14 @@ func (user *User) syncHandleEvent(event any) {
|
|||
}
|
||||
case *events.PairSuccessful:
|
||||
user.Session = user.Client.AuthData
|
||||
if user.PhoneID != "" && user.PhoneID != v.GetMobile().GetSourceID() {
|
||||
if user.PhoneID != "" && user.PhoneID != v.PhoneID {
|
||||
user.zlog.Warn().
|
||||
Str("old_phone_id", user.PhoneID).
|
||||
Str("new_phone_id", v.GetMobile().GetSourceID()).
|
||||
Str("new_phone_id", v.PhoneID).
|
||||
Msg("Phone ID changed, resetting state")
|
||||
user.ResetState()
|
||||
}
|
||||
user.PhoneID = v.GetMobile().GetSourceID()
|
||||
user.PhoneID = v.PhoneID
|
||||
err := user.Update(context.TODO())
|
||||
if err != nil {
|
||||
user.zlog.Err(err).Msg("Failed to update session in database")
|
||||
|
|
Loading…
Reference in a new issue