diff --git a/bridgestate.go b/bridgestate.go index 1a837e9..b9b47ec 100644 --- a/bridgestate.go +++ b/bridgestate.go @@ -23,6 +23,7 @@ import ( const ( GMListenError status.BridgeStateErrorCode = "gm-listen-error" GMFatalError status.BridgeStateErrorCode = "gm-listen-fatal-error" + GMUnpaired status.BridgeStateErrorCode = "gm-unpaired" GMNotConnected status.BridgeStateErrorCode = "gm-not-connected" GMConnecting status.BridgeStateErrorCode = "gm-connecting" GMConnectionFailed status.BridgeStateErrorCode = "gm-connection-failed" @@ -35,7 +36,8 @@ const ( func init() { status.BridgeStateHumanErrors.Update(status.BridgeStateErrorMap{ GMListenError: "Error polling messages from Google Messages server, the bridge will try to reconnect", - GMFatalError: "Google Messages login was invalidated, please re-link the bridge", + GMFatalError: "Google Messages token was invalidated, please re-link the bridge", + GMUnpaired: "The bridge was unpaired from Google Messages, please re-link the bridge", GMBrowserInactive: "Google Messages opened in another browser", GMBrowserInactiveTimeout: "Google Messages disconnected due to timeout", GMBrowserInactiveInactivity: "Google Messages disconnected due to inactivity", diff --git a/libgm/pairing_handler.go b/libgm/pairing_handler.go index ab324e9..94eea7b 100644 --- a/libgm/pairing_handler.go +++ b/libgm/pairing_handler.go @@ -23,6 +23,7 @@ func (c *Client) handlePairingEvent(response *pblite.Response) { } case *binary.PairEvents_Revoked: c.Logger.Debug().Any("data", evt).Msg("Revoked Device") + c.triggerEvent(evt.Revoked) default: c.Logger.Debug().Any("response", response).Any("evt", evt).Msg("Invalid PairEvents type") } diff --git a/user.go b/user.go index 9517446..f08ad0b 100644 --- a/user.go +++ b/user.go @@ -546,6 +546,12 @@ func (user *User) HandleEvent(event interface{}) { if err != nil { user.zlog.Err(err).Msg("Failed to update session in database") } + case *binary.RevokePairData: + user.zlog.Info().Any("revoked_device", v.GetRevokedDevice()).Msg("Got pair revoked event") + user.Logout(status.BridgeState{ + StateEvent: status.StateBadCredentials, + Error: GMUnpaired, + }, false) case *events.AuthTokenRefreshed: err := user.Update(context.TODO()) if err != nil {