Skip to content

Commit

Permalink
Update bridge info if IDS registration fails due to registration prov…
Browse files Browse the repository at this point in the history
…ider error
  • Loading branch information
tulir committed Dec 21, 2023
1 parent d1c5ef8 commit fcdf41f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions imessage/ipc/bridgeinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ func GetBridgeInfo() *BridgeInfo {
}
}
resp.NextReregisterCheck = nextReregisterCheck.UTC()
if global.NACNotReachable {
resp.RegistrationProviderError = ErrBadRegistrationCode.Message
}

return &resp
}
7 changes: 7 additions & 0 deletions imessage/ipc/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package main
import (
"context"
"crypto/sha256"
"errors"
"fmt"
"regexp"
"slices"
Expand All @@ -36,6 +37,7 @@ import (
"github.com/beeper/imessage/database"
"github.com/beeper/imessage/imessage"
"github.com/beeper/imessage/imessage/direct"
"github.com/beeper/imessage/imessage/direct/nacserv"
"github.com/beeper/imessage/imessage/direct/util/uri"
"github.com/beeper/imessage/msgconv"
)
Expand Down Expand Up @@ -846,6 +848,10 @@ func handleEvent(evt any) {
handleDelivered(typedEvt)

case *direct.IDSRegisterFail:
if errors.Is(typedEvt.Error, nacserv.ErrProviderNotReachable) {
global.NACNotReachable = true
global.IPC.Send(CmdBridgeInfo, GetBridgeInfo())
}
analytics.Track("IMGo IDS Register Failure", map[string]any{
"bi": true,
"error": typedEvt.Error.Error(),
Expand Down Expand Up @@ -919,6 +925,7 @@ func handleEvent(evt any) {
}
global.IPC.Send(CmdBridgeInfo, GetBridgeInfo())
case *direct.IDSActuallyReregistered:
global.NACNotReachable = false
global.IPC.Send(CmdBridgeInfo, GetBridgeInfo())
case *direct.IDSRegisterSuccess:
//go updateGroupOutgoingHandles()
Expand Down
1 change: 1 addition & 0 deletions imessage/ipc/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ type IMContext struct {

StartConfirmed bool
InitialConfigureDone bool
NACNotReachable bool

Stopping atomic.Bool
}
Expand Down

0 comments on commit fcdf41f

Please sign in to comment.