Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ type Config struct {

SigningSecret string `password:"true" info:"Signing secret to verify requests from slack."`
InteractiveMessages bool `info:"Enable interactive messages (e.g. buttons)."`
DisableBroadcastThreadReplies bool `info:"Disable broadcasting alert status updates in threads to the main channel." public:"true"`
}

Twilio struct {
Expand Down
8 changes: 8 additions & 0 deletions graphql2/mapconfig.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions notification/slack/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,11 +457,17 @@ func (s *ChannelSender) SendMessage(ctx context.Context, msg notification.Messag
channelID, ts = chanTS(channelID, t.OriginalStatus.ProviderMessageID.ExternalID)

// Reply in thread if we already sent a message for this alert.
opts = append(opts,
threadOpts := []slack.MsgOption{
slack.MsgOptionTS(ts),
slack.MsgOptionBroadcast(),
slack.MsgOptionText(alertLink(ctx, t.AlertID, t.Summary), false),
)
}

// Conditionally add broadcast based on config (default: enabled)
if !cfg.Slack.DisableBroadcastThreadReplies {
threadOpts = append(threadOpts, slack.MsgOptionBroadcast())
}

opts = append(opts, threadOpts...)
break
}

Expand Down
38 changes: 38 additions & 0 deletions test/smoke/slacknotification_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,41 @@ func TestSlackNotification(t *testing.T) {
// should broadcast reply to channel
msg.ExpectBroadcastReply("Alert #1")
}

// TestSlackNotification_NoBroadcast tests that thread replies don't broadcast when disabled.
func TestSlackNotification_NoBroadcast(t *testing.T) {
t.Parallel()

sql := `
insert into escalation_policies (id, name, repeat)
values
({{uuid "eid"}}, 'esc policy', 1);
insert into escalation_policy_steps (id, escalation_policy_id, delay)
values
({{uuid "esid"}}, {{uuid "eid"}}, 30);

insert into notification_channels (id, type, name, value)
values
({{uuid "chan"}}, 'SLACK', '#test', {{slackChannelID "test"}});

insert into escalation_policy_actions (escalation_policy_step_id, channel_id)
values
({{uuid "esid"}}, {{uuid "chan"}});

insert into services (id, escalation_policy_id, name)
values
({{uuid "sid"}}, {{uuid "eid"}}, 'service');
`
h := harness.NewHarness(t, sql, "slack-user-link")
defer h.Close()

// Disable broadcast
h.SetConfigValue("Slack.DisableBroadcastThreadReplies", "true")

h.CreateAlert(h.UUID("sid"), "testing")
msg := h.Slack().Channel("test").ExpectMessage("testing")

h.FastForward(time.Hour)
// Should reply in thread WITHOUT broadcast
msg.ExpectThreadReply("Alert #1")
}
1 change: 1 addition & 0 deletions web/src/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1657,6 +1657,7 @@ type ConfigID =
| 'Slack.AccessToken'
| 'Slack.SigningSecret'
| 'Slack.InteractiveMessages'
| 'Slack.DisableBroadcastThreadReplies'
| 'Twilio.Enable'
| 'Twilio.VoiceName'
| 'Twilio.VoiceLanguage'
Expand Down