Skip to content

Commit

Permalink
Add additional debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
pkosiec committed Jul 31, 2023
1 parent 0b6f85c commit 7fc3fec
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/bot/mattermost.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ func NewMattermost(ctx context.Context, log logrus.FieldLogger, commGroupName st
return nil, err
}

mmURL := strings.TrimSuffix(cfg.URL, "/")

mmURL := strings.TrimSuffix(cfg.URL, "/") // This is needed for WS connection as `model.NewWebSocketClient4` already removes it
checkURL, err := url.Parse(mmURL)
if err != nil {
return nil, fmt.Errorf("while parsing Mattermost URL %q: %w", mmURL, err)
Expand All @@ -90,6 +89,11 @@ func NewMattermost(ctx context.Context, log logrus.FieldLogger, commGroupName st
webSocketURL = WebSocketSecureProtocol + checkURL.Host + checkURL.Path
}

log.WithFields(logrus.Fields{
"webSocketURL": webSocketURL,
"apiURL": mmURL,
}).Debugf("Setting up Mattermost bot...")

client := model.NewAPIv4Client(mmURL)
client.SetOAuthToken(cfg.Token)
botTeams, _, err := client.SearchTeams(ctx, &model.TeamSearch{
Expand All @@ -100,7 +104,7 @@ func NewMattermost(ctx context.Context, log logrus.FieldLogger, commGroupName st
}

if len(botTeams) == 0 {
return nil, fmt.Errorf("team: %s not found", cfg.Team)
return nil, fmt.Errorf("team %q not found", cfg.Team)
}
botTeam := botTeams[0]
// In Mattermost v7.0+, what we see in MM Console is `display_name` of team.
Expand Down

0 comments on commit 7fc3fec

Please sign in to comment.