From 264839b7d3bb02f1ba9e172ae4cbfda610685693 Mon Sep 17 00:00:00 2001 From: Marc Vilanova <39573146+mvilanova@users.noreply.github.com> Date: Thu, 1 Jul 2021 11:13:19 -0700 Subject: [PATCH 1/3] Re-adds slack_client to send_ephemeral_message call (#1388) --- src/dispatch/plugins/dispatch_slack/events.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dispatch/plugins/dispatch_slack/events.py b/src/dispatch/plugins/dispatch_slack/events.py index f8070048411c..29caaeb6c6d0 100644 --- a/src/dispatch/plugins/dispatch_slack/events.py +++ b/src/dispatch/plugins/dispatch_slack/events.py @@ -309,6 +309,7 @@ def ban_threads_warning( # value, when they differ the latter is a reply to the former. message = "Please refrain from using threads in incident related channels. Threads make it harder for incident participants to maintain context." dispatch_slack_service.send_ephemeral_message( + slack_client, channel_id, user_id, message, From 1466690d15f04b44cc03263721073db2def1b416 Mon Sep 17 00:00:00 2001 From: kevgliss Date: Thu, 1 Jul 2021 11:24:06 -0700 Subject: [PATCH 2/3] Only get users that have permission (#1387) * Only get users that have permission * Update src/dispatch/plugins/dispatch_jira/plugin.py Co-authored-by: Marc Vilanova <39573146+mvilanova@users.noreply.github.com> Co-authored-by: Marc Vilanova <39573146+mvilanova@users.noreply.github.com> --- src/dispatch/plugins/dispatch_jira/plugin.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/dispatch/plugins/dispatch_jira/plugin.py b/src/dispatch/plugins/dispatch_jira/plugin.py index 1161a9977508..29c9c9af588a 100644 --- a/src/dispatch/plugins/dispatch_jira/plugin.py +++ b/src/dispatch/plugins/dispatch_jira/plugin.py @@ -50,10 +50,12 @@ def get_email_username(email: str) -> str: return email -def get_user_field(client: JIRA, user_email) -> dict: +def get_user_field(client: JIRA, user_email: str, project_key: str) -> dict: """Returns correct Jira user field based on Jira hosting type.""" if JIRA_HOSTING_TYPE == "Server": - user = client.search_users(user_email, maxResults=1)[0] + user = client.search_allowed_users_for_issue( + user_email, projectKey=project_key, maxResults=1 + )[0] return {"name": user.name} if JIRA_HOSTING_TYPE == "Cloud": username = get_email_username(user_email) @@ -173,13 +175,14 @@ def create( """Creates a Jira issue.""" client = JIRA(str(JIRA_API_URL), basic_auth=(JIRA_USERNAME, str(JIRA_PASSWORD))) - assignee = get_user_field(client, commander_email) - reporter = get_user_field(client, reporter_email) - project_id, issue_type_name = process_incident_type_plugin_metadata( incident_type_plugin_metadata ) + project = client.project(project_id) + assignee = get_user_field(client, commander_email, project.key) + reporter = get_user_field(client, reporter_email, project.key) + issue_fields = { "project": {"id": project_id}, "issuetype": {"name": issue_type_name}, @@ -210,12 +213,13 @@ def update( """Updates Jira issue fields.""" client = JIRA(str(JIRA_API_URL), basic_auth=(JIRA_USERNAME, str(JIRA_PASSWORD))) - assignee = get_user_field(client, commander_email) - reporter = get_user_field(client, reporter_email) - commander_username = get_email_username(commander_email) issue = client.issue(ticket_id) + + assignee = get_user_field(client, commander_email, project_key=issue.fields.project.key) + reporter = get_user_field(client, reporter_email, project_key=issue.fields.project.key) + issue_fields = create_issue_fields( title=title, description=description, From a9e71c0aa3cb358930dc9f6503e9245c18b92d06 Mon Sep 17 00:00:00 2001 From: Marc Vilanova <39573146+mvilanova@users.noreply.github.com> Date: Thu, 1 Jul 2021 13:06:29 -0700 Subject: [PATCH 3/3] Let's re-resolve teams and individuals only when the incident status is active (#1389) --- src/dispatch/incident/flows.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dispatch/incident/flows.py b/src/dispatch/incident/flows.py index 08c9105fc138..017c14a088ff 100644 --- a/src/dispatch/incident/flows.py +++ b/src/dispatch/incident/flows.py @@ -1119,7 +1119,7 @@ def incident_update_flow( # add new folks to the incident if appropriate # we only have to do this for teams as new members will be added to tactical # groups on incident join - if incident.status != IncidentStatus.closed.value: + if incident.status == IncidentStatus.active.value: individual_participants, team_participants = get_incident_participants(incident, db_session) for individual, service_id in individual_participants: