mirror of
https://github.com/matrix-construct/construct
synced 2024-12-25 06:53:58 +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
|
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_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_get_forward_extremis(client &, const resource::request &, const room::id &);
|
||||||
static resource::response handle(client &, const resource::request &);
|
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")
|
if(request.head.method == "GET" && cmd == "forward_extremities")
|
||||||
return handle_get_forward_extremis(client, request, room_id);
|
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
|
throw m::NOT_FOUND
|
||||||
{
|
{
|
||||||
"/admin/rooms command not found"
|
"/admin/rooms command not found"
|
||||||
|
@ -162,3 +166,41 @@ ircd::m::admin::handle_get_forward_extremis(client &client,
|
||||||
|
|
||||||
return response;
|
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