summary refs log tree commit diff
path: root/synapse/rest/admin/rooms.py
diff options
context:
space:
mode:
authorMichael Albert <37796947+awesome-michael@users.noreply.github.com>2020-07-16 22:43:23 +0200
committerGitHub <noreply@github.com>2020-07-16 16:43:23 -0400
commitfff483ea96160912ee4e9f5f3f743b86a933058f (patch)
treea9fcc72cbbab8b54309d8cf0260402e710a3333b /synapse/rest/admin/rooms.py
parentConsistently use `db_to_json` to convert from database values to JSON objects... (diff)
downloadsynapse-fff483ea96160912ee4e9f5f3f743b86a933058f.tar.xz
Add admin endpoint to get members in a room. (#7842)
Diffstat (limited to 'synapse/rest/admin/rooms.py')
-rw-r--r--synapse/rest/admin/rooms.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/synapse/rest/admin/rooms.py b/synapse/rest/admin/rooms.py
index 544be47060..b8c95d045a 100644
--- a/synapse/rest/admin/rooms.py
+++ b/synapse/rest/admin/rooms.py
@@ -231,6 +231,31 @@ class RoomRestServlet(RestServlet):
         return 200, ret
 
 
+class RoomMembersRestServlet(RestServlet):
+    """
+    Get members list of a room.
+    """
+
+    PATTERNS = admin_patterns("/rooms/(?P<room_id>[^/]+)/members")
+
+    def __init__(self, hs):
+        self.hs = hs
+        self.auth = hs.get_auth()
+        self.store = hs.get_datastore()
+
+    async def on_GET(self, request, room_id):
+        await assert_requester_is_admin(self.auth, request)
+
+        ret = await self.store.get_room(room_id)
+        if not ret:
+            raise NotFoundError("Room not found")
+
+        members = await self.store.get_users_in_room(room_id)
+        ret = {"members": members, "total": len(members)}
+
+        return 200, ret
+
+
 class JoinRoomAliasServlet(RestServlet):
 
     PATTERNS = admin_patterns("/join/(?P<room_identifier>[^/]*)")