Skip to content

Commit

Permalink
dependencies: update mautrix-go
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Dec 2, 2024
1 parent 1d54054 commit 9f8c19e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
go.mau.fi/util v0.8.2
golang.org/x/net v0.31.0
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
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,5 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
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=
22 changes: 16 additions & 6 deletions pkg/connector/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,39 +154,49 @@ func (s *SlackClient) handleBootError(ctx context.Context, err error) {
}
}

func (s *SlackClient) Connect(ctx context.Context) error {
func (s *SlackClient) Connect(ctx context.Context) {
if s.Client == nil {
s.UserLogin.BridgeState.Send(status.BridgeState{
StateEvent: status.StateBadCredentials,
Error: "slack-not-logged-in",
})
return nil
return
}
var bootResp *slack.ClientBootResponse
if s.IsRealUser {
var err error
bootResp, err = s.Client.ClientBootContext(ctx)
if err != nil {
s.handleBootError(ctx, err)
return err
return
}
} else {
teamResp, err := s.Client.GetTeamInfoContext(ctx)
if err != nil {
zerolog.Ctx(ctx).Err(err).Msg("Failed to fetch team info")
s.handleBootError(ctx, err)
return fmt.Errorf("failed to fetch team info: %w", err)
return
}
userResp, err := s.Client.GetUserInfoContext(ctx, s.UserID)
if err != nil {
zerolog.Ctx(ctx).Err(err).Msg("Failed to fetch user info")
s.handleBootError(ctx, err)
return fmt.Errorf("failed to fetch user info: %w", err)
return
}
bootResp = &slack.ClientBootResponse{
Self: *userResp,
Team: *teamResp,
}
}
return s.connect(ctx, bootResp)
err := s.connect(ctx, bootResp)
if err != nil {
zerolog.Ctx(ctx).Err(err).Msg("Failed to connect")
s.UserLogin.BridgeState.Send(status.BridgeState{
StateEvent: status.StateUnknownError,
Error: "slack-unknown-connect-error",
Message: fmt.Sprintf("Unknown error from Slack: %s", err.Error()),
})
}
}

func (s *SlackClient) connect(ctx context.Context, bootResp *slack.ClientBootResponse) error {
Expand Down
5 changes: 1 addition & 4 deletions pkg/connector/login-app.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,7 @@ func (s *SlackAppLogin) SubmitUserInput(ctx context.Context, input map[string]st
return nil, err
}
sc := ul.Client.(*SlackClient)
err = sc.Connect(ul.Log.WithContext(context.Background()))
if err != nil {
return nil, fmt.Errorf("failed to connect after login: %w", err)
}
go sc.Connect(ul.Log.WithContext(context.Background()))
return &bridgev2.LoginStep{
Type: bridgev2.LoginStepTypeComplete,
StepID: LoginStepIDComplete,
Expand Down

0 comments on commit 9f8c19e

Please sign in to comment.