mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 21:13:36 +00:00
events: Fix bug in get_recent_conversations_recipient_id.
user_profile.id was confused for user_profile.recipient_id. These bugs
are particularly sneaky as they can go undetected by tests due to ids of
objects accidentally coinciding. We add a mitigation for this class of
mistakes by shifting the Recipient.id sequence in test db.
This was introduced in dda3ff41e1.
On the rare occasion where user_profile.id would coincide with
recipient_id passed to the function, we would return the wrong value.
That is, instead of correctly returning recipient_id, we would return
sender.recipient_id - recipient id of the sender of the message, thus
possibly returning user_profile.recipient_id (if user_profile is the
sender) - exactly the situation the function wanted to avoid
with the `if recipient_id == my_recipient_id:` if. Ultimately resulting
in incorrect/malformed data in
state['raw_recent_private_conversations'].
This commit is contained in:
committed by
Tim Abbott
parent
b8c8ea5262
commit
90636d5e81
@@ -1160,7 +1160,7 @@ def get_recent_conversations_recipient_id(user_profile: UserProfile,
|
||||
get_recent_private_conversations would have used to record that
|
||||
message in its data structure.
|
||||
"""
|
||||
my_recipient_id = user_profile.id
|
||||
my_recipient_id = user_profile.recipient_id
|
||||
if recipient_id == my_recipient_id:
|
||||
return UserProfile.objects.values_list('recipient_id', flat=True).get(id=sender_id)
|
||||
return recipient_id
|
||||
|
||||
Reference in New Issue
Block a user