mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 04:53:36 +00:00
message_cache: Use the sender’s recipient_id for incoming 1:1 DMs.
For an incoming 1:1 DM, the recipient’s own recipient_id is useless to the recipient themselves. Substitute the sender’s recipient_id, so the recipient can use recipient_id as documented to uniquely represent the set of 2 users in this conversation. Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
6ef0f0c072
commit
e2d56db2a3
@@ -4089,6 +4089,7 @@ class GetOldMessagesTest(ZulipTestCase):
|
||||
client_gravatar=False,
|
||||
can_access_sender=True,
|
||||
realm_host=get_realm("zulip").host,
|
||||
is_incoming_1_to_1=False,
|
||||
)
|
||||
self.assertEqual(final_dict["content"], "<p>test content</p>")
|
||||
|
||||
@@ -4884,6 +4885,24 @@ WHERE user_profile_id = {hamlet_id} AND (content ILIKE '%jumping%' OR subject IL
|
||||
'@<span class="highlight">Othello</span>, the Moor of Venice</span>?</p>',
|
||||
)
|
||||
|
||||
def test_dm_recipient_id(self) -> None:
|
||||
hamlet = self.example_user("hamlet")
|
||||
othello = self.example_user("othello")
|
||||
self.login_user(hamlet)
|
||||
|
||||
outgoing_message_id = self.send_personal_message(hamlet, othello)
|
||||
incoming_message_id = self.send_personal_message(othello, hamlet)
|
||||
|
||||
result = self.get_and_check_messages(dict(anchor="newest", num_before=2))
|
||||
self.assert_length(result["messages"], 2)
|
||||
self.assertEqual(result["messages"][0]["id"], outgoing_message_id)
|
||||
self.assertEqual(result["messages"][0]["sender_id"], hamlet.id)
|
||||
self.assertEqual(result["messages"][0]["recipient_id"], othello.recipient_id)
|
||||
self.assertEqual(result["messages"][1]["id"], incoming_message_id)
|
||||
self.assertEqual(result["messages"][1]["sender_id"], othello.id)
|
||||
# Incoming DMs show the recipient_id that outgoing DMs would.
|
||||
self.assertEqual(result["messages"][1]["recipient_id"], othello.recipient_id)
|
||||
|
||||
|
||||
class MessageHasKeywordsTest(ZulipTestCase):
|
||||
"""Test for keywords like has_link, has_image, has_attachment."""
|
||||
|
||||
Reference in New Issue
Block a user