Skip to content

Commit 7cb13f8

Browse files
committed
bridgev2/status: add user_action field for bridge states
1 parent 89b4190 commit 7cb13f8

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

bridgev2/bridgestate.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ func (bsq *BridgeStateQueue) loop() {
7676

7777
func (bsq *BridgeStateQueue) sendNotice(ctx context.Context, state status.BridgeState) {
7878
noticeConfig := bsq.bridge.Config.BridgeStatusNotices
79-
isError := state.StateEvent == status.StateBadCredentials || state.StateEvent == status.StateUnknownError
79+
isError := state.StateEvent == status.StateBadCredentials ||
80+
state.StateEvent == status.StateUnknownError ||
81+
state.UserAction == status.UserActionOpenNative
8082
sendNotice := noticeConfig == "all" || (noticeConfig == "errors" &&
8183
(isError || (bsq.errorSent && state.StateEvent == status.StateConnected)))
8284
if !sendNotice {

bridgev2/status/bridgestate.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ func (e BridgeStateEvent) IsValid() bool {
7373
}
7474
}
7575

76+
type BridgeStateUserAction string
77+
78+
const (
79+
UserActionOpenNative BridgeStateUserAction = "OPEN_NATIVE"
80+
UserActionRelogin BridgeStateUserAction = "RELOGIN"
81+
)
82+
7683
type RemoteProfile struct {
7784
Phone string `json:"phone,omitempty"`
7885
Email string `json:"email,omitempty"`
@@ -110,6 +117,8 @@ type BridgeState struct {
110117
Error BridgeStateErrorCode `json:"error,omitempty"`
111118
Message string `json:"message,omitempty"`
112119

120+
UserAction BridgeStateUserAction `json:"user_action,omitempty"`
121+
113122
UserID id.UserID `json:"user_id,omitempty"`
114123
RemoteID string `json:"remote_id,omitempty"`
115124
RemoteName string `json:"remote_name,omitempty"`
@@ -192,6 +201,7 @@ func (pong *BridgeState) ShouldDeduplicate(newPong *BridgeState) bool {
192201
return pong != nil &&
193202
pong.StateEvent == newPong.StateEvent &&
194203
pong.RemoteName == newPong.RemoteName &&
204+
pong.UserAction == newPong.UserAction &&
195205
ptr.Val(pong.RemoteProfile) == ptr.Val(newPong.RemoteProfile) &&
196206
pong.Error == newPong.Error &&
197207
maps.EqualFunc(pong.Info, newPong.Info, reflect.DeepEqual) &&

0 commit comments

Comments
 (0)