summary refs log tree commit diff
path: root/synapse/handlers
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-09-08 18:16:09 +0100
committerMark Haines <mark.haines@matrix.org>2015-09-08 18:16:09 +0100
commitdd42bb78d088c719aaa288b892fe58caa5850deb (patch)
treeac8d73a187d9a01efe5608be437730b9962fade9 /synapse/handlers
parentInclude the event_id and stream_ordering of membership events when looking up... (diff)
downloadsynapse-dd42bb78d088c719aaa288b892fe58caa5850deb.tar.xz
Include rooms that a user has left in an initialSync. Include the state and messages at the point they left the room
Diffstat (limited to 'synapse/handlers')
-rw-r--r--synapse/handlers/message.py27
1 files changed, 21 insertions, 6 deletions
diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py
index 23b779ad7c..5447c97e83 100644
--- a/synapse/handlers/message.py
+++ b/synapse/handlers/message.py
@@ -316,7 +316,9 @@ class MessageHandler(BaseHandler):
         """
         room_list = yield self.store.get_rooms_for_user_where_membership_is(
             user_id=user_id,
-            membership_list=[Membership.INVITE, Membership.JOIN]
+            membership_list=[
+                Membership.INVITE, Membership.JOIN, Membership.LEAVE
+            ]
         )
 
         user = UserID.from_string(user_id)
@@ -358,19 +360,32 @@ class MessageHandler(BaseHandler):
 
             rooms_ret.append(d)
 
-            if event.membership != Membership.JOIN:
+            if event.membership not in (Membership.JOIN, Membership.LEAVE):
                 return
             try:
+                if event.membership == Membership.JOIN:
+                    room_end_token = now_token.room_key
+                    deferred_room_state = self.state_handler.get_current_state(
+                        event.room_id
+                    )
+                else:
+                    room_end_token = "s%d" % (event.stream_ordering,)
+                    deferred_room_state = self.store.get_state_for_events(
+                        event.room_id, [event.event_id], None
+                    )
+                    deferred_room_state.addCallback(
+                        lambda states: states[event.event_id]
+                    )
+
+
                 (messages, token), current_state = yield defer.gatherResults(
                     [
                         self.store.get_recent_events_for_room(
                             event.room_id,
                             limit=limit,
-                            end_token=now_token.room_key,
-                        ),
-                        self.state_handler.get_current_state(
-                            event.room_id
+                            end_token=room_end_token,
                         ),
+                        deferred_room_state,
                     ]
                 ).addErrback(unwrapFirstError)