diff options
Diffstat (limited to 'synapse/rest/room.py')
-rw-r--r-- | synapse/rest/room.py | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/synapse/rest/room.py b/synapse/rest/room.py index ec0ce78fda..4f6d039b61 100644 --- a/synapse/rest/room.py +++ b/synapse/rest/room.py @@ -138,7 +138,7 @@ class RoomStateEventRestServlet(RestServlet): raise SynapseError( 404, "Event not found.", errcode=Codes.NOT_FOUND ) - defer.returnValue((200, data[0].get_dict()["content"])) + defer.returnValue((200, data.get_dict()["content"])) @defer.inlineCallbacks def on_PUT(self, request, room_id, event_type, state_key): @@ -148,12 +148,15 @@ class RoomStateEventRestServlet(RestServlet): content = _parse_json(request) event = self.event_factory.create_event( - etype=event_type, + etype=urllib.unquote(event_type), content=content, room_id=urllib.unquote(room_id), user_id=user.to_string(), state_key=urllib.unquote(state_key) ) + + self.validator.validate(event) + if event_type == RoomMemberEvent.TYPE: # membership events are special handler = self.handlers.room_member_handler @@ -182,12 +185,14 @@ class RoomSendEventRestServlet(RestServlet): content = _parse_json(request) event = self.event_factory.create_event( - etype=event_type, + etype=urllib.unquote(event_type), room_id=urllib.unquote(room_id), user_id=user.to_string(), content=content ) + self.validator.validate(event) + msg_handler = self.handlers.message_handler yield msg_handler.send_message(event) @@ -253,6 +258,9 @@ class JoinRoomAliasServlet(RestServlet): user_id=user.to_string(), state_key=user.to_string() ) + + self.validator.validate(event) + handler = self.handlers.room_member_handler yield handler.change_membership(event) defer.returnValue((200, {})) @@ -353,27 +361,14 @@ class RoomInitialSyncRestServlet(RestServlet): @defer.inlineCallbacks def on_GET(self, request, room_id): - yield self.auth.get_user_by_req(request) - # TODO: Get all the initial sync data for this room and return in the - # same format as initial sync, that is: - # { - # membership: join, - # messages: [ - # chunk: [ msg events ], - # start: s_tok, - # end: e_tok - # ], - # room_id: foo, - # state: [ - # { state event } , { state event } - # ] - # } - # Probably worth keeping the keys room_id and membership for parity - # with /initialSync even though they must be joined to sync this and - # know the room ID, so clients can reuse the same code (room_id and - # membership are MANDATORY for /initialSync, so the code will expect - # it to be there) - defer.returnValue((200, {})) + user = yield self.auth.get_user_by_req(request) + pagination_config = PaginationConfig.from_request(request) + content = yield self.handlers.message_handler.room_initial_sync( + room_id=urllib.unquote(room_id), + user_id=user.to_string(), + pagin_config=pagination_config, + ) + defer.returnValue((200, content)) class RoomTriggerBackfill(RestServlet): @@ -424,6 +419,9 @@ class RoomMembershipRestServlet(RestServlet): user_id=user.to_string(), state_key=state_key ) + + self.validator.validate(event) + handler = self.handlers.room_member_handler yield handler.change_membership(event) defer.returnValue((200, {})) @@ -458,9 +456,11 @@ class RoomRedactEventRestServlet(RestServlet): room_id=urllib.unquote(room_id), user_id=user.to_string(), content=content, - redacts=event_id, + redacts=urllib.unquote(event_id), ) + self.validator.validate(event) + msg_handler = self.handlers.message_handler yield msg_handler.send_message(event) |