summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2021-04-15 14:13:45 +0100
committerErik Johnston <erik@matrix.org>2021-04-15 14:13:45 +0100
commit68b9eb694f0896f11f0699a7e01bd7fb9210dba4 (patch)
tree3e05430849bf3bb4fb9bb4e7843da6a7ac63c7b5 /synapse
parentRemove the federation replication stream and associated commands (diff)
downloadsynapse-erikj/remove_send_queue.tar.xz
Tidy up hs.get_federation_sender() calls github/erikj/remove_send_queue erikj/remove_send_queue
Diffstat (limited to 'synapse')
-rw-r--r--synapse/handlers/device.py2
-rw-r--r--synapse/handlers/devicemessage.py4
-rw-r--r--synapse/handlers/presence.py14
-rw-r--r--synapse/handlers/receipts.py4
-rw-r--r--synapse/handlers/typing.py4
-rw-r--r--synapse/module_api/__init__.py4
-rw-r--r--synapse/notifier.py4
7 files changed, 10 insertions, 26 deletions
diff --git a/synapse/handlers/device.py b/synapse/handlers/device.py
index d75edb184b..bac7f26a06 100644
--- a/synapse/handlers/device.py
+++ b/synapse/handlers/device.py
@@ -484,7 +484,7 @@ class DeviceHandler(DeviceWorkerHandler):
             "device_list_key", position, users=[user_id], rooms=room_ids
         )
 
-        if hosts:
+        if hosts and self.federation_sender:
             logger.info(
                 "Sending device list update notif for %r to: %r", user_id, hosts
             )
diff --git a/synapse/handlers/devicemessage.py b/synapse/handlers/devicemessage.py
index c5d631de07..638c9f8b5f 100644
--- a/synapse/handlers/devicemessage.py
+++ b/synapse/handlers/devicemessage.py
@@ -51,9 +51,7 @@ class DeviceMessageHandler:
         # same instance. Other federation sender instances will get notified by
         # `synapse.app.generic_worker.FederationSenderHandler` when it sees it
         # in the to-device replication stream.
-        self.federation_sender = None
-        if hs.should_send_federation():
-            self.federation_sender = hs.get_federation_sender()
+        self.federation_sender = hs.get_federation_sender()
 
         # If we can handle the to device EDUs we do so, otherwise we route them
         # to the appropriate worker.
diff --git a/synapse/handlers/presence.py b/synapse/handlers/presence.py
index 1255ceca55..8b1d8c5ad6 100644
--- a/synapse/handlers/presence.py
+++ b/synapse/handlers/presence.py
@@ -287,9 +287,7 @@ class WorkerPresenceHandler(BasePresenceHandler):
         self.notifier = hs.get_notifier()
         self.instance_id = hs.get_instance_id()
 
-        self._federation = None
-        if hs.should_send_federation():
-            self._federation = hs.get_federation_sender()
+        self._federation = hs.get_federation_sender()
 
         # user_id -> last_sync_ms. Lists the users that have stopped syncing
         # but we haven't notified the master of that yet
@@ -506,9 +504,7 @@ class PresenceHandler(BasePresenceHandler):
         self.presence_router = hs.get_presence_router()
         self._presence_enabled = hs.config.use_presence
 
-        self.federation_sender = None
-        if hs.should_send_federation():
-            self.federation_sender = hs.get_federation_sender()
+        self.federation_sender = hs.get_federation_sender()
 
         federation_registry = hs.get_federation_registry()
 
@@ -1900,11 +1896,9 @@ class PresenceFederationQueue:
         self._queue_presence_updates = True
 
         # The federation sender if this instance is a federation sender.
-        self._federation = None
-
-        if hs.should_send_federation():
-            self._federation = hs.get_federation_sender()
+        self._federation = hs.get_federation_sender()
 
+        if self._federation:
             # We don't bother queuing up presence states if only this instance
             # is sending federation.
             if hs.config.worker.federation_shard_config.instances == [
diff --git a/synapse/handlers/receipts.py b/synapse/handlers/receipts.py
index f782d9db32..8e1ea8308e 100644
--- a/synapse/handlers/receipts.py
+++ b/synapse/handlers/receipts.py
@@ -36,9 +36,7 @@ class ReceiptsHandler(BaseHandler):
         # same instance. Other federation sender instances will get notified by
         # `synapse.app.generic_worker.FederationSenderHandler` when it sees it
         # in the receipts stream.
-        self.federation_sender = None
-        if hs.should_send_federation():
-            self.federation_sender = hs.get_federation_sender()
+        self.federation_sender = hs.get_federation_sender()
 
         # If we can handle the receipt EDUs we do so, otherwise we route them
         # to the appropriate worker.
diff --git a/synapse/handlers/typing.py b/synapse/handlers/typing.py
index e22393adc4..c5b0e5707e 100644
--- a/synapse/handlers/typing.py
+++ b/synapse/handlers/typing.py
@@ -57,9 +57,7 @@ class FollowerTypingHandler:
         self.clock = hs.get_clock()
         self.is_mine_id = hs.is_mine_id
 
-        self.federation = None
-        if hs.should_send_federation():
-            self.federation = hs.get_federation_sender()
+        self.federation = hs.get_federation_sender()
 
         if hs.config.worker.writers.typing != hs.get_instance_name():
             hs.get_federation_registry().register_instance_for_edu(
diff --git a/synapse/module_api/__init__.py b/synapse/module_api/__init__.py
index 90a40cd16b..94c25c87c5 100644
--- a/synapse/module_api/__init__.py
+++ b/synapse/module_api/__init__.py
@@ -54,9 +54,7 @@ class ModuleApi:
         self._state = hs.get_state_handler()
         self._presence_router = hs.get_presence_router()
 
-        self._federation = None
-        if hs.should_send_federation():
-            self._federation = self._hs.get_federation_sender()
+        self._federation = self._hs.get_federation_sender()
 
         # We expose these as properties below in order to attach a helpful docstring.
         self._http_client = hs.get_simple_http_client()  # type: SimpleHttpClient
diff --git a/synapse/notifier.py b/synapse/notifier.py
index d5ab77058d..782b6729fa 100644
--- a/synapse/notifier.py
+++ b/synapse/notifier.py
@@ -227,9 +227,7 @@ class Notifier:
         self.appservice_handler = hs.get_application_service_handler()
         self._pusher_pool = hs.get_pusherpool()
 
-        self.federation_sender = None
-        if hs.should_send_federation():
-            self.federation_sender = hs.get_federation_sender()
+        self.federation_sender = hs.get_federation_sender()
 
         self.state_handler = hs.get_state_handler()