Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/tracking-sheet
Browse files Browse the repository at this point in the history
  • Loading branch information
kevgliss authored Jul 1, 2021
2 parents eb046ff + a9e71c0 commit 574c423
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/dispatch/incident/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,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:
if incident.status == IncidentStatus.active:
individual_participants, team_participants = get_incident_participants(incident, db_session)

for individual, service_id in individual_participants:
Expand Down
20 changes: 12 additions & 8 deletions src/dispatch/plugins/dispatch_jira/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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},
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/dispatch/plugins/dispatch_slack/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 574c423

Please sign in to comment.