diff --git a/cmd/botkube-agent/main.go b/cmd/botkube-agent/main.go index bd840b626..6851b0da7 100644 --- a/cmd/botkube-agent/main.go +++ b/cmd/botkube-agent/main.go @@ -267,7 +267,7 @@ func run(ctx context.Context) (err error) { } if commGroupCfg.Mattermost.Enabled { - mb, err := bot.NewMattermost(commGroupLogger.WithField(botLogFieldKey, "Mattermost"), commGroupName, commGroupCfg.Mattermost, executorFactory, reporter) + mb, err := bot.NewMattermost(ctx, commGroupLogger.WithField(botLogFieldKey, "Mattermost"), commGroupName, commGroupCfg.Mattermost, executorFactory, reporter) if err != nil { return reportFatalError("while creating Mattermost bot", err) } diff --git a/pkg/bot/mattermost.go b/pkg/bot/mattermost.go index 0eb4abb92..f0086ad3f 100644 --- a/pkg/bot/mattermost.go +++ b/pkg/bot/mattermost.go @@ -71,7 +71,7 @@ type mattermostMessage struct { } // NewMattermost creates a new Mattermost instance. -func NewMattermost(log logrus.FieldLogger, commGroupName string, cfg config.Mattermost, executorFactory ExecutorFactory, reporter AnalyticsReporter) (*Mattermost, error) { +func NewMattermost(ctx context.Context, log logrus.FieldLogger, commGroupName string, cfg config.Mattermost, executorFactory ExecutorFactory, reporter AnalyticsReporter) (*Mattermost, error) { botMentionRegex, err := mattermostBotMentionRegex(cfg.BotName) if err != nil { return nil, err @@ -90,7 +90,6 @@ func NewMattermost(log logrus.FieldLogger, commGroupName string, cfg config.Matt client := model.NewAPIv4Client(cfg.URL) client.SetOAuthToken(cfg.Token) - ctx := context.Background() botTeams, _, err := client.SearchTeams(ctx, &model.TeamSearch{ Term: cfg.Team, })