diff --git a/docs/docs/user-guide/incidents/participant.mdx b/docs/docs/user-guide/incidents/participant.mdx index dfc8645d7ee8..50e88bf867e3 100644 --- a/docs/docs/user-guide/incidents/participant.mdx +++ b/docs/docs/user-guide/incidents/participant.mdx @@ -59,7 +59,7 @@ After an incident is marked stable, Dispatch continues to help with incident man In addition to Dispatch engaging individuals that will be directly responsible for managing the incident, it provides notifications for general awareness throughout the organization. :::info -The new incident notification message includes a "Join" button; this allows individuals to add themselves to the incident \(and its resources\) without involvement from the incident commander. +The new incident notification message includes a "Join" button if "Self-Join" is enabled on the project; this allows individuals to add themselves to the incident \(and its resources\) without involvement from the incident commander. ::: ## Self-service engagement diff --git a/src/dispatch/incident/messaging.py b/src/dispatch/incident/messaging.py index ab19cd4f3497..038b8b6ccfbb 100644 --- a/src/dispatch/incident/messaging.py +++ b/src/dispatch/incident/messaging.py @@ -47,6 +47,7 @@ INCIDENT_TYPE_CHANGE, INCIDENT_COMPLETED_FORM_MESSAGE, INCIDENT_TASK_ADD_TO_INCIDENT, + INCIDENT_NAME_WITH_ENGAGEMENT_NO_SELF_JOIN, MessageType, generate_welcome_message, ) @@ -379,7 +380,10 @@ def send_incident_created_notifications(incident: Incident, db_session: SessionL notification_template = INCIDENT_NOTIFICATION.copy() if incident.status != IncidentStatus.closed: - notification_template.insert(0, INCIDENT_NAME_WITH_ENGAGEMENT) + if incident.project.allow_self_join: + notification_template.insert(0, INCIDENT_NAME_WITH_ENGAGEMENT) + else: + notification_template.insert(0, INCIDENT_NAME_WITH_ENGAGEMENT_NO_SELF_JOIN) else: notification_template.insert(0, INCIDENT_NAME) @@ -526,7 +530,10 @@ def send_incident_update_notifications( # we send a notification to the notification conversations and emails fyi_notification_template = notification_template.copy() if incident.status != IncidentStatus.closed: - fyi_notification_template.insert(0, INCIDENT_NAME_WITH_ENGAGEMENT) + if incident.project.allow_self_join: + fyi_notification_template.insert(0, INCIDENT_NAME_WITH_ENGAGEMENT) + else: + fyi_notification_template.insert(0, INCIDENT_NAME_WITH_ENGAGEMENT_NO_SELF_JOIN) else: fyi_notification_template.insert(0, INCIDENT_NAME) diff --git a/src/dispatch/incident/scheduled.py b/src/dispatch/incident/scheduled.py index a06878615a55..27376b245da6 100644 --- a/src/dispatch/incident/scheduled.py +++ b/src/dispatch/incident/scheduled.py @@ -168,13 +168,14 @@ def incident_report_daily(db_session: SessionLocal, project: Project): "button_action": f"{ConversationButtonActions.subscribe_user}-{incident.status}-{idx}", } ) - item["buttons"].append( - { - "button_text": "Join", - "button_value": f"{incident.project.organization.slug}-{incident.id}", - "button_action": f"{ConversationButtonActions.invite_user}-{incident.status}-{idx}", - } - ) + if incident.project.allow_self_join: + item["buttons"].append( + { + "button_text": "Join", + "button_value": f"{incident.project.organization.slug}-{incident.id}", + "button_action": f"{ConversationButtonActions.invite_user}-{incident.status}-{idx}", + } + ) items_grouped.append(item) except Exception as e: diff --git a/src/dispatch/messaging/strings.py b/src/dispatch/messaging/strings.py index c4910311676d..d166af654fe6 100644 --- a/src/dispatch/messaging/strings.py +++ b/src/dispatch/messaging/strings.py @@ -388,6 +388,19 @@ class MessageType(DispatchEnum): ], } +INCIDENT_NAME_WITH_ENGAGEMENT_NO_SELF_JOIN = { + "title": "{{name}} Incident Notification", + "title_link": "{{ticket_weblink}}", + "text": INCIDENT_NOTIFICATION_PURPOSES_FYI, + "buttons": [ + { + "button_text": "Subscribe", + "button_value": "{{organization_slug}}-{{incident_id}}", + "button_action": ConversationButtonActions.subscribe_user, + }, + ], +} + INCIDENT_NAME = { "title": "{{name}} Incident Notification", "title_link": "{{ticket_weblink}}",