summary refs log tree commit diff
path: root/synapse/handlers/sync.py
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-12-22 11:59:55 +0000
committerMark Haines <mark.haines@matrix.org>2015-12-22 11:59:55 +0000
commitcdd04f70556c4f098b6975d07e2685b88aac8bf9 (patch)
treefaf4ff52435313c629f9956cdc07c6a76ebb1cec /synapse/handlers/sync.py
parentMerge branch 'develop' into markjh/guest_access (diff)
downloadsynapse-cdd04f70556c4f098b6975d07e2685b88aac8bf9.tar.xz
Hook up read receipts and typing notifications for guest access
Diffstat (limited to '')
-rw-r--r--synapse/handlers/sync.py24
1 files changed, 11 insertions, 13 deletions
diff --git a/synapse/handlers/sync.py b/synapse/handlers/sync.py
index 9c8ea2bbb2..4753166a0c 100644
--- a/synapse/handlers/sync.py
+++ b/synapse/handlers/sync.py
@@ -203,14 +203,7 @@ class SyncHandler(BaseHandler):
             account_data_by_room = {}
             tags_by_room = {}
 
-            # TODO: Hook up read receipts
-            ephemeral_by_room = {}
-
         else:
-            now_token, ephemeral_by_room = yield self.ephemeral_by_room(
-                sync_config, now_token
-            )
-
             membership_list = (Membership.INVITE, Membership.JOIN)
             if sync_config.filter.include_leave:
                 membership_list += (Membership.LEAVE, Membership.BAN)
@@ -244,6 +237,10 @@ class SyncHandler(BaseHandler):
             is_guest=sync_config.is_guest,
         )
 
+        now_token, ephemeral_by_room = yield self.ephemeral_by_room(
+            sync_config, now_token, joined_room_ids
+        )
+
         joined = []
         invited = []
         archived = []
@@ -352,11 +349,13 @@ class SyncHandler(BaseHandler):
         return account_data_events
 
     @defer.inlineCallbacks
-    def ephemeral_by_room(self, sync_config, now_token, since_token=None):
+    def ephemeral_by_room(self, sync_config, now_token, room_ids,
+                          since_token=None):
         """Get the ephemeral events for each room the user is in
         Args:
             sync_config (SyncConfig): The flags, filters and user for the sync.
             now_token (StreamToken): Where the server is currently up to.
+            room_ids (list): List of room id strings to get data for.
             since_token (StreamToken): Where the server was when the client
                 last synced.
         Returns:
@@ -367,9 +366,6 @@ class SyncHandler(BaseHandler):
 
         typing_key = since_token.typing_key if since_token else "0"
 
-        rooms = yield self.store.get_rooms_for_user(sync_config.user.to_string())
-        room_ids = [room.room_id for room in rooms]
-
         typing_source = self.event_sources.sources["typing"]
         typing, typing_key = yield typing_source.get_new_events(
             user=sync_config.user,
@@ -450,8 +446,6 @@ class SyncHandler(BaseHandler):
         if sync_config.is_guest:
             room_ids = sync_config.filter.list_rooms()
 
-            ephemeral_by_room = {}
-
             tags_by_room = {}
             account_data = {}
             account_data_by_room = {}
@@ -478,6 +472,10 @@ class SyncHandler(BaseHandler):
                 )
             )
 
+        now_token, ephemeral_by_room = yield self.ephemeral_by_room(
+            sync_config, now_token, room_ids, since_token
+        )
+
         presence_source = self.event_sources.sources["presence"]
         presence, presence_key = yield presence_source.get_new_events(
             user=sync_config.user,