Skip to content

Commit

Permalink
Fix/self join button (#4865)
Browse files Browse the repository at this point in the history
* added checks to self_join before creating join buttons

* updated participant user guide

Co-authored-by: Mike Laventure <[email protected]>
Co-authored-by: David Whittaker <[email protected]>
  • Loading branch information
3 people authored Jun 25, 2024
1 parent 0b2de50 commit f0c95fb
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/docs/user-guide/incidents/participant.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions src/dispatch/incident/messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down
15 changes: 8 additions & 7 deletions src/dispatch/incident/scheduled.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
13 changes: 13 additions & 0 deletions src/dispatch/messaging/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}}",
Expand Down

0 comments on commit f0c95fb

Please sign in to comment.