mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 01:16:19 +00:00
push notifications: Fix exception when handling deleted messages.
If a user deletes message between when it triggered a potential push notification for another user, and when that notification was actually sent, we'd end up with a situation where the `Message` table didn't have an entry for the requested message ID. The clean fix for this is to still throw an exception in the event that the message doesn't exist at all, but if it exists in ArchivedMessage, don't throw a user-facing exception.
This commit is contained in:
@@ -400,6 +400,9 @@ def handle_missedmessage_emails(user_profile_id: int,
|
||||
if not receives_offline_email_notifications(user_profile):
|
||||
return
|
||||
|
||||
# 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.
|
||||
messages = Message.objects.filter(usermessage__user_profile_id=user_profile,
|
||||
id__in=message_ids,
|
||||
usermessage__flags=~UserMessage.flags.read)
|
||||
|
||||
Reference in New Issue
Block a user