Skip to content

Commit ce5439d

Browse files
mateuszmanderatimabbott
authored andcommitted
retention: Remove outdated compat block for delete_message events.
As noted in the comment in that block, this is no longer useful.
1 parent bc38409 commit ce5439d

File tree

2 files changed

+1
-38
lines changed

2 files changed

+1
-38
lines changed

zerver/tests/test_retention.py

-26
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
from zerver.models.users import get_system_bot
4646

4747
# Class with helper functions useful for testing archiving of reactions:
48-
from zerver.tornado.django_api import send_event
4948

5049
ZULIP_REALM_DAYS = 30
5150
MIT_REALM_DAYS = 100
@@ -1152,28 +1151,3 @@ def test_do_delete_messages_multiple(self) -> None:
11521151
archived_messages = ArchivedMessage.objects.filter(id__in=message_ids)
11531152
self.assertEqual(archived_messages.count(), len(message_ids))
11541153
self.assert_length({message.archive_transaction_id for message in archived_messages}, 1)
1155-
1156-
def test_old_event_format_processed_correctly(self) -> None:
1157-
"""
1158-
do_delete_messages used to send events with users in dict format {"id": <int>}.
1159-
We have a block in process_notification to deal with that old format, that should be
1160-
deleted in a later release. This test is meant to ensure correctness of that block.
1161-
"""
1162-
realm = get_realm("zulip")
1163-
cordelia = self.example_user("cordelia")
1164-
hamlet = self.example_user("hamlet")
1165-
message_id = self.send_personal_message(cordelia, hamlet)
1166-
message = Message.objects.get(id=message_id)
1167-
1168-
event = {
1169-
"type": "delete_message",
1170-
"sender": message.sender.email,
1171-
"sender_id": message.sender_id,
1172-
"message_id": message.id,
1173-
"message_type": "private",
1174-
"recipient_id": message.recipient_id,
1175-
}
1176-
move_messages_to_archive([message_id])
1177-
# We only send the event to see no exception is thrown - as it would be if the block
1178-
# in process_notification to handle this old format of "users to notify" wasn't correct.
1179-
send_event(realm, event, [{"id": cordelia.id}, {"id": hamlet.id}])

zerver/tornado/event_queue.py

+1-12
Original file line numberDiff line numberDiff line change
@@ -1572,18 +1572,7 @@ def process_notification(notice: Mapping[str, Any]) -> None:
15721572
elif event["type"] == "update_message":
15731573
process_message_update_event(event, cast(list[Mapping[str, Any]], users))
15741574
elif event["type"] == "delete_message":
1575-
if len(users) > 0 and isinstance(users[0], dict):
1576-
# do_delete_messages used to send events with users in
1577-
# dict format {"id": <int>} This block is here for
1578-
# compatibility with events in that format still in the
1579-
# queue at the time of upgrade.
1580-
#
1581-
# TODO/compatibility: Remove this block once you can no
1582-
# longer directly upgrade directly from 4.x to main.
1583-
user_ids: list[int] = [user["id"] for user in cast(list[Mapping[str, Any]], users)]
1584-
else:
1585-
user_ids = cast(list[int], users)
1586-
process_deletion_event(event, user_ids)
1575+
process_deletion_event(event, cast(list[int], users))
15871576
elif event["type"] == "presence":
15881577
process_presence_event(event, cast(list[int], users))
15891578
elif event["type"] == "custom_profile_fields":

0 commit comments

Comments
 (0)