From ce5439d87ff0ffba9ac31dc405f5d509a4353a02 Mon Sep 17 00:00:00 2001 From: Mateusz Mandera Date: Tue, 10 Sep 2024 20:02:28 +0200 Subject: [PATCH] retention: Remove outdated compat block for delete_message events. As noted in the comment in that block, this is no longer useful. --- zerver/tests/test_retention.py | 26 -------------------------- zerver/tornado/event_queue.py | 13 +------------ 2 files changed, 1 insertion(+), 38 deletions(-) diff --git a/zerver/tests/test_retention.py b/zerver/tests/test_retention.py index cc19bb6b44..6b7ea8d135 100644 --- a/zerver/tests/test_retention.py +++ b/zerver/tests/test_retention.py @@ -45,7 +45,6 @@ from zerver.models.streams import get_stream from zerver.models.users import get_system_bot # Class with helper functions useful for testing archiving of reactions: -from zerver.tornado.django_api import send_event ZULIP_REALM_DAYS = 30 MIT_REALM_DAYS = 100 @@ -1152,28 +1151,3 @@ class TestDoDeleteMessages(ZulipTestCase): archived_messages = ArchivedMessage.objects.filter(id__in=message_ids) self.assertEqual(archived_messages.count(), len(message_ids)) self.assert_length({message.archive_transaction_id for message in archived_messages}, 1) - - def test_old_event_format_processed_correctly(self) -> None: - """ - do_delete_messages used to send events with users in dict format {"id": }. - We have a block in process_notification to deal with that old format, that should be - deleted in a later release. This test is meant to ensure correctness of that block. - """ - realm = get_realm("zulip") - cordelia = self.example_user("cordelia") - hamlet = self.example_user("hamlet") - message_id = self.send_personal_message(cordelia, hamlet) - message = Message.objects.get(id=message_id) - - event = { - "type": "delete_message", - "sender": message.sender.email, - "sender_id": message.sender_id, - "message_id": message.id, - "message_type": "private", - "recipient_id": message.recipient_id, - } - move_messages_to_archive([message_id]) - # We only send the event to see no exception is thrown - as it would be if the block - # in process_notification to handle this old format of "users to notify" wasn't correct. - send_event(realm, event, [{"id": cordelia.id}, {"id": hamlet.id}]) diff --git a/zerver/tornado/event_queue.py b/zerver/tornado/event_queue.py index 0a2c197a27..9ab0a6e031 100644 --- a/zerver/tornado/event_queue.py +++ b/zerver/tornado/event_queue.py @@ -1572,18 +1572,7 @@ def process_notification(notice: Mapping[str, Any]) -> None: elif event["type"] == "update_message": process_message_update_event(event, cast(list[Mapping[str, Any]], users)) elif event["type"] == "delete_message": - if len(users) > 0 and isinstance(users[0], dict): - # do_delete_messages used to send events with users in - # dict format {"id": } This block is here for - # compatibility with events in that format still in the - # queue at the time of upgrade. - # - # TODO/compatibility: Remove this block once you can no - # longer directly upgrade directly from 4.x to main. - user_ids: list[int] = [user["id"] for user in cast(list[Mapping[str, Any]], users)] - else: - user_ids = cast(list[int], users) - process_deletion_event(event, user_ids) + process_deletion_event(event, cast(list[int], users)) elif event["type"] == "presence": process_presence_event(event, cast(list[int], users)) elif event["type"] == "custom_profile_fields":