diff --git a/libgm/events/qr.go b/libgm/events/qr.go index 2f95175..c69dd88 100644 --- a/libgm/events/qr.go +++ b/libgm/events/qr.go @@ -9,5 +9,6 @@ type QR struct { } type PairSuccessful struct { - *gmproto.PairedData + PhoneID string + QRData *gmproto.PairedData } diff --git a/libgm/pair.go b/libgm/pair.go index 1a6212b..81ab02f 100644 --- a/libgm/pair.go +++ b/libgm/pair.go @@ -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, diff --git a/libgm/pair_google.go b/libgm/pair_google.go index 121092a..786b449 100644 --- a/libgm/pair_google.go +++ b/libgm/pair_google.go @@ -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, diff --git a/user.go b/user.go index cf07bac..1505443 100644 --- a/user.go +++ b/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")