Merge pull request #461 from grafana/fix-slack-message-blocks

Remove unused footer/duplicate block_id from post message to channel
This commit is contained in:
Michael Derynck 2022-09-01 07:40:46 -06:00 committed by GitHub
commit 1d3cb8761e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -24,7 +24,6 @@ class NotificationDeliveryStep(scenario_step.ScenarioStep):
self.post_message_to_channel(
f"Attempt to send an SMS to {user_verbal_with_mention} has been failed due to a plan limit",
alert_group.slack_message.channel_id,
color="red",
)
elif (
log_record.notification_error_code
@ -33,7 +32,6 @@ class NotificationDeliveryStep(scenario_step.ScenarioStep):
self.post_message_to_channel(
f"Attempt to call to {user_verbal_with_mention} has been failed due to a plan limit",
alert_group.slack_message.channel_id,
color="red",
)
elif (
log_record.notification_error_code
@ -42,7 +40,6 @@ class NotificationDeliveryStep(scenario_step.ScenarioStep):
self.post_message_to_channel(
f"Failed to send email to {user_verbal_with_mention}. Exceeded limit for mails",
alert_group.slack_message.channel_id,
color="red",
)
elif (
log_record.notification_error_code
@ -52,18 +49,14 @@ class NotificationDeliveryStep(scenario_step.ScenarioStep):
self.post_message_to_channel(
f"Failed to send an SMS to {user_verbal_with_mention}. Phone number is not verified",
alert_group.slack_message.channel_id,
color="red",
)
elif log_record.notification_channel == UserNotificationPolicy.NotificationChannel.PHONE_CALL:
self.post_message_to_channel(
f"Failed to call to {user_verbal_with_mention}. Phone number is not verified",
alert_group.slack_message.channel_id,
color="red",
)
def post_message_to_channel(self, text, channel, color=None, footer=None):
# TODO: No color in blocks, use prefix emoji?
# color_id = self.get_color_id(color)
def post_message_to_channel(self, text, channel):
blocks = [
{
"type": "section",
@ -73,15 +66,6 @@ class NotificationDeliveryStep(scenario_step.ScenarioStep):
"text": text,
},
},
{"type": "divider"},
{
"type": "section",
"block_id": "alert",
"text": {
"type": "mrkdwn",
"text": footer,
},
},
]
try:
# TODO: slack-onprem, check exceptions