Skip to content

Commit

Permalink
Merge pull request #1738 from elementary-data/ele-3775-send-alerts-to…
Browse files Browse the repository at this point in the history
…-deleted-slack-channel

send alert to default channel as fallback
  • Loading branch information
MikaKerman authored Nov 6, 2024
2 parents 77cb308 + 58c45fa commit f935d7a
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1124,6 +1124,25 @@ def send_alert(
)
sent_successfully = False

if (
not sent_successfully
and self.config.slack_channel_name
and channel_name != self.config.slack_channel_name
):
try:
logger.debug(
f"Sending alert to default Slack channel: {self.config.slack_channel_name}"
)
channel_name = self.config.slack_channel_name
sent_successfully = self.client.send_message(
channel_name=channel_name, message=template
)
except Exception as err:
logger.error(
f"Unable to send alert via Slack to default channel: {err}"
)
sent_successfully = False

if not sent_successfully:
try:
fallback_template = self._get_fallback_template(alert)
Expand Down

0 comments on commit f935d7a

Please sign in to comment.