diff options
author | Will Hunt <will@half-shot.uk> | 2019-11-15 01:39:26 +0000 |
---|---|---|
committer | Will Hunt <will@half-shot.uk> | 2019-11-15 01:39:26 +0000 |
commit | 12ee70c0b97c38a9ab99907f6281ab08451e4469 (patch) | |
tree | 3973441c08b872c9604ee5253c218c820901d8e1 | |
parent | Add many joined members Servlet (diff) | |
download | synapse-hs/many-joined-members.tar.xz |
Move path to something more in keeping with /joined_rooms github/hs/many-joined-members hs/many-joined-members
-rw-r--r-- | synapse/rest/client/v1/room.py | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/synapse/rest/client/v1/room.py b/synapse/rest/client/v1/room.py index 38632c7234..e275a8009e 100644 --- a/synapse/rest/client/v1/room.py +++ b/synapse/rest/client/v1/room.py @@ -487,33 +487,6 @@ class JoinedRoomMemberListRestServlet(RestServlet): return 200, {"joined": users_with_profile} -class JoinedManyRoomMemberListRestServlet(RestServlet): - PATTERNS = client_patterns("/rooms/joined_members$", v1=True) - - def __init__(self, hs): - super(JoinedManyRoomMemberListRestServlet, self).__init__() - self.message_handler = hs.get_message_handler() - self.auth = hs.get_auth() - - async def on_POST(self, request): - requester = await self.auth.get_user_by_req(request) - - content = parse_json_object_from_request(request) - - if content.get("rooms", None) is None: - raise SynapseError(400, "'rooms' not given in request body.", errcode=Codes.BAD_JSON) - - result = {} - - for room_id in set(content["rooms"]): - if not isinstance(room_id, str): - raise SynapseError(400, "Invalid room_id given.", errcode=Codes.BAD_JSON) - result[room_id] = await self.message_handler.get_joined_members( - requester, room_id - ) - - return 200, {"rooms": result} - # TODO: Needs better unit testing class RoomMessageListRestServlet(RestServlet): @@ -872,6 +845,32 @@ class SearchRestServlet(RestServlet): return 200, results +class JoinedManyRoomMemberListRestServlet(RestServlet): + PATTERNS = client_patterns("/joined_members$", v1=True) + + def __init__(self, hs): + super(JoinedManyRoomMemberListRestServlet, self).__init__() + self.message_handler = hs.get_message_handler() + self.auth = hs.get_auth() + + async def on_POST(self, request): + requester = await self.auth.get_user_by_req(request) + + content = parse_json_object_from_request(request) + + if content.get("rooms", None) is None: + raise SynapseError(400, "'rooms' not given in request body.", errcode=Codes.BAD_JSON) + + result = {} + + for room_id in set(content["rooms"]): + if not isinstance(room_id, str): + raise SynapseError(400, "Invalid room_id given.", errcode=Codes.BAD_JSON) + result[room_id] = await self.message_handler.get_joined_members( + requester, room_id + ) + + return 200, {"rooms": result} class JoinedRoomsRestServlet(RestServlet): PATTERNS = client_patterns("/joined_rooms$", v1=True) |