Skip to content

Commit

Permalink
Checks if incident participant is a task assignee not owner before al…
Browse files Browse the repository at this point in the history
…lowing them to leave the incident conversation (#2737)

* Checks if reporter is a task assignee not owner when they leave the incident conversation

* Improves template messaging

* More messaging updates
  • Loading branch information
mvilanova authored Dec 1, 2022
1 parent 116e969 commit 06827ad
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
15 changes: 8 additions & 7 deletions src/dispatch/incident/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -1522,15 +1522,16 @@ def incident_remove_participant_flow(

for task in incident.tasks:
if task.status == TaskStatus.open:
if task.owner == participant:
# we add the participant back to the conversation
add_participants_to_conversation([user_email], incident, db_session)
for assignee in task.assignees:
if assignee == participant:
# we add the participant back to the conversation
add_participants_to_conversation([user_email], incident, db_session)

# we ask the participant to resolve or re-assign
# their tasks before leaving the incident
send_incident_open_tasks_ephemeral_message(user_email, incident, db_session)
# we ask the participant to resolve or re-assign
# their tasks before leaving the incident conversation
send_incident_open_tasks_ephemeral_message(user_email, incident, db_session)

return
return

if user_email == incident.commander.individual.email:
# we add the incident commander back to the conversation
Expand Down
2 changes: 1 addition & 1 deletion src/dispatch/incident/messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ def send_incident_open_tasks_ephemeral_message(
):
"""
Sends an ephemeral message to the participant asking them to resolve or re-assign
their open tasks before leaving the incident.
their open tasks before leaving the incident conversation.
"""
convo_plugin = plugin_service.get_active_instance(
db_session=db_session, project_id=incident.project.id, plugin_type="conversation"
Expand Down
4 changes: 2 additions & 2 deletions src/dispatch/messaging/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ class MessageType(DispatchEnum):
INCIDENT_TASK_LIST_DESCRIPTION = """The following are open incident tasks."""

INCIDENT_OPEN_TASKS_DESCRIPTION = """
Please resolve or transfer ownership of all the open incident tasks owned by you directly in the incident documents or using the <{{dispatch_ui_url}}|Dispatch Web UI>,
then wait about 30 seconds for Dispatch to update the tasks before leaving the incident channel.
Please resolve or transfer ownership of all the open incident tasks assigned to you in the incident documents or using the <{{dispatch_ui_url}}|Dispatch Web UI>,
then wait about 30 seconds for Dispatch to update the tasks before leaving the incident conversation.
""".replace(
"\n", " "
).strip()
Expand Down

0 comments on commit 06827ad

Please sign in to comment.