summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2014-12-10 21:01:49 +0000
committerPaul "LeoNerd" Evans <paul@matrix.org>2014-12-10 21:01:49 +0000
commit1a75ff5c23e4d85714927f995e185ddf2d7eaff8 (patch)
treec50b4ef6d06afa51a96229ebe5195716a64051a5 /synapse
parentStore serial numbers per room for typing event stream purposes (diff)
downloadsynapse-1a75ff5c23e4d85714927f995e185ddf2d7eaff8.tar.xz
Hook up the event stream to typing notifications
Diffstat (limited to 'synapse')
-rw-r--r--synapse/handlers/typing.py24
1 files changed, 22 insertions, 2 deletions
diff --git a/synapse/handlers/typing.py b/synapse/handlers/typing.py
index 2370ff7134..7426bda960 100644
--- a/synapse/handlers/typing.py
+++ b/synapse/handlers/typing.py
@@ -183,12 +183,32 @@ class TypingNotificationHandler(BaseHandler):
 class TypingNotificationEventSource(object):
     def __init__(self, hs):
         self.hs = hs
+        self.handler = hs.get_handlers().typing_notification_handler
+
+    def _make_event_for(self, room_id):
+        typing = self.handler._room_typing[room_id]
+        return {
+            "type": "m.typing",
+            "room_id": room_id,
+            "typing": [u.to_string() for u in typing],
+        }
 
     def get_new_events_for_user(self, user, from_key, limit):
-        return ([], from_key)
+        from_key = int(from_key)
+        handler = self.handler
+
+        events = []
+        for room_id in handler._room_serials:
+            if handler._room_serials[room_id] <= from_key:
+                continue
+
+            # TODO: check if user is in room
+            events.append(self._make_event_for(room_id))
+
+        return (events, handler._latest_room_serial)
 
     def get_current_key(self):
-        return 0
+        return self.handler._latest_room_serial
 
     def get_pagination_rows(self, user, pagination_config, key):
         return ([], pagination_config.from_key)