mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
message_edit: Update check_message_update to use queue_event_on_commit.
Earlier, we were using 'queue_json_publish' in 'check_message_update' which can lead to a situation where we enqueue event but the transaction fails at a later stage. Events should not be sent until we know we're not rolling back.
This commit is contained in:
committed by
Tim Abbott
parent
74f7488009
commit
ebf1438640
@@ -44,7 +44,7 @@ from zerver.lib.message import (
|
||||
truncate_topic,
|
||||
)
|
||||
from zerver.lib.message_cache import update_message_cache
|
||||
from zerver.lib.queue import queue_json_publish
|
||||
from zerver.lib.queue import queue_event_on_commit
|
||||
from zerver.lib.stream_subscription import get_active_subscriptions_for_stream_id
|
||||
from zerver.lib.stream_topic import StreamTopicTarget
|
||||
from zerver.lib.streams import (
|
||||
@@ -1402,7 +1402,7 @@ def check_update_message(
|
||||
"message_realm_id": user_profile.realm_id,
|
||||
"urls": list(links_for_embed),
|
||||
}
|
||||
queue_json_publish("embed_links", event_data)
|
||||
queue_event_on_commit("embed_links", event_data)
|
||||
|
||||
# Update stream active status after we have successfully moved the
|
||||
# messages. We only update the new stream here and let the daily
|
||||
|
@@ -348,7 +348,7 @@ class PreviewTestCase(ZulipTestCase):
|
||||
url = "http://test.org/"
|
||||
self.create_mock_response(url)
|
||||
|
||||
with mock_queue_publish("zerver.actions.message_edit.queue_json_publish") as patched:
|
||||
with mock_queue_publish("zerver.actions.message_edit.queue_event_on_commit") as patched:
|
||||
result = self.client_patch(
|
||||
"/json/messages/" + str(msg_id),
|
||||
{
|
||||
@@ -434,7 +434,7 @@ class PreviewTestCase(ZulipTestCase):
|
||||
self.assertEqual(queue, "embed_links")
|
||||
event = patched.call_args[0][1]
|
||||
|
||||
def wrapped_queue_json_publish(*args: Any, **kwargs: Any) -> None:
|
||||
def wrapped_queue_event_on_commit(*args: Any, **kwargs: Any) -> None:
|
||||
self.create_mock_response(original_url)
|
||||
self.create_mock_response(edited_url)
|
||||
|
||||
@@ -472,7 +472,7 @@ class PreviewTestCase(ZulipTestCase):
|
||||
)
|
||||
|
||||
with mock_queue_publish(
|
||||
"zerver.actions.message_edit.queue_json_publish", wraps=wrapped_queue_json_publish
|
||||
"zerver.actions.message_edit.queue_event_on_commit", wraps=wrapped_queue_event_on_commit
|
||||
):
|
||||
result = self.client_patch(
|
||||
"/json/messages/" + str(msg_id),
|
||||
|
Reference in New Issue
Block a user