0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 18:22:50 +01:00

modules/client/rooms: 6.3.5 GET joined_members; minor cleanup.

This commit is contained in:
Jason Volk 2018-02-16 12:36:30 -08:00
parent a9b42926fa
commit b121c4377b
3 changed files with 44 additions and 6 deletions

View file

@ -17,14 +17,9 @@ get__members(client &client,
const resource::request &request,
const m::room::id &room_id)
{
const m::room room
{
room_id
};
const m::room::members members
{
room
room_id
};
std::vector<json::value> ret;
@ -43,3 +38,38 @@ get__members(client &client,
}
};
}
resource::response
get__joined_members(client &client,
const resource::request &request,
const m::room::id &room_id)
{
const m::room::members members
{
room_id
};
std::vector<json::member> ret;
ret.reserve(32);
members.for_each("join", [&ret](const m::event &event)
{
ret.emplace_back(json::member
{
at<"sender"_>(event), at<"content"_>(event)
});
});
const json::strung joined
{
ret.data(), ret.data() + ret.size()
};
return resource::response
{
client, json::members
{
{ "joined", joined }
}
};
}

View file

@ -56,6 +56,9 @@ get_rooms(client &client, const resource::request &request)
if(cmd == "members")
return get__members(client, request, room_id);
if(cmd == "joined_members")
return get__joined_members(client, request, room_id);
if(cmd == "context")
return get__context(client, request, room_id);

View file

@ -40,6 +40,11 @@ get__members(ircd::client &client,
const ircd::resource::request &request,
const ircd::m::room::id &room_id);
ircd::resource::response
get__joined_members(ircd::client &client,
const ircd::resource::request &request,
const ircd::m::room::id &room_id);
///////////////////////////////////////////////////////////////////////////////
//
// context.cc