Skip to content

Commit e0c7f94

Browse files
reconfigured code to maintain slack ids in dict
1 parent 7fdb624 commit e0c7f94

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

sde_collections/utils/slack_utils.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33

44
from ..models.collection_choice_fields import WorkflowStatusChoices
55

6+
SLACK_ID_MAPPING = {
7+
"Shravan Vishwanathan": "<@U056B4HMGEP>",
8+
"Advait Yogaonkar": "<@U06L5SKQ5QA>",
9+
"channel": "<!here>",
10+
}
11+
612
STATUS_CHANGE_NOTIFICATIONS = {
713
(WorkflowStatusChoices.RESEARCH_IN_PROGRESS, WorkflowStatusChoices.READY_FOR_ENGINEERING): {
814
"message": "Research on {name} is complete. Ready for engineering! :rocket:",
@@ -23,19 +29,23 @@
2329
"message": "LRM QC passed for {name}. Ready for final quality check! :white_check_mark:",
2430
},
2531
(WorkflowStatusChoices.READY_FOR_FINAL_QUALITY_CHECK, WorkflowStatusChoices.QUALITY_CHECK_FAILED): {
26-
"message": "<@U056B4HMGEP> <@U06L5SKQ5QA> Quality check on {name} has failed. Changes needed! :x:",
32+
"message": "Quality check on {name} has failed. Changes needed! :x:",
33+
"mention_users": ["Shravan Vishwanathan", "Advait Yogaonkar"],
2734
},
2835
(WorkflowStatusChoices.READY_FOR_FINAL_QUALITY_CHECK, WorkflowStatusChoices.QUALITY_CHECK_PERFECT): {
2936
"message": "{name} has passed all quality checks and is ready for public production! :white_check_mark:",
37+
"mention_users": ["channel"],
3038
},
3139
(WorkflowStatusChoices.READY_FOR_FINAL_QUALITY_CHECK, WorkflowStatusChoices.QUALITY_CHECK_MINOR): {
3240
"message": "{name} has passed all quality checks and is ready for public production! :white_check_mark:",
3341
},
3442
(WorkflowStatusChoices.QUALITY_CHECK_PERFECT, WorkflowStatusChoices.PROD_PERFECT): {
3543
"message": "<!here> {name} is now live on Public Prod! Congrats team! :sparkles:",
44+
"mention_users": ["channel"],
3645
},
3746
(WorkflowStatusChoices.QUALITY_CHECK_MINOR, WorkflowStatusChoices.PROD_MINOR): {
3847
"message": "<!here> {name} is now live on Public Prod! Congrats team! :sparkles:",
48+
"mention_users": ["channel"],
3949
},
4050
}
4151

@@ -44,6 +54,9 @@ def format_slack_message(name, details, collection_id):
4454
message_template = details["message"]
4555
link = f"https://sde-indexing-helper.nasa-impact.net/{collection_id}/" # noqa: E231
4656
linked_name = f"<{link}|{name}>"
57+
if "mention_users" in details:
58+
slack_mentions = " ".join(SLACK_ID_MAPPING[user] for user in details["mention_users"])
59+
return slack_mentions + " " + message_template.format(name=linked_name)
4760
return message_template.format(name=linked_name)
4861

4962

0 commit comments

Comments
 (0)