From 6ce096c0ff8e68c7d910a99edb68172d57657230 Mon Sep 17 00:00:00 2001 From: Mateusz Mandera Date: Tue, 10 Sep 2024 20:45:21 +0200 Subject: [PATCH] zerver: Rename some message_type variables to recipient_type. --- zerver/actions/message_send.py | 4 ++-- zerver/migrations/0377_message_edit_history_format.py | 6 +++--- zerver/tests/test_service_bot_system.py | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/zerver/actions/message_send.py b/zerver/actions/message_send.py index 14422b6919..f521af32aa 100644 --- a/zerver/actions/message_send.py +++ b/zerver/actions/message_send.py @@ -1082,12 +1082,12 @@ def do_send_messages( users.append(user_data) sender = send_request.message.sender - message_type = wide_message_dict["type"] + recipient_type = wide_message_dict["type"] user_notifications_data_list = [ UserMessageNotificationsData.from_user_id_sets( user_id=user_id, flags=user_flags.get(user_id, []), - private_message=message_type == "private", + private_message=recipient_type == "private", disable_external_notifications=send_request.disable_external_notifications, online_push_user_ids=send_request.online_push_user_ids, dm_mention_push_disabled_user_ids=send_request.dm_mention_push_disabled_user_ids, diff --git a/zerver/migrations/0377_message_edit_history_format.py b/zerver/migrations/0377_message_edit_history_format.py index 14bc6be2a2..703cf4d83a 100644 --- a/zerver/migrations/0377_message_edit_history_format.py +++ b/zerver/migrations/0377_message_edit_history_format.py @@ -62,11 +62,11 @@ def backfill_message_edit_history_chunk( for message in messages: legacy_edit_history: list[LegacyEditHistoryEvent] = orjson.loads(message.edit_history) - message_type = message.recipient.type + recipient_type = message.recipient.type modern_edit_history: list[EditHistoryEvent] = [] # Only Stream messages have topic / stream edit history data. - if message_type == STREAM: + if recipient_type == STREAM: topic = message.subject stream_id = message.recipient.type_id @@ -83,7 +83,7 @@ def backfill_message_edit_history_chunk( "prev_rendered_content_version" ] - if message_type == STREAM: + if recipient_type == STREAM: if "prev_subject" in edit_history_event: # Add topic edit key/value pairs from legacy format. modern_entry["topic"] = topic diff --git a/zerver/tests/test_service_bot_system.py b/zerver/tests/test_service_bot_system.py index bf701f4344..32115026a1 100644 --- a/zerver/tests/test_service_bot_system.py +++ b/zerver/tests/test_service_bot_system.py @@ -488,7 +488,7 @@ class TestServiceBotEventTriggers(ZulipTestCase): content = "@**FooBot** foo bar!!!" recipient = "Denmark" trigger = "mention" - message_type = Recipient._type_names[Recipient.STREAM] + recipient_type = Recipient._type_names[Recipient.STREAM] def check_values_passed( queue_name: Any, @@ -500,7 +500,7 @@ class TestServiceBotEventTriggers(ZulipTestCase): self.assertEqual(trigger_event["message"]["content"], content) self.assertEqual(trigger_event["message"]["display_recipient"], recipient) self.assertEqual(trigger_event["message"]["sender_email"], self.user_profile.email) - self.assertEqual(trigger_event["message"]["type"], message_type) + self.assertEqual(trigger_event["message"]["type"], recipient_type) self.assertEqual(trigger_event["trigger"], trigger) self.assertEqual(trigger_event["user_profile_id"], self.bot_profile.id)