summary refs log tree commit diff
path: root/synapse/server.py
diff options
context:
space:
mode:
authorPatrick Cloke <clokep@users.noreply.github.com>2021-03-17 11:30:21 -0400
committerGitHub <noreply@github.com>2021-03-17 11:30:21 -0400
commitcc324d53fe531d002aca28a9d8e5b85768cdef23 (patch)
tree449f90ba69043a2d732531ed3937183a7901cb6a /synapse/server.py
parentonly save remote cross-signing keys if they're different from the current one... (diff)
downloadsynapse-cc324d53fe531d002aca28a9d8e5b85768cdef23.tar.xz
Fix up types for the typing handler. (#9638)
By splitting this to two separate methods the callers know
what methods they can expect on the handler.
Diffstat (limited to '')
-rw-r--r--synapse/server.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/synapse/server.py b/synapse/server.py
index dd4ee7dd3c..d11d08c573 100644
--- a/synapse/server.py
+++ b/synapse/server.py
@@ -417,10 +417,19 @@ class HomeServer(metaclass=abc.ABCMeta):
         return PresenceHandler(self)
 
     @cache_in_self
-    def get_typing_handler(self):
+    def get_typing_writer_handler(self) -> TypingWriterHandler:
         if self.config.worker.writers.typing == self.get_instance_name():
             return TypingWriterHandler(self)
         else:
+            raise Exception("Workers cannot write typing")
+
+    @cache_in_self
+    def get_typing_handler(self) -> FollowerTypingHandler:
+        if self.config.worker.writers.typing == self.get_instance_name():
+            # Use get_typing_writer_handler to ensure that we use the same
+            # cached version.
+            return self.get_typing_writer_handler()
+        else:
             return FollowerTypingHandler(self)
 
     @cache_in_self