diff options
author | Andrew Morgan <andrew@amorgan.xyz> | 2021-03-18 13:15:43 +0000 |
---|---|---|
committer | Andrew Morgan <andrew@amorgan.xyz> | 2021-03-18 16:35:21 +0000 |
commit | 2d656e7b7fc1a6eaf6be40ae3367314d59fdd854 (patch) | |
tree | 02b5b77bc486a3569e4790efc3101dbf36b4e21d | |
parent | Update PresenceHandler to call PresenceRouter methods when applicable (diff) | |
download | synapse-2d656e7b7fc1a6eaf6be40ae3367314d59fdd854.tar.xz |
Update method calls to thread presence_router through to presence handler
-rw-r--r-- | synapse/app/generic_worker.py | 3 | ||||
-rw-r--r-- | synapse/federation/sender/__init__.py | 12 |
2 files changed, 11 insertions, 4 deletions
diff --git a/synapse/app/generic_worker.py b/synapse/app/generic_worker.py index 274d582d07..cbe91e7b70 100644 --- a/synapse/app/generic_worker.py +++ b/synapse/app/generic_worker.py @@ -282,6 +282,7 @@ class GenericWorkerPresence(BasePresenceHandler): self.hs = hs self.is_mine_id = hs.is_mine_id + self.presence_router = hs.get_presence_router() self._presence_enabled = hs.config.use_presence # The number of ongoing syncs on this process, by user id. @@ -394,7 +395,7 @@ class GenericWorkerPresence(BasePresenceHandler): return _user_syncing() async def notify_from_replication(self, states, stream_id): - parties = await get_interested_parties(self.store, states) + parties = await get_interested_parties(self.store, self.presence_router, states) room_ids_to_states, users_to_states = parties self.notifier.on_new_event( diff --git a/synapse/federation/sender/__init__.py b/synapse/federation/sender/__init__.py index 24ebc4b803..e5dc98ee5d 100644 --- a/synapse/federation/sender/__init__.py +++ b/synapse/federation/sender/__init__.py @@ -14,7 +14,7 @@ # limitations under the License. import logging -from typing import Dict, Hashable, Iterable, List, Optional, Set, Tuple +from typing import TYPE_CHECKING, Dict, Hashable, Iterable, List, Optional, Set, Tuple from prometheus_client import Counter @@ -43,6 +43,9 @@ from synapse.metrics.background_process_metrics import run_as_background_process from synapse.types import ReadReceipt, RoomStreamToken from synapse.util.metrics import Measure, measure_func +if TYPE_CHECKING: + from synapse.server import HomeServer + logger = logging.getLogger(__name__) sent_pdus_destination_dist_count = Counter( @@ -66,7 +69,7 @@ CATCH_UP_STARTUP_INTERVAL_SEC = 5 class FederationSender: - def __init__(self, hs: "synapse.server.HomeServer"): + def __init__(self, hs: "HomeServer"): self.hs = hs self.server_name = hs.hostname @@ -76,6 +79,7 @@ class FederationSender: self.clock = hs.get_clock() self.is_mine_id = hs.is_mine_id + self._presence_router = hs.get_presence_router() self._transaction_manager = TransactionManager(hs) self._instance_name = hs.get_instance_name() @@ -498,7 +502,9 @@ class FederationSender: """Given a list of states populate self.pending_presence_by_dest and poke to send a new transaction to each destination """ - hosts_and_states = await get_interested_remotes(self.store, states, self.state) + hosts_and_states = await get_interested_remotes( + self.store, self._presence_router, states, self.state + ) for destinations, states in hosts_and_states: for destination in destinations: |