remote_server: Queue deferred work after commit.

This commit is contained in:
Tim Abbott
2023-12-11 13:12:22 -08:00
parent d763fae9d0
commit b9af6c7962
3 changed files with 6 additions and 4 deletions

View File

@@ -21,7 +21,7 @@ from zerver.lib.exceptions import (
RemoteRealmServerMismatchError,
)
from zerver.lib.outgoing_http import OutgoingSession
from zerver.lib.queue import queue_json_publish
from zerver.lib.queue import queue_event_on_commit
from zerver.models import OrgTypeEnum, Realm, RealmAuditLog
@@ -411,4 +411,4 @@ def enqueue_register_realm_with_push_bouncer_if_needed(realm: Realm) -> None:
# We do this in a queue worker to avoid messing with the realm
# creation process due to network issues or latency.
event = {"type": "register_realm_with_push_bouncer", "realm_id": realm.id}
queue_json_publish("deferred_work", event)
queue_event_on_commit("deferred_work", event)

View File

@@ -1413,6 +1413,7 @@ class RealmImportExportTest(ExportFile):
m.side_effect = mock_send_to_push_bouncer_response
with self.captureOnCommitCallbacks(execute=True):
new_realm = do_import_realm(get_output_dir(), "test-zulip")
self.assertTrue(Realm.objects.filter(string_id="test-zulip").exists())

View File

@@ -1103,6 +1103,7 @@ class RealmTest(ZulipTestCase):
m.side_effect = mock_send_to_push_bouncer_response
with self.captureOnCommitCallbacks(execute=True):
realm = do_create_realm("realm_string_id", "realm name")
self.assertEqual(realm.string_id, "realm_string_id")