From 500f030fb36dd95695deade0adf57ca7e9823fa0 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Thu, 5 Oct 2023 12:56:42 +0300 Subject: [PATCH] Send phone not responding alerts to management room --- user.go | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/user.go b/user.go index 5afcb4f..48e0ee0 100644 --- a/user.go +++ b/user.go @@ -68,15 +68,16 @@ type User struct { spaceMembershipChecked bool - longPollingError error - browserInactiveType status.BridgeStateErrorCode - batteryLow bool - mobileData bool - phoneResponding bool - ready bool - sessionID string - batteryLowAlertSent time.Time - pollErrorAlertSent bool + longPollingError error + browserInactiveType status.BridgeStateErrorCode + batteryLow bool + mobileData bool + phoneResponding bool + ready bool + sessionID string + batteryLowAlertSent time.Time + pollErrorAlertSent bool + phoneNotRespondingAlertSent bool loginInProgress atomic.Bool pairSuccessChan chan struct{} @@ -576,9 +577,18 @@ func (user *User) syncHandleEvent(event any) { case *events.PhoneNotResponding: user.phoneResponding = false user.BridgeState.Send(status.BridgeState{StateEvent: status.StateConnected}) + // TODO make this properly configurable + if user.zlog.Trace().Enabled() && !user.phoneNotRespondingAlertSent { + go user.sendMarkdownBridgeAlert(false, "Phone is not responding") + user.phoneNotRespondingAlertSent = true + } case *events.PhoneRespondingAgain: user.phoneResponding = true user.BridgeState.Send(status.BridgeState{StateEvent: status.StateConnected}) + if user.phoneNotRespondingAlertSent { + go user.sendMarkdownBridgeAlert(false, "Phone is responding again") + user.phoneNotRespondingAlertSent = false + } case *events.PingFailed: if errors.Is(v.Error, events.ErrRequestedEntityNotFound) { go user.Logout(status.BridgeState{