summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-11-11 17:55:32 +0000
committerErik Johnston <erik@matrix.org>2014-11-11 17:55:32 +0000
commit37900a92dbfd269c17c88e1b6cd7eb7881ed7b13 (patch)
tree33c5b7631b3743fd441500916a9999e63ad7fa6f /synapse
parentsynapse.state docs. (diff)
downloadsynapse-37900a92dbfd269c17c88e1b6cd7eb7881ed7b13.tar.xz
Only allow people in a room to look up room state.
Diffstat (limited to 'synapse')
-rw-r--r--synapse/handlers/message.py38
1 files changed, 4 insertions, 34 deletions
diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py
index 8394013df3..4da5c046bf 100644
--- a/synapse/handlers/message.py
+++ b/synapse/handlers/message.py
@@ -147,49 +147,19 @@ class MessageHandler(BaseHandler):
 
     @defer.inlineCallbacks
     def get_room_data(self, user_id=None, room_id=None,
-                      event_type=None, state_key="",
-                      public_room_rules=[],
-                      private_room_rules=["join"]):
+                      event_type=None, state_key=""):
         """ Get data from a room.
 
         Args:
             event : The room path event
-            public_room_rules : A list of membership states the user can be in,
-            in order to read this data IN A PUBLIC ROOM. An empty list means
-            'any state'.
-            private_room_rules : A list of membership states the user can be
-            in, in order to read this data IN A PRIVATE ROOM. An empty list
-            means 'any state'.
         Returns:
             The path data content.
         Raises:
             SynapseError if something went wrong.
         """
-        if event_type == RoomTopicEvent.TYPE:
-            # anyone invited/joined can read the topic
-            private_room_rules = ["invite", "join"]
-
-        # does this room exist
-        room = yield self.store.get_room(room_id)
-        if not room:
-            raise RoomError(403, "Room does not exist.")
-
-        # does this user exist in this room
-        member = yield self.store.get_room_member(
-            room_id=room_id,
-            user_id="" if not user_id else user_id)
-
-        member_state = member.membership if member else None
-
-        if room.is_public and public_room_rules:
-            # make sure the user meets public room rules
-            if member_state not in public_room_rules:
-                raise RoomError(403, "Member does not meet public room rules.")
-        elif not room.is_public and private_room_rules:
-            # make sure the user meets private room rules
-            if member_state not in private_room_rules:
-                raise RoomError(
-                    403, "Member does not meet private room rules.")
+        have_joined = yield self.auth.check_joined_room(room_id, user_id)
+        if not have_joined:
+            raise RoomError(403, "User not in room.")
 
         data = yield self.state_handler.get_current_state(
             room_id, event_type, state_key