Skip to content

Commit

Permalink
capture and log more detail when email recipients aren't defined
Browse files Browse the repository at this point in the history
  • Loading branch information
pbugni committed Mar 6, 2024
1 parent 13926c4 commit f1f9e9b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions portal/models/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ def send_message(self, cc_address=None):
NB the cc isn't persisted with the rest of the record.
"""
if not self.recipients:
current_app.logger.error(
"can't email w/o recipients. failed to send "
f"'{self.subject}' to user {self.recipient_id}")
message = Message(
subject=self.subject,
extra_headers=extra_headers(),
Expand Down
2 changes: 2 additions & 0 deletions portal/trigger_states/empro_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def patient_email(patient, soft_triggers, hard_triggers):
mr = MailResource(
app_text(name), locale_code=patient.locale_code, variables=args)
em = EmailMessage(
recipient_id=patient.id,
recipients=patient.email,
sender=current_app.config['MAIL_DEFAULT_SENDER'],
subject=mr.subject,
Expand Down Expand Up @@ -120,6 +121,7 @@ def staff_emails(patient, hard_triggers, initial_notification):
locale_code=staff.locale_code,
variables=args)
emails.append(EmailMessage(
recipient_id=staff.id,
recipients=staff.email,
sender=current_app.config['MAIL_DEFAULT_SENDER'],
subject=mr.subject,
Expand Down

0 comments on commit f1f9e9b

Please sign in to comment.