queue: Rename queue_json_publish to queue_json_publish_rollback_unsafe.

This commit renames the 'queue_json_publish' function to
'queue_json_publish_rollback_unsafe' to reflect the fact that it doesn't
wait for the db transaction (within which it gets called, if any)
to commit and sends event irrespective of commit or rollback.

In most of the cases we don't want to send event in the case of
rollbacks, so the caller should be aware that calling the function
directly is rollback unsafe.

Fixes part of #30489.
This commit is contained in:
Prakhar Pratyush
2024-12-06 12:14:03 +05:30
committed by Tim Abbott
parent 1847086044
commit 3bad36ef8c
24 changed files with 63 additions and 53 deletions

View File

@@ -41,13 +41,13 @@ class MaybeEnqueueNotificationsTest(ZulipTestCase):
)
with mock_queue_publish(
"zerver.tornado.event_queue.queue_json_publish"
"zerver.tornado.event_queue.queue_json_publish_rollback_unsafe"
) as mock_queue_json_publish:
notified = maybe_enqueue_notifications(**params)
mock_queue_json_publish.assert_not_called()
with mock_queue_publish(
"zerver.tornado.event_queue.queue_json_publish"
"zerver.tornado.event_queue.queue_json_publish_rollback_unsafe"
) as mock_queue_json_publish:
params["user_notifications_data"] = self.create_user_notifications_data_object(
user_id=1, dm_push_notify=True, dm_email_notify=True
@@ -63,7 +63,7 @@ class MaybeEnqueueNotificationsTest(ZulipTestCase):
self.assertTrue(notified["push_notified"])
with mock_queue_publish(
"zerver.tornado.event_queue.queue_json_publish"
"zerver.tornado.event_queue.queue_json_publish_rollback_unsafe"
) as mock_queue_json_publish:
params = self.get_maybe_enqueue_notifications_parameters(
message_id=1,