diff options
author | Erik Johnston <erik@matrix.org> | 2022-06-06 18:46:11 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-06 16:46:11 +0100 |
commit | 44de53bb79f961147386ea2a8bfbeb54b007cd41 (patch) | |
tree | 69b9b7896e2f69518bebcdd579619099888be9b4 /synapse/handlers | |
parent | Do not break URL previews if an image is unreachable. (#12950) (diff) | |
download | synapse-44de53bb79f961147386ea2a8bfbeb54b007cd41.tar.xz |
Reduce state pulled from DB due to sending typing and receipts over federation (#12964)
Reducing the amount of state we pull from the DB is useful as fetching state is expensive in terms of DB, CPU and memory.
Diffstat (limited to 'synapse/handlers')
-rw-r--r-- | synapse/handlers/typing.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/synapse/handlers/typing.py b/synapse/handlers/typing.py index 0aeab86bbb..d104ea07fe 100644 --- a/synapse/handlers/typing.py +++ b/synapse/handlers/typing.py @@ -59,6 +59,7 @@ class FollowerTypingHandler: def __init__(self, hs: "HomeServer"): self.store = hs.get_datastores().main + self._storage_controllers = hs.get_storage_controllers() self.server_name = hs.config.server.server_name self.clock = hs.get_clock() self.is_mine_id = hs.is_mine_id @@ -131,7 +132,6 @@ class FollowerTypingHandler: return try: - users = await self.store.get_users_in_room(member.room_id) self._member_last_federation_poke[member] = self.clock.time_msec() now = self.clock.time_msec() @@ -139,7 +139,10 @@ class FollowerTypingHandler: now=now, obj=member, then=now + FEDERATION_PING_INTERVAL ) - for domain in {get_domain_from_id(u) for u in users}: + hosts = await self._storage_controllers.state.get_current_hosts_in_room( + member.room_id + ) + for domain in hosts: if domain != self.server_name: logger.debug("sending typing update to %s", domain) self.federation.build_and_send_edu( |