summary refs log tree commit diff
path: root/synapse/handlers/typing.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2020-10-27 15:32:19 +0000
committerGitHub <noreply@github.com>2020-10-27 15:32:19 +0000
commit0c7f9cb81fbfa4922f0c7b935374322a7fda4bee (patch)
treed483e4e94d565cf53af933eb29ceb0ddc002edd3 /synapse/handlers/typing.py
parentAdd admin API to list users' local media (#8647) (diff)
downloadsynapse-0c7f9cb81fbfa4922f0c7b935374322a7fda4bee.tar.xz
Don't unnecessarily start bg process while handling typing. (#8668)
There's no point starting a background process when all its going to do is bail if federation isn't enabled.
Diffstat (limited to 'synapse/handlers/typing.py')
-rw-r--r--synapse/handlers/typing.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/synapse/handlers/typing.py b/synapse/handlers/typing.py
index 8758066c74..e919a8f9ed 100644
--- a/synapse/handlers/typing.py
+++ b/synapse/handlers/typing.py
@@ -167,20 +167,25 @@ class FollowerTypingHandler:
             now_typing = set(row.user_ids)
             self._room_typing[row.room_id] = row.user_ids
 
-            run_as_background_process(
-                "_handle_change_in_typing",
-                self._handle_change_in_typing,
-                row.room_id,
-                prev_typing,
-                now_typing,
-            )
+            if self.federation:
+                run_as_background_process(
+                    "_send_changes_in_typing_to_remotes",
+                    self._send_changes_in_typing_to_remotes,
+                    row.room_id,
+                    prev_typing,
+                    now_typing,
+                )
 
-    async def _handle_change_in_typing(
+    async def _send_changes_in_typing_to_remotes(
         self, room_id: str, prev_typing: Set[str], now_typing: Set[str]
     ):
         """Process a change in typing of a room from replication, sending EDUs
         for any local users.
         """
+
+        if not self.federation:
+            return
+
         for user_id in now_typing - prev_typing:
             if self.is_mine_id(user_id):
                 await self._push_remote(RoomMember(room_id, user_id), True)