Skip to content

Commit

Permalink
Update Mautrix and send error state if connect fails
Browse files Browse the repository at this point in the history
  • Loading branch information
Fizzadar committed Dec 2, 2024
1 parent 3e9bf5a commit 2985b1e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ require (
golang.org/x/sync v0.9.0
google.golang.org/protobuf v1.35.2
gopkg.in/yaml.v3 v3.0.1
maunium.net/go/mautrix v0.22.0
maunium.net/go/mautrix v0.22.1-0.20241202131110-166ba04aae02
)

require (
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,5 @@ maunium.net/go/mauflag v1.0.0 h1:YiaRc0tEI3toYtJMRIfjP+jklH45uDHtT80nUamyD4M=
maunium.net/go/mauflag v1.0.0/go.mod h1:nLivPOpTpHnpzEh8jEdSL9UqO9+/KBJFmNRlwKfkPeA=
maunium.net/go/mautrix v0.22.0 h1:nLrnLYiMyFV6qZPqpkNogkOPgm2dQTYiQXlu9Nc3rz8=
maunium.net/go/mautrix v0.22.0/go.mod h1:oqwf9WYC/brqucM+heYk4gX11O59nP+ljvyxVhndFIM=
maunium.net/go/mautrix v0.22.1-0.20241202131110-166ba04aae02 h1:g8L4GpOhyg5EuXtASDKyU9Cg79ZjATlUnh+giFumQgc=
maunium.net/go/mautrix v0.22.1-0.20241202131110-166ba04aae02/go.mod h1:oqwf9WYC/brqucM+heYk4gX11O59nP+ljvyxVhndFIM=
12 changes: 9 additions & 3 deletions pkg/connector/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,21 +148,27 @@ func (wa *WhatsAppClient) IsThisUser(_ context.Context, userID networkid.UserID)
return userID == waid.MakeUserID(wa.JID)
}

func (wa *WhatsAppClient) Connect(ctx context.Context) error {
func (wa *WhatsAppClient) Connect(ctx context.Context) {
if wa.Client == nil {
state := status.BridgeState{
StateEvent: status.StateBadCredentials,
Error: WANotLoggedIn,
}
wa.UserLogin.BridgeState.Send(state)
return nil
return
}
wa.Main.firstClientConnectOnce.Do(wa.Main.onFirstClientConnect)
if err := wa.Main.updateProxy(ctx, wa.Client, false); err != nil {
zerolog.Ctx(ctx).Err(err).Msg("Failed to update proxy")
}
wa.startLoops()
return wa.Client.Connect()
if err := wa.Client.Connect(); err != nil {
state := status.BridgeState{
StateEvent: status.StateUnknownError,
Error: WAConnectionFailed,
}
wa.UserLogin.BridgeState.Send(state)
}
}

func (wa *WhatsAppClient) startLoops() {
Expand Down

0 comments on commit 2985b1e

Please sign in to comment.