Skip to content

Commit

Permalink
Check for case assignee before trying to send reminder (#4218)
Browse files Browse the repository at this point in the history
* Check for case assignee before trying to send reminder

Updated return types for definitions, changed None checks to use "is None" instead of "not" and added a None check for assignee when sending case close reminders

* Update src/dispatch/case/messaging.py

Co-authored-by: David Whittaker <[email protected]>

---------

Co-authored-by: David Whittaker <[email protected]>
  • Loading branch information
jschroth and whitdog47 authored Jan 8, 2024
1 parent 18c176b commit c6fb835
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/dispatch/case/messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
log = logging.getLogger(__name__)


def send_case_close_reminder(case: Case, db_session: SessionLocal):
def send_case_close_reminder(case: Case, db_session: SessionLocal) -> None:
"""
Sends a direct message to the assignee reminding them to close the case if possible.
"""
Expand All @@ -30,9 +30,12 @@ def send_case_close_reminder(case: Case, db_session: SessionLocal):
plugin = plugin_service.get_active_instance(
db_session=db_session, project_id=case.project.id, plugin_type="conversation"
)
if not plugin:
if plugin is None:
log.warning("Case close reminder message not sent. No conversation plugin enabled.")
return
if case.assignee is None:
log.warning(f"Case close reminder message not sent. No assignee for {case.name}.")
return

items = [
{
Expand All @@ -54,7 +57,7 @@ def send_case_close_reminder(case: Case, db_session: SessionLocal):
log.debug(f"Case close reminder sent to {case.assignee.individual.email}.")


def send_case_triage_reminder(case: Case, db_session: SessionLocal):
def send_case_triage_reminder(case: Case, db_session: SessionLocal) -> None:
"""
Sends a direct message to the assignee reminding them to triage the case if possible.
"""
Expand All @@ -64,12 +67,12 @@ def send_case_triage_reminder(case: Case, db_session: SessionLocal):
plugin = plugin_service.get_active_instance(
db_session=db_session, project_id=case.project.id, plugin_type="conversation"
)
if not plugin:
if plugin is None:
log.warning("Case triage reminder message not sent. No conversation plugin enabled.")
return

if not case.assignee:
log.warning("Case triage reminder message not sent. No assignee.")
if case.assignee is None:
log.warning(f"Case triage reminder message not sent. No assignee for {case.name}.")
return

items = [
Expand Down

0 comments on commit c6fb835

Please sign in to comment.