Skip to content

Commit

Permalink
Merge pull request #159 from blockchain-etl/slack-alerts-add-support-…
Browse files Browse the repository at this point in the history
…for-user-groups

Update Slack alert formatting to allow mention by user group
  • Loading branch information
charlielewisme committed Jun 29, 2023
2 parents 2022b81 + 3e797ed commit e86a69f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion airflow/dags/utils/error_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,15 @@ def handle_dag_failure(context: Dict) -> None:
override_owner_ids = json.loads(Variable.get(f"{platform}_alerts_dag_owners", "{}"))
relevant_user_ids_string = override_owner_ids.get(dag_id, default_user_id)
relevant_user_ids = relevant_user_ids_string.split(",")
owner_tags = [f"<@{relevant_user_id}>" for relevant_user_id in relevant_user_ids]

# Mention by user or user group
# https://api.slack.com/reference/surfaces/formatting#basics
owner_tags = [
f"<!subteam^{relevant_user_id}>"
if relevant_user_id.startswith("S")
else f"<@{relevant_user_id}>"
for relevant_user_id in relevant_user_ids
]
owner_text = ", ".join(owner_tags)

if platform == "discord":
Expand Down

0 comments on commit e86a69f

Please sign in to comment.