From 5c1a5a816feccbf849a30b9c4295ea393d306b4f Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Sun, 10 Dec 2023 20:18:13 -0800 Subject: [PATCH] remote_server: Rename register_realm_with_push_bouncer. We plan to have this potentially happen more than once for a given realm. --- zerver/lib/remote_server.py | 11 +++++++---- zerver/worker/queue_processors.py | 6 ++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/zerver/lib/remote_server.py b/zerver/lib/remote_server.py index b826cbd21c..32e57f526f 100644 --- a/zerver/lib/remote_server.py +++ b/zerver/lib/remote_server.py @@ -404,11 +404,14 @@ def send_analytics_to_push_bouncer(consider_usage_statistics: bool = True) -> No def maybe_enqueue_audit_log_upload(realm: Realm) -> None: + # Update the push notifications service, either with the fact that + # the realm now exists or updates to its audit log of users. + # + # Done via a queue worker so that networking failures cannot have + # any impact on the success operation of the local server's + # ability to do operations that trigger these updates. from zerver.lib.push_notifications import uses_notification_bouncer if uses_notification_bouncer(): - # Let the bouncer know about the new realm. - # 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} + event = {"type": "push_bouncer_update_for_realm", "realm_id": realm.id} queue_event_on_commit("deferred_work", event) diff --git a/zerver/worker/queue_processors.py b/zerver/worker/queue_processors.py index dd7669b9a9..1fe0e3776c 100644 --- a/zerver/worker/queue_processors.py +++ b/zerver/worker/queue_processors.py @@ -1170,12 +1170,10 @@ class DeferredWorker(QueueProcessingWorker): ) user_profile = get_user_profile_by_id(event["user_profile_id"]) reactivate_user_if_soft_deactivated(user_profile) - elif event["type"] == "register_realm_with_push_bouncer": + elif event["type"] == "push_bouncer_update_for_realm": # In the future we may use the realm_id to send only that single realm's info. realm_id = event["realm_id"] - logger.info( - "Running send_analytics_to_push_bouncer, requested due to realm %s", realm_id - ) + logger.info("Updating push bouncer with metadata on behalf of realm %s", realm_id) send_analytics_to_push_bouncer(consider_usage_statistics=False) end = time.time()