summary refs log tree commit diff
path: root/synapse/api
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2015-02-11 10:03:24 +0000
committerKegan Dougal <kegan@matrix.org>2015-02-11 10:03:24 +0000
commit9978c5c10310512493b976f482f400bf30a78729 (patch)
tree5afafbfa518af855eb654a4a060f692b0ae2332e /synapse/api
parentMerge branch 'develop' into application-services (diff)
parentMerge pull request #60 from matrix-org/single_source_version_and_dependencies (diff)
downloadsynapse-9978c5c10310512493b976f482f400bf30a78729.tar.xz
Merge branch 'develop' into application-services
Diffstat (limited to 'synapse/api')
-rw-r--r--synapse/api/auth.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/synapse/api/auth.py b/synapse/api/auth.py
index 310a428066..b176db8ce1 100644
--- a/synapse/api/auth.py
+++ b/synapse/api/auth.py
@@ -89,12 +89,19 @@ class Auth(object):
             raise
 
     @defer.inlineCallbacks
-    def check_joined_room(self, room_id, user_id):
-        member = yield self.state.get_current_state(
-            room_id=room_id,
-            event_type=EventTypes.Member,
-            state_key=user_id
-        )
+    def check_joined_room(self, room_id, user_id, current_state=None):
+        if current_state:
+            member = current_state.get(
+                (EventTypes.Member, user_id),
+                None
+            )
+        else:
+            member = yield self.state.get_current_state(
+                room_id=room_id,
+                event_type=EventTypes.Member,
+                state_key=user_id
+            )
+
         self._check_joined_room(member, user_id, room_id)
         defer.returnValue(member)
 
@@ -102,7 +109,7 @@ class Auth(object):
     def check_host_in_room(self, room_id, host):
         curr_state = yield self.state.get_current_state(room_id)
 
-        for event in curr_state:
+        for event in curr_state.values():
             if event.type == EventTypes.Member:
                 try:
                     if UserID.from_string(event.state_key).domain != host: