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(
|