notifications: Add safeties to prevent incorrect notifications.

de04f0ad67 changed now notifications recipients were calculated, in
a manner that caused them to be sent when they should not have been.
ac70a2d2e1 was supposed to resolve this, but appears to have been
insufficient, as all three of these cases have been observed to still
happen.

Add safety checks immediately before notification, until the
underlying logic error can be sussed out.
This commit is contained in:
Alex Vandiver
2021-09-01 17:49:20 -07:00
committed by Tim Abbott
parent 5b45f8a128
commit 094f22e6b4
2 changed files with 15 additions and 0 deletions

View File

@@ -569,6 +569,10 @@ def handle_missedmessage_emails(
# Never email bot users.
return
if not user_profile.enable_offline_email_notifications:
# BUG: Investigate why it's possible to get here.
return # nocoverage
# Note: This query structure automatically filters out any
# messages that were permanently deleted, since those would now be
# in the ArchivedMessage table, not the Message table.