Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
message_cache: Remove is_incoming_1_to_1 recipient_id substitution.
Alex Vandiver8d08760f9e86
diff --git a/zerver/lib/message.py b/zerver/lib/message.pyindex f57dcddccbf..8b544365fd8 100644--- a/zerver/lib/message.py+++ b/zerver/lib/message.py@@ -366,7 +366,6 @@ def messages_for_ids(client_gravatar=client_gravatar,allow_empty_topic_name=allow_empty_topic_name,realm=realm,- user_recipient_id=None if user_profile is None else user_profile.recipient_id,)return message_listdiff --git a/zerver/lib/message_cache.py b/zerver/lib/message_cache.pyindex 112b5771f9e..c9ec0f3cd6c 100644--- a/zerver/lib/message_cache.py+++ b/zerver/lib/message_cache.py@@ -162,7 +162,6 @@ class MessageDict:client_gravatar: bool,allow_empty_topic_name: bool,realm: Realm,- user_recipient_id: int | None,) -> None:"""NOTE: This function mutates the objects in@@ -185,7 +184,6 @@ class MessageDict:skip_copy=True,can_access_sender=can_access_sender,realm_host=realm.host,- is_incoming_1_to_1=obj["recipient_id"] == user_recipient_id,)@staticmethod@@ -199,7 +197,6 @@ class MessageDict:skip_copy: bool = False,can_access_sender: bool,realm_host: str,- is_incoming_1_to_1: bool,) -> dict[str, Any]:"""By default, we make a shallow copy of the incoming dict to avoid@@ -256,7 +253,6 @@ class MessageDict:if not keep_rendered_content:del obj["rendered_content"]- obj.pop("sender_recipient_id")del obj["sender_realm_id"]del obj["sender_avatar_source"]del obj["sender_delivery_email"]@@ -497,7 +493,6 @@ class MessageDict:for obj in objs:sender_id = obj["sender_id"]user_row = sender_dict[sender_id]- obj["sender_recipient_id"] = user_row["recipient_id"]obj["sender_full_name"] = user_row["full_name"]obj["sender_email"] = user_row["email"]obj["sender_delivery_email"] = user_row["delivery_email"]diff --git a/zerver/lib/outgoing_webhook.py b/zerver/lib/outgoing_webhook.pyindex bbf1e7ffd5e..81cf6346d98 100644--- a/zerver/lib/outgoing_webhook.py+++ b/zerver/lib/outgoing_webhook.py@@ -69,7 +69,6 @@ class GenericOutgoingWebhookService(OutgoingWebhookServiceInterface):get_user_profile_by_id(event["message"]["sender_id"]), self.user_profile),realm_host=realm.host,- is_incoming_1_to_1=event["message"]["recipient_id"] == self.user_profile.recipient_id,)request_data = {diff --git a/zerver/tests/test_event_system.py b/zerver/tests/test_event_system.pyindex ddd92342f5f..06b12bcdbcd 100644--- a/zerver/tests/test_event_system.py+++ b/zerver/tests/test_event_system.py@@ -931,7 +931,6 @@ class ClientDescriptorsTest(ZulipTestCase):queue_timeout=0,realm_id=realm.id,user_profile_id=hamlet.id,- user_recipient_id=hamlet.recipient_id,)client = allocate_client_descriptor(queue_data)@@ -986,7 +985,6 @@ class ClientDescriptorsTest(ZulipTestCase):queue_timeout=0,realm_id=realm.id,user_profile_id=hamlet.id,- user_recipient_id=hamlet.recipient_id,)client = allocate_client_descriptor(queue_data)@@ -1034,12 +1032,10 @@ class ClientDescriptorsTest(ZulipTestCase):self,*,user_profile_id: int,- user_recipient_id: int | None,apply_markdown: bool,client_gravatar: bool,) -> None:self.user_profile_id = user_profile_id- self.user_recipient_id = user_recipient_idself.apply_markdown = apply_markdownself.client_gravatar = client_gravatarself.client_type_name = "whatever"@@ -1058,28 +1054,24 @@ class ClientDescriptorsTest(ZulipTestCase):client1 = MockClient(user_profile_id=hamlet.id,- user_recipient_id=hamlet.recipient_id,apply_markdown=True,client_gravatar=False,)client2 = MockClient(user_profile_id=hamlet.id,- user_recipient_id=hamlet.recipient_id,apply_markdown=False,client_gravatar=False,)client3 = MockClient(user_profile_id=hamlet.id,- user_recipient_id=hamlet.recipient_id,apply_markdown=True,client_gravatar=True,)client4 = MockClient(user_profile_id=hamlet.id,- user_recipient_id=hamlet.recipient_id,apply_markdown=False,client_gravatar=True,)@@ -1117,7 +1109,6 @@ class ClientDescriptorsTest(ZulipTestCase):# NOTE: Some of these fields are clutter, but some# will be useful when we let clients specify# that they can compute their own gravatar URLs.- sender_recipient_id=sender.recipient_id,sender_email=sender.email,sender_delivery_email=sender.delivery_email,sender_realm_id=sender.realm_id,@@ -1248,7 +1239,6 @@ class ReloadWebClientsTest(ZulipTestCase):queue_timeout=0,realm_id=realm.id,user_profile_id=hamlet.id,- user_recipient_id=hamlet.recipient_id,)client = allocate_client_descriptor(queue_data)diff --git a/zerver/tests/test_message_dict.py b/zerver/tests/test_message_dict.pyindex 1c174ff11fb..475ccc4a64f 100644--- a/zerver/tests/test_message_dict.py+++ b/zerver/tests/test_message_dict.py@@ -84,7 +84,6 @@ class MessageDictTest(ZulipTestCase):allow_empty_topic_name=True,can_access_sender=True,realm_host=get_realm("zulip").host,- is_incoming_1_to_1=False,)return narrow_dict@@ -101,7 +100,6 @@ class MessageDictTest(ZulipTestCase):client_gravatar=client_gravatar,allow_empty_topic_name=True,realm=get_realm("zulip"),- user_recipient_id=None,)final_dict = unhydrated_dictreturn final_dict@@ -187,7 +185,6 @@ class MessageDictTest(ZulipTestCase):client_gravatar=False,allow_empty_topic_name=True,realm=realm,- user_recipient_id=None,)self.assert_length(objs, num_ids)diff --git a/zerver/tests/test_message_fetch.py b/zerver/tests/test_message_fetch.pyindex 15668016342..481804eed3b 100644--- a/zerver/tests/test_message_fetch.py+++ b/zerver/tests/test_message_fetch.py@@ -4404,7 +4404,6 @@ class GetOldMessagesTest(ZulipTestCase):allow_empty_topic_name=True,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>")diff --git a/zerver/tests/test_message_send.py b/zerver/tests/test_message_send.pyindex 2ea47b57480..73550a859a3 100644--- a/zerver/tests/test_message_send.py+++ b/zerver/tests/test_message_send.py@@ -1930,7 +1930,6 @@ class StreamMessagesTest(ZulipTestCase):client_gravatar=False,allow_empty_topic_name=True,realm=user_profile.realm,- user_recipient_id=None,)self.assertEqual(dct["display_recipient"], "Denmark")diff --git a/zerver/tornado/event_queue.py b/zerver/tornado/event_queue.pyindex cfc2c8339ea..fefe20318c5 100644--- a/zerver/tornado/event_queue.py+++ b/zerver/tornado/event_queue.py@@ -76,7 +76,6 @@ class ClientDescriptor:self,*,user_profile_id: int,- user_recipient_id: int | None,realm_id: int,event_queue: "EventQueue",event_types: Sequence[str] | None,@@ -106,7 +105,6 @@ class ClientDescriptor:# added to load_event_queues() to update the restored objects.# Additionally, the to_dict and from_dict methods must be updatedself.user_profile_id = user_profile_id- self.user_recipient_id = user_recipient_idself.realm_id = realm_idself.current_handler_id: int | None = Noneself.current_client_name: str | None = None@@ -148,7 +146,6 @@ class ClientDescriptor:# loading event queues that lack that key.return dict(user_profile_id=self.user_profile_id,- user_recipient_id=self.user_recipient_id,realm_id=self.realm_id,event_queue=self.event_queue.to_dict(),queue_timeout=self.queue_timeout,@@ -190,7 +187,6 @@ class ClientDescriptor:ret = cls(user_profile_id=d["user_profile_id"],- user_recipient_id=d.get("user_recipient_id"),realm_id=d["realm_id"],event_queue=EventQueue.from_dict(d["event_queue"]),event_types=d["event_types"],@@ -1232,7 +1228,6 @@ def process_message_event(client_gravatar: bool,allow_empty_topic_name: bool,can_access_sender: bool,- is_incoming_1_to_1: bool,) -> dict[str, Any]:return MessageDict.finalize_payload(wide_dict,@@ -1241,7 +1236,6 @@ def process_message_event(allow_empty_topic_name=allow_empty_topic_name,can_access_sender=can_access_sender,realm_host=realm_host,- is_incoming_1_to_1=is_incoming_1_to_1,)# Extra user-specific data to include@@ -1324,7 +1318,6 @@ def process_message_event(client_gravatar=client.client_gravatar,allow_empty_topic_name=client.empty_topic_name,can_access_sender=can_access_sender,- is_incoming_1_to_1=wide_dict["recipient_id"] == client.user_recipient_id,)# Make sure mirroring bots know whether stream is invite-onlydiff --git a/zerver/tornado/views.py b/zerver/tornado/views.pyindex fd649300722..78c040100c6 100644--- a/zerver/tornado/views.py+++ b/zerver/tornado/views.py@@ -239,7 +239,6 @@ def get_events_backend(if queue_id is None:new_queue_data = dict(user_profile_id=user_profile.id,- user_recipient_id=user_profile.recipient_id,realm_id=user_profile.realm_id,event_types=event_types,client_type_name=valid_user_client_name,