mirror of
https://github.com/matrix-construct/construct
synced 2024-12-24 14:34:00 +01:00
modules/admin/rooms: Implement GET /members.
This commit is contained in:
parent
a549fd0b80
commit
2d78dbdbb9
1 changed files with 42 additions and 0 deletions
|
@ -10,6 +10,7 @@
|
|||
|
||||
namespace ircd::m::admin
|
||||
{
|
||||
static resource::response handle_get_members(client &, const resource::request &, const room::id &);
|
||||
static resource::response handle_delete_forward_extremis(client &, const resource::request &, const room::id &);
|
||||
static resource::response handle_get_forward_extremis(client &, const resource::request &, const room::id &);
|
||||
static resource::response handle(client &, const resource::request &);
|
||||
|
@ -83,6 +84,9 @@ ircd::m::admin::handle(client &client,
|
|||
if(request.head.method == "GET" && cmd == "forward_extremities")
|
||||
return handle_get_forward_extremis(client, request, room_id);
|
||||
|
||||
if(request.head.method == "GET" && cmd == "members")
|
||||
return handle_get_members(client, request, room_id);
|
||||
|
||||
throw m::NOT_FOUND
|
||||
{
|
||||
"/admin/rooms command not found"
|
||||
|
@ -162,3 +166,41 @@ ircd::m::admin::handle_get_forward_extremis(client &client,
|
|||
|
||||
return response;
|
||||
}
|
||||
|
||||
ircd::m::resource::response
|
||||
ircd::m::admin::handle_get_members(client &client,
|
||||
const resource::request &request,
|
||||
const room::id &room_id)
|
||||
{
|
||||
const m::room::members members
|
||||
{
|
||||
room_id
|
||||
};
|
||||
|
||||
m::resource::response::chunked::json response
|
||||
{
|
||||
client, http::OK
|
||||
};
|
||||
|
||||
json::stack::member
|
||||
{
|
||||
response, "total", json::value
|
||||
{
|
||||
long(members.count("join"))
|
||||
}
|
||||
};
|
||||
|
||||
json::stack::array array
|
||||
{
|
||||
response, "members"
|
||||
};
|
||||
|
||||
members.for_each("join", [&array]
|
||||
(const m::id::user &user_id)
|
||||
{
|
||||
array.append(user_id);
|
||||
return true;
|
||||
});
|
||||
|
||||
return response;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue