From 8f59b26a6c86b6749eff47f2cd7bea1c0da55138 Mon Sep 17 00:00:00 2001 From: Aaron Herman Date: Tue, 24 Jun 2025 10:30:12 -0500 Subject: [PATCH] feat(cases): add case visibility notificaiton --- src/dispatch/case/messaging.py | 9 +++++++++ src/dispatch/messaging/strings.py | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/dispatch/case/messaging.py b/src/dispatch/case/messaging.py index 8242614ad531..1ac8f5c0f942 100644 --- a/src/dispatch/case/messaging.py +++ b/src/dispatch/case/messaging.py @@ -28,6 +28,7 @@ CASE_TYPE_CHANGE, CASE_SEVERITY_CHANGE, CASE_PRIORITY_CHANGE, + CASE_VISIBILITY_CHANGE, CASE_CLOSED_RATING_FEEDBACK_NOTIFICATION, MessageType, generate_welcome_message, @@ -219,6 +220,10 @@ def send_case_update_notifications(case: Case, previous_case: CaseRead, db_sessi change = True notification_template.append(CASE_PRIORITY_CHANGE) + if previous_case.visibility != case.visibility: + change = True + notification_template.append(CASE_VISIBILITY_CHANGE) + if not change: # we don't need to send notifications log.debug("Case updated notifications not sent. No changes were made.") @@ -251,6 +256,8 @@ def send_case_update_notifications(case: Case, previous_case: CaseRead, db_sessi case_status_old=previous_case.status, case_type_new=case.case_type.name, case_type_old=previous_case.case_type.name, + case_visibility_new=case.visibility, + case_visibility_old=previous_case.visibility, name=case.name, ticket_weblink=case.ticket.weblink, title=case.title, @@ -286,6 +293,8 @@ def send_case_update_notifications(case: Case, previous_case: CaseRead, db_sessi "case_status_old": previous_case.status, "case_type_new": case.case_type.name, "case_type_old": previous_case.case_type.name, + "case_visibility_new": case.visibility, + "case_visibility_old": previous_case.visibility, "name": case.name, "organization_slug": case.project.organization.slug, "ticket_weblink": resolve_attr(case, "ticket.weblink"), diff --git a/src/dispatch/messaging/strings.py b/src/dispatch/messaging/strings.py index a791e7e2c3c4..0a26587da322 100644 --- a/src/dispatch/messaging/strings.py +++ b/src/dispatch/messaging/strings.py @@ -554,6 +554,11 @@ class MessageType(DispatchEnum): "\n", " " ).strip() +CASE_VISIBILITY_CHANGE_DESCRIPTION = """ +The case visibility has been changed from {{ case_visibility_old }} to {{ case_visibility_new }}.""".replace( + "\n", " " +).strip() + CASE_STATUS_CHANGE = { "title": "Status Change", "text": CASE_STATUS_CHANGE_DESCRIPTION, @@ -571,6 +576,11 @@ class MessageType(DispatchEnum): "text": CASE_PRIORITY_CHANGE_DESCRIPTION, } +CASE_VISIBILITY_CHANGE = { + "title": "Visibility Change", + "text": CASE_VISIBILITY_CHANGE_DESCRIPTION, +} + INCIDENT_NAME = { "title": "{{name}} Incident Notification", "title_link": "{{ticket_weblink}}",