notifications: Group messages by (recipient, sender) for PM's.

This fixes a issue with multiple PM's being clubbed into a single
missed message email.

Fixes #6224.
This commit is contained in:
Aditya Bansal
2017-08-25 07:45:05 +05:30
committed by Tim Abbott
parent 0693656b89
commit 6a2c83f051
2 changed files with 31 additions and 1 deletions

View File

@@ -367,7 +367,11 @@ def handle_missedmessage_emails(user_profile_id, missed_email_events):
messages_by_recipient_subject = defaultdict(list) # type: Dict[Tuple[int, Text], List[Message]]
for msg in messages:
messages_by_recipient_subject[(msg.recipient_id, msg.topic_name())].append(msg)
if msg.recipient.type == Recipient.PERSONAL:
# For PM's group using (recipient, sender).
messages_by_recipient_subject[(msg.recipient_id, msg.sender_id)].append(msg)
else:
messages_by_recipient_subject[(msg.recipient_id, msg.topic_name())].append(msg)
message_count_by_recipient_subject = {
recipient_subject: len(msgs)