0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-28 16:34:13 +01:00

modules/client/events: Dumbstub this endpoint for 11.6 and requiring a room_id for now.

This commit is contained in:
Jason Volk 2018-02-16 12:07:12 -08:00
parent fa4d31292f
commit a9b42926fa

View file

@ -13,7 +13,7 @@ using namespace ircd;
mapi::header mapi::header
IRCD_MODULE IRCD_MODULE
{ {
"Client 6.2.2 :Events" "Client 11.16 :Room Previews"
}; };
resource resource
@ -21,42 +21,45 @@ events_resource
{ {
"/_matrix/client/r0/events", "/_matrix/client/r0/events",
{ {
"Events (6.2.3) (10.x)" "(11.16) Room Previews"
} }
}; };
resource::response resource::response
get__events(client &client, const resource::request &request) get__events(client &client,
const resource::request &request)
{ {
if(!request.has("room_id"))
throw m::UNSUPPORTED
{
"Specify a room_id or use /sync"
};
const m::room::id &room_id const m::room::id &room_id
{ {
unquote(request["room_id"]) unquote(request.at("room_id"))
}; };
const m::vm::query<m::vm::where::equal> query const m::room room
{ {
{ "room_id", room_id } room_id
}; };
size_t i(0); const string_view start{};
m::vm::for_each(query, [&i](const auto &event) const string_view end{};
std::vector<json::value> events;
json::value chunk
{ {
++i; events.data(), events.size()
}); };
size_t j(0);
json::value ret[i];
m::vm::for_each(query, [&i, &j, &ret](const m::event &event)
{
if(j < i)
ret[j++] = event;
});
return resource::response return resource::response
{ {
client, json::members client, json::members
{ {
{ "chunk", { ret, j } } { "start", start },
{ "chunk", chunk },
{ "end", end },
} }
}; };
} }