diff --git a/go.mod b/go.mod index 130abfe..c80c8fc 100644 --- a/go.mod +++ b/go.mod @@ -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 ( diff --git a/go.sum b/go.sum index 367de20..9f05e87 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/pkg/connector/client.go b/pkg/connector/client.go index 6d1b194..defbec9 100644 --- a/pkg/connector/client.go +++ b/pkg/connector/client.go @@ -154,13 +154,13 @@ 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 { @@ -168,25 +168,35 @@ func (s *SlackClient) Connect(ctx context.Context) 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 { diff --git a/pkg/connector/login-app.go b/pkg/connector/login-app.go index c326d3b..a5846c9 100644 --- a/pkg/connector/login-app.go +++ b/pkg/connector/login-app.go @@ -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,