summary refs log tree commit diff
path: root/synapse/handlers
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-09-10 15:06:47 +0100
committerMark Haines <mark.haines@matrix.org>2015-09-10 15:06:47 +0100
commite2054ce21a04f3d741293f50b283c01bbe2b0591 (patch)
tree2d2a46af3b6e27e05e7ae9d3980d3559fd3e99f8 /synapse/handlers
parentAllow users that have left a room to get the messages that happend in the roo... (diff)
downloadsynapse-e2054ce21a04f3d741293f50b283c01bbe2b0591.tar.xz
Allow users to GET individual state events for rooms that they have left
Diffstat (limited to 'synapse/handlers')
-rw-r--r--synapse/handlers/message.py20
1 files changed, 13 insertions, 7 deletions
diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py
index db89491b46..5d18aaacf0 100644
--- a/synapse/handlers/message.py
+++ b/synapse/handlers/message.py
@@ -16,7 +16,7 @@
 from twisted.internet import defer
 
 from synapse.api.constants import EventTypes, Membership
-from synapse.api.errors import RoomError, SynapseError
+from synapse.api.errors import SynapseError
 from synapse.streams.config import PaginationConfig
 from synapse.events.utils import serialize_event
 from synapse.events.validator import EventValidator
@@ -277,13 +277,19 @@ class MessageHandler(BaseHandler):
         Raises:
             SynapseError if something went wrong.
         """
-        have_joined = yield self.auth.check_joined_room(room_id, user_id)
-        if not have_joined:
-            raise RoomError(403, "User not in room.")
+        member_event = yield self.auth.check_user_was_in_room(room_id, user_id)
+
+        if member_event.membership == Membership.JOIN:
+            data = yield self.state_handler.get_current_state(
+                room_id, event_type, state_key
+            )
+        elif member_event.membership == Membership.LEAVE:
+            key = (event_type, state_key)
+            room_state = yield self.store.get_state_for_events(
+                room_id, [member_event.event_id], [key]
+            )
+            data = room_state[member_event.event_id].get(key)
 
-        data = yield self.state_handler.get_current_state(
-            room_id, event_type, state_key
-        )
         defer.returnValue(data)
 
     @defer.inlineCallbacks