summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2014-12-10 21:17:48 +0000
committerPaul "LeoNerd" Evans <paul@matrix.org>2014-12-10 21:17:48 +0000
commit5f49914dee80c7572c549bb17a0099cdad7cdb32 (patch)
tree2b047daf89be7b02dc8931ce4b0cebef6f37d8e7 /synapse
parentHook up the event stream to typing notifications (diff)
downloadsynapse-5f49914dee80c7572c549bb17a0099cdad7cdb32.tar.xz
Avoid cyclic dependency in handler setup
Diffstat (limited to 'synapse')
-rw-r--r--synapse/handlers/typing.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/synapse/handlers/typing.py b/synapse/handlers/typing.py
index 7426bda960..989f73947f 100644
--- a/synapse/handlers/typing.py
+++ b/synapse/handlers/typing.py
@@ -183,10 +183,16 @@ class TypingNotificationHandler(BaseHandler):
 class TypingNotificationEventSource(object):
     def __init__(self, hs):
         self.hs = hs
-        self.handler = hs.get_handlers().typing_notification_handler
+        self._handler = None
+
+    def handler(self):
+        # Avoid cyclic dependency in handler setup
+        if not self._handler:
+            self._handler = self.hs.get_handlers().typing_notification_handler
+        return self._handler
 
     def _make_event_for(self, room_id):
-        typing = self.handler._room_typing[room_id]
+        typing = self.handler()._room_typing[room_id]
         return {
             "type": "m.typing",
             "room_id": room_id,
@@ -195,7 +201,7 @@ class TypingNotificationEventSource(object):
 
     def get_new_events_for_user(self, user, from_key, limit):
         from_key = int(from_key)
-        handler = self.handler
+        handler = self.handler()
 
         events = []
         for room_id in handler._room_serials:
@@ -208,7 +214,7 @@ class TypingNotificationEventSource(object):
         return (events, handler._latest_room_serial)
 
     def get_current_key(self):
-        return self.handler._latest_room_serial
+        return self.handler()._latest_room_serial
 
     def get_pagination_rows(self, user, pagination_config, key):
         return ([], pagination_config.from_key)