Skip to content

Commit

Permalink
fix(slack): skip after hours notification if no participant (#5419)
Browse files Browse the repository at this point in the history
  • Loading branch information
whitdog47 authored Nov 4, 2024
1 parent 96b0b87 commit 624110b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/dispatch/plugins/dispatch_slack/case/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,13 @@ def handle_case_after_hours_message(
participant = participant_service.get_by_case_id_and_email(
db_session=db_session, case_id=context["subject"].id, email=user.email
)
# handle no participant found
if not participant:
log.warning(
f"Participant not found for {user.email} in case {case.id}. Skipping after hours notification."
)
return

# get their timezone from slack
owner_tz = (dispatch_slack_service.get_user_info_by_email(client, email=owner_email))["tz"]
message = f"Responses may be delayed. The current case priority is *{case.case_priority.name}* and your message was sent outside of the Assignee's working hours (Weekdays, 9am-5pm, {owner_tz} timezone)."
Expand Down
3 changes: 3 additions & 0 deletions src/dispatch/plugins/dispatch_slack/incident/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,9 @@ def handle_after_hours_message(
)
# handle no participant found
if not participant:
log.warning(
f"Participant not found for {user.email} in incident {incident.id}. Skipping after hours notification."
)
return

# get their timezone from slack
Expand Down

0 comments on commit 624110b

Please sign in to comment.