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 b7e9e38a3895..23736c9c79d4 100644 --- a/src/dispatch/messaging/strings.py +++ b/src/dispatch/messaging/strings.py @@ -558,6 +558,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, @@ -575,6 +580,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}}",