From ae822103a7af8197f4213eddd79abe18713e75e9 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Wed, 27 Sep 2023 04:02:01 +0000 Subject: [PATCH] message: Add realm limit to private-message summary query. This query has two halves; messages set by the user, and messages received by the user. The former uses the already-specific usermessage privatemessage flag index; the latter relies on the recipient index on messages. Add the realm_id to the latter half, so that the recipient_id is paired with the realm_id. --- zerver/lib/message.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/zerver/lib/message.py b/zerver/lib/message.py index d85f373ff6..5cde4d16fd 100644 --- a/zerver/lib/message.py +++ b/zerver/lib/message.py @@ -1580,6 +1580,7 @@ def get_recent_private_conversations(user_profile: UserProfile) -> Dict[int, Dic ON m.sender_id = sender_profile.id WHERE + m.realm_id=%(realm_id)s AND m.recipient_id=%(my_recipient_id)s ORDER BY message_id DESC LIMIT %(conversation_limit)s) @@ -1595,6 +1596,7 @@ def get_recent_private_conversations(user_profile: UserProfile) -> Dict[int, Dic "user_profile_id": user_profile.id, "conversation_limit": RECENT_CONVERSATIONS_LIMIT, "my_recipient_id": my_recipient_id, + "realm_id": user_profile.realm_id, }, ) rows = cursor.fetchall()