Send phone not responding alerts to management room
This commit is contained in:
parent
766d79562a
commit
500f030fb3
1 changed files with 19 additions and 9 deletions
10
user.go
10
user.go
|
@ -77,6 +77,7 @@ type User struct {
|
|||
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{
|
||||
|
|
Loading…
Reference in a new issue