Skip to content

Commit

Permalink
client: send bad credentials if login is expired on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Nov 18, 2024
1 parent e34e100 commit 85c1bd0
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion pkg/connector/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"maunium.net/go/mautrix/bridgev2/networkid"

"go.mau.fi/mautrix-gmessages/pkg/libgm"
"go.mau.fi/mautrix-gmessages/pkg/libgm/events"
"go.mau.fi/mautrix-gmessages/pkg/libgm/gmproto"
)

Expand Down Expand Up @@ -94,7 +95,26 @@ func (gc *GMClient) Connect(ctx context.Context) error {
})
return nil
}
return gc.Client.Connect()
err := gc.Client.Connect()
if err != nil {
if errors.Is(err, events.ErrRequestedEntityNotFound) {
go gc.invalidateSession(ctx, status.BridgeState{
StateEvent: status.StateBadCredentials,
Error: GMUnpaired404,
Info: map[string]any{
"go_error": err.Error(),
},
})
} else {
gc.UserLogin.BridgeState.Send(status.BridgeState{
StateEvent: status.StateUnknownError,
Info: map[string]any{
"go_error": err.Error(),
},
})
}
}
return nil
}

func (gc *GMClient) Disconnect() {
Expand Down

0 comments on commit 85c1bd0

Please sign in to comment.