Skip to content
This repository was archived by the owner on Sep 3, 2025. It is now read-only.

Commit 7537df7

Browse files
nathanmyeeNathan Yeeaaronherman
authored
Emojify and simplify change notifications for incidents and cases (#6173)
* Emojify and simplify change notifications * Update formatting for case assignee * Update jinja formatting from feedback * Set dictionary on a single line for the linter --------- Co-authored-by: Nathan Yee <nyee@netflix.com> Co-authored-by: Aaron Herman <12768929+aaronherman@users.noreply.github.com>
1 parent 556220f commit 7537df7

File tree

4 files changed

+44
-90
lines changed

4 files changed

+44
-90
lines changed

src/dispatch/case/messaging.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,10 @@ def send_case_update_notifications(case: Case, previous_case: CaseRead, db_sessi
248248
assignee_fullname=case.assignee.individual.name,
249249
assignee_team=case.assignee.team,
250250
assignee_weblink=case.assignee.individual.weblink,
251-
case_priority_new=case.case_priority.name,
252-
case_priority_old=previous_case.case_priority.name,
253-
case_severity_new=case.case_severity.name,
254-
case_severity_old=previous_case.case_severity.name,
251+
case_priority_new=case.case_priority,
252+
case_priority_old=previous_case.case_priority,
253+
case_severity_new=case.case_severity,
254+
case_severity_old=previous_case.case_severity,
255255
case_status_new=case.status,
256256
case_status_old=previous_case.status,
257257
case_type_new=case.case_type.name,
@@ -285,10 +285,10 @@ def send_case_update_notifications(case: Case, previous_case: CaseRead, db_sessi
285285
"contact_fullname": case.assignee.individual.name,
286286
"contact_weblink": case.assignee.individual.weblink,
287287
"case_id": case.id,
288-
"case_priority_new": case.case_priority.name,
289-
"case_priority_old": previous_case.case_priority.name,
290-
"case_severity_new": case.case_severity.name,
291-
"case_severity_old": previous_case.case_severity.name,
288+
"case_priority_new": case.case_priority,
289+
"case_priority_old": previous_case.case_priority,
290+
"case_severity_new": case.case_severity,
291+
"case_severity_old": previous_case.case_severity,
292292
"case_status_new": case.status,
293293
"case_status_old": previous_case.status,
294294
"case_type_new": case.case_type.name,

src/dispatch/incident/messaging.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -453,10 +453,10 @@ def send_incident_update_notifications(
453453
commander_fullname=incident.commander.individual.name,
454454
commander_team=incident.commander.team,
455455
commander_weblink=incident.commander.individual.weblink,
456-
incident_priority_new=incident.incident_priority.name,
457-
incident_priority_old=previous_incident.incident_priority.name,
458-
incident_severity_new=incident.incident_severity.name,
459-
incident_severity_old=previous_incident.incident_severity.name,
456+
incident_priority_new=incident.incident_priority,
457+
incident_priority_old=previous_incident.incident_priority,
458+
incident_severity_new=incident.incident_severity,
459+
incident_severity_old=previous_incident.incident_severity,
460460
incident_status_new=incident.status,
461461
incident_status_old=previous_incident.status,
462462
incident_type_new=incident.incident_type.name,
@@ -487,10 +487,10 @@ def send_incident_update_notifications(
487487
"contact_fullname": incident.commander.individual.name,
488488
"contact_weblink": incident.commander.individual.weblink,
489489
"incident_id": incident.id,
490-
"incident_priority_new": incident.incident_priority.name,
491-
"incident_priority_old": previous_incident.incident_priority.name,
492-
"incident_severity_new": incident.incident_severity.name,
493-
"incident_severity_old": previous_incident.incident_severity.name,
490+
"incident_priority_new": incident.incident_priority,
491+
"incident_priority_old": previous_incident.incident_priority,
492+
"incident_severity_new": incident.incident_severity,
493+
"incident_severity_old": previous_incident.incident_severity,
494494
"incident_status_new": incident.status,
495495
"incident_status_old": previous_incident.status,
496496
"incident_type_new": incident.incident_type.name,

src/dispatch/messaging/strings.py

Lines changed: 19 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -431,28 +431,9 @@ class MessageType(DispatchEnum):
431431
ONCALL_SHIFT_FEEDBACK_RECEIVED_DESCRIPTION = """
432432
We received your feedback for your shift that ended {{ shift_end_at }} UTC. Thank you!"""
433433

434-
INCIDENT_STATUS_CHANGE_DESCRIPTION = """
435-
The incident status has been changed from {{ incident_status_old }} to {{ incident_status_new }}.""".replace(
436-
"\n", " "
437-
).strip()
438-
439-
INCIDENT_TYPE_CHANGE_DESCRIPTION = """
440-
The incident type has been changed from {{ incident_type_old }} to {{ incident_type_new }}.""".replace(
441-
"\n", " "
442-
).strip()
443-
444-
INCIDENT_SEVERITY_CHANGE_DESCRIPTION = """
445-
The incident severity has been changed from {{ incident_severity_old }} to {{ incident_severity_new }}.""".replace(
446-
"\n", " "
447-
).strip()
448-
449-
INCIDENT_PRIORITY_CHANGE_DESCRIPTION = """
450-
The incident priority has been changed from {{ incident_priority_old }} to {{ incident_priority_new }}.""".replace(
451-
"\n", " "
452-
).strip()
453434

454435
INCIDENT_NAME_WITH_ENGAGEMENT = {
455-
"title": "{{name}} Incident Notification",
436+
"title": ":rotating_light: {{name}} Incident Notification",
456437
"title_link": "{{ticket_weblink}}",
457438
"text": NOTIFICATION_PURPOSES_FYI,
458439
"buttons": [
@@ -488,7 +469,7 @@ class MessageType(DispatchEnum):
488469
}
489470

490471
INCIDENT_NAME_WITH_ENGAGEMENT_NO_SELF_JOIN = {
491-
"title": "{{name}} Incident Notification",
472+
"title": ":rotating_light: {{name}} Incident Notification",
492473
"title_link": "{{ticket_weblink}}",
493474
"text": NOTIFICATION_PURPOSES_FYI,
494475
"buttons": [
@@ -501,13 +482,13 @@ class MessageType(DispatchEnum):
501482
}
502483

503484
CASE_NAME = {
504-
"title": "{{name}} Case Notification",
485+
"title": ":briefcase: {{name}} Case Notification",
505486
"title_link": "{{ticket_weblink}}",
506487
"text": NOTIFICATION_PURPOSES_FYI,
507488
}
508489

509490
CASE_NAME_WITH_ENGAGEMENT = {
510-
"title": "{{name}} Case Notification",
491+
"title": ":briefcase: {{name}} Case Notification",
511492
"title_link": "{{ticket_weblink}}",
512493
"text": NOTIFICATION_PURPOSES_FYI,
513494
"buttons": [
@@ -533,60 +514,32 @@ class MessageType(DispatchEnum):
533514
}
534515

535516
CASE_NAME_WITH_ENGAGEMENT_NO_SELF_JOIN = {
536-
"title": "{{name}} Case Notification",
517+
"title": ":briefcase: {{name}} Case Notification",
537518
"title_link": "{{ticket_weblink}}",
538519
"text": NOTIFICATION_PURPOSES_FYI,
539520
}
540521

541-
CASE_STATUS_CHANGE_DESCRIPTION = """
542-
The case status has been changed from {{ case_status_old }} to {{ case_status_new }}.""".replace(
543-
"\n", " "
544-
).strip()
545-
546-
CASE_TYPE_CHANGE_DESCRIPTION = """
547-
The case type has been changed from {{ case_type_old }} to {{ case_type_new }}.""".replace(
548-
"\n", " "
549-
).strip()
550-
551-
CASE_SEVERITY_CHANGE_DESCRIPTION = """
552-
The case severity has been changed from {{ case_severity_old }} to {{ case_severity_new }}.""".replace(
553-
"\n", " "
554-
).strip()
555-
556-
CASE_PRIORITY_CHANGE_DESCRIPTION = """
557-
The case priority has been changed from {{ case_priority_old }} to {{ case_priority_new }}.""".replace(
558-
"\n", " "
559-
).strip()
560-
561-
CASE_VISIBILITY_CHANGE_DESCRIPTION = """
562-
The case visibility has been changed from {{ case_visibility_old }} to {{ case_visibility_new }}.""".replace(
563-
"\n", " "
564-
).strip()
565522

566523
CASE_STATUS_CHANGE = {
567-
"title": "Status Change",
568-
"text": CASE_STATUS_CHANGE_DESCRIPTION,
524+
"title": "*{% set status_emojis = {'Closed': ':white_check_mark:', 'New': ':new:', 'Triage': ':mag:', 'Stable': ':shield:', 'Escalated': ':arrow_up:'} %}{{ status_emojis.get(case_status_new, ':arrows_counterclockwise:') }} Status Change:* {{ case_status_old }} → {{ case_status_new }}",
569525
}
570526

571-
CASE_TYPE_CHANGE = {"title": "Case Type Change", "text": CASE_TYPE_CHANGE_DESCRIPTION}
527+
CASE_TYPE_CHANGE = {"title": "*:label: Case Type Change:* {{ case_type_old }} → {{ case_type_new }}"}
572528

573529
CASE_SEVERITY_CHANGE = {
574-
"title": "Severity Change",
575-
"text": CASE_SEVERITY_CHANGE_DESCRIPTION,
530+
"title": "*{% if case_severity_old.view_order < case_severity_new.view_order %}:arrow_up:{% elif case_severity_old.view_order > case_severity_new.view_order %}:arrow_down:{% else %}:left_right_arrow:{% endif %} Severity Change:* {{ case_severity_old.name }} → {{ case_severity_new.name }}",
576531
}
577532

578533
CASE_PRIORITY_CHANGE = {
579-
"title": "Priority Change",
580-
"text": CASE_PRIORITY_CHANGE_DESCRIPTION,
534+
"title": "*{% if case_priority_old.view_order < case_priority_new.view_order %}:arrow_up:{% elif case_priority_old.view_order > case_priority_new.view_order %}:arrow_down:{% else %}:left_right_arrow:{% endif %} Priority Change:* {{ case_priority_old.name }} → {{ case_priority_new.name }}",
581535
}
582536

583537
CASE_VISIBILITY_CHANGE = {
584-
"title": "Visibility Change",
585-
"text": CASE_VISIBILITY_CHANGE_DESCRIPTION,
538+
"title": "*{% set visibility_emojis = {'Open': ':unlock:', 'Restricted': ':lock:'} %}{{ visibility_emojis.get(case_visibility_new, ':eye:') }} Visibility Change:* {{ case_visibility_old }} → {{ case_visibility_new }}",
586539
}
587540

588541
INCIDENT_NAME = {
589-
"title": "{{name}} Incident Notification",
542+
"title": ":rotating_light: {{name}} Incident Notification",
590543
"title_link": "{{ticket_weblink}}",
591544
"text": NOTIFICATION_PURPOSES_FYI,
592545
}
@@ -599,9 +552,9 @@ class MessageType(DispatchEnum):
599552

600553
INCIDENT_SUMMARY = {"title": "Summary", "text": "{{summary}}"}
601554

602-
INCIDENT_TITLE = {"title": "Title", "text": "{{title}}"}
555+
INCIDENT_TITLE = {"title": "*:memo: Title:* {{title}}"}
603556

604-
CASE_TITLE = {"title": "Title", "text": "{{title}}"}
557+
CASE_TITLE = {"title": "*:memo: Title:* {{title}}"}
605558

606559
CASE_STATUS = {
607560
"title": "Status - {{status}}",
@@ -662,8 +615,7 @@ class MessageType(DispatchEnum):
662615
}
663616

664617
INCIDENT_COMMANDER = {
665-
"title": "Commander - {{commander_fullname}}, {{commander_team}}",
666-
"title_link": "{{commander_weblink}}",
618+
"title": ":firefighter: Commander: <{{commander_weblink}}|{{commander_fullname}}, {{commander_team}}>",
667619
"text": INCIDENT_COMMANDER_DESCRIPTION,
668620
}
669621

@@ -710,20 +662,17 @@ class MessageType(DispatchEnum):
710662
}
711663

712664
INCIDENT_STATUS_CHANGE = {
713-
"title": "Status Change",
714-
"text": INCIDENT_STATUS_CHANGE_DESCRIPTION,
665+
"title": "*{% set status_emojis = {'Closed': ':white_check_mark:', 'Stable': ':shield:', 'Active': ':fire:'} %}{{ status_emojis.get(incident_status_new, ':arrows_counterclockwise:') }} Status Change:* {{ incident_status_old }} → {{ incident_status_new }}",
715666
}
716667

717-
INCIDENT_TYPE_CHANGE = {"title": "Incident Type Change", "text": INCIDENT_TYPE_CHANGE_DESCRIPTION}
668+
INCIDENT_TYPE_CHANGE = {"title": "*:label: Incident Type Change:* {{ incident_type_old }} → {{ incident_type_new }}"}
718669

719670
INCIDENT_SEVERITY_CHANGE = {
720-
"title": "Severity Change",
721-
"text": INCIDENT_SEVERITY_CHANGE_DESCRIPTION,
671+
"title": "*{% if incident_severity_old.view_order < incident_severity_new.view_order %}:arrow_up:{% elif incident_severity_old.view_order > incident_severity_new.view_order %}:arrow_down:{% else %}:left_right_arrow:{% endif %} Severity Change:* {{ incident_severity_old.name }} → {{ incident_severity_new.name }}",
722672
}
723673

724674
INCIDENT_PRIORITY_CHANGE = {
725-
"title": "Priority Change",
726-
"text": INCIDENT_PRIORITY_CHANGE_DESCRIPTION,
675+
"title": "*{% if incident_priority_old.view_order < incident_priority_new.view_order %}:arrow_up:{% elif incident_priority_old.view_order > incident_priority_new.view_order %}:arrow_down:{% else %}:left_right_arrow:{% endif %} Priority Change:* {{ incident_priority_old.name }} → {{ incident_priority_new.name }}",
727676
}
728677

729678
INCIDENT_PARTICIPANT_SUGGESTED_READING_ITEM = {
@@ -904,8 +853,7 @@ class MessageType(DispatchEnum):
904853
}
905854

906855
CASE_ASSIGNEE = {
907-
"title": "Assignee - {{assignee_fullname}}, {{assignee_team}}",
908-
"title_link": "{{assignee_weblink}}",
856+
"title": ":female-detective: Assignee: <{{assignee_weblink}}|{{assignee_fullname}}, {{assignee_team}}>",
909857
"text": CASE_ASSIGNEE_DESCRIPTION,
910858
}
911859

src/dispatch/plugins/dispatch_slack/messaging.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,18 @@ def build_unexpected_error_message(guid: str) -> str:
190190
def format_default_text(item: dict):
191191
"""Creates the correct Slack text string based on the item context."""
192192
if item.get("title_link"):
193-
return f"*<{item['title_link']}|{item['title']}>*\n{item['text']}"
193+
text_part = f"\n{item['text']}" if item.get('text') else ""
194+
return f"*<{item['title_link']}|{item['title']}>*{text_part}"
194195
if item.get("datetime"):
195196
return f"*{item['title']}*\n <!date^{int(item['datetime'].timestamp())}^ {{date}} | {item['datetime']}"
196197
if item.get("title"):
197-
return f"*{item['title']}*\n{item['text']}"
198-
return item["text"]
198+
text_part = f"\n{item['text']}" if item.get('text') else ""
199+
# Check if title already has formatting (contains asterisks)
200+
if '*' in item['title']:
201+
return f"{item['title']}{text_part}"
202+
else:
203+
return f"*{item['title']}*{text_part}"
204+
return item.get("text", "")
199205

200206

201207
def default_notification(items: list):

0 commit comments

Comments
 (0)