Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

compatiblity: Delete obsolete compatibility code.

Tim Abbott8010d06f9ea3
diff --git a/zerver/tests/test_queue_worker.py b/zerver/tests/test_queue_worker.py
index 1d1e9bbc8d9..88bf7ab0a85 100644
--- a/zerver/tests/test_queue_worker.py
+++ b/zerver/tests/test_queue_worker.py
@@ -96,29 +96,6 @@ class WorkerTest(ZulipTestCase):
)
fake_client.enqueue("user_activity", data)
- # The block below adds an event using the old format,
- # having the client name instead of id, to test the queue
- # worker handles it correctly. That compatibility code can
- # be deleted in a later release, and this test should then be cleaned up.
- data_old_format = dict(
- user_profile_id=user.id,
- client="ios",
- time=time.time(),
- query="send_message",
- )
- fake_client.enqueue("user_activity", data_old_format)
-
- with simulated_queue_client(fake_client):
- worker = queue_processors.UserActivityWorker()
- worker.setup()
- worker.start()
- activity_records = UserActivity.objects.filter(
- user_profile=user.id,
- client=get_client("ios"),
- )
- self.assert_length(activity_records, 1)
- self.assertEqual(activity_records[0].count, 2)
-
# Now process the event a second time and confirm count goes
# up. Ideally, we'd use an event with a slightly newer
# time, but it's not really important.
@@ -132,7 +109,7 @@ class WorkerTest(ZulipTestCase):
client=get_client("ios"),
)
self.assert_length(activity_records, 1)
- self.assertEqual(activity_records[0].count, 3)
+ self.assertEqual(activity_records[0].count, 2)
def test_missed_message_worker(self) -> None:
cordelia = self.example_user("cordelia")
@@ -455,23 +432,6 @@ class WorkerTest(ZulipTestCase):
* 2,
)
- # This verifies the compatibility code for the `message_id` -> `message_ids`
- # conversion for "remove" events.
- with patch(
- "zerver.worker.queue_processors.handle_remove_push_notification"
- ) as mock_handle_remove, patch(
- "zerver.worker.queue_processors.initialize_push_notifications"
- ):
- event_new = dict(
- user_profile_id=10,
- message_id=33,
- type="remove",
- )
- fake_client.enqueue("missedmessage_mobile_notifications", event_new)
- worker.start()
- # The `message_id` field should have been converted to a list with a single element.
- mock_handle_remove.assert_called_once_with(10, [33])
-
@patch("zerver.worker.queue_processors.mirror_email")
def test_mirror_worker(self, mock_mirror_email: MagicMock) -> None:
fake_client = FakeClient()
diff --git a/zerver/worker/queue_processors.py b/zerver/worker/queue_processors.py
index 9b0caa72e51..48d278102c0 100644
--- a/zerver/worker/queue_processors.py
+++ b/zerver/worker/queue_processors.py
@@ -523,20 +523,7 @@ class UserActivityWorker(LoopQueueProcessingWorker):
# deduplicate them for insertion into the database.
for event in user_activity_events:
user_profile_id = event["user_profile_id"]
-
- if "client_id" not in event:
- # This is for compatibility with older events still stuck in the queue,
- # that used the client name in event["client"] instead of having
- # event["client_id"] directly.
- #
- # TODO/compatibility: We can delete this once it is no
- # longer possible to directly upgrade from 2.1 to main.
- if event["client"] not in self.client_id_map:
- client = get_client(event["client"])
- self.client_id_map[event["client"]] = client.id
- client_id = self.client_id_map[event["client"]]
- else:
- client_id = event["client_id"]
+ client_id = event["client_id"]
key_tuple = (user_profile_id, client_id, event["query"])
if key_tuple not in uncommitted_events:
@@ -779,15 +766,7 @@ class PushNotificationsWorker(QueueProcessingWorker):
def consume(self, event: Dict[str, Any]) -> None:
try:
if event.get("type", "add") == "remove":
- message_ids = event.get("message_ids")
- if message_ids is None:
- # TODO/compatibility: Previously, we sent only one `message_id` in
- # a payload for notification remove events. This was later changed
- # to send a list of `message_ids` (with that field name), but we need
- # compatibility code for events present in the queue during upgrade.
- # Remove this when one can no longer upgrade from 1.9.2 (or earlier)
- # to any version after 2.0.0
- message_ids = [event["message_id"]]
+ message_ids = event["message_ids"]
handle_remove_push_notification(event["user_profile_id"], message_ids)
else:
handle_push_notification(event["user_profile_id"], event)