From a9b42926fa36916e985cf9d4c5b923a3db6565c7 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 16 Feb 2018 12:07:12 -0800 Subject: [PATCH] modules/client/events: Dumbstub this endpoint for 11.6 and requiring a room_id for now. --- modules/client/events.cc | 41 +++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/modules/client/events.cc b/modules/client/events.cc index 57c500635..c5efe1f04 100644 --- a/modules/client/events.cc +++ b/modules/client/events.cc @@ -13,7 +13,7 @@ using namespace ircd; mapi::header IRCD_MODULE { - "Client 6.2.2 :Events" + "Client 11.16 :Room Previews" }; resource @@ -21,42 +21,45 @@ events_resource { "/_matrix/client/r0/events", { - "Events (6.2.3) (10.x)" + "(11.16) Room Previews" } }; 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 { - unquote(request["room_id"]) + unquote(request.at("room_id")) }; - const m::vm::query query + const m::room room { - { "room_id", room_id } + room_id }; - size_t i(0); - m::vm::for_each(query, [&i](const auto &event) + const string_view start{}; + const string_view end{}; + std::vector events; + json::value chunk { - ++i; - }); - - 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; - }); + events.data(), events.size() + }; return resource::response { client, json::members { - { "chunk", { ret, j } } + { "start", start }, + { "chunk", chunk }, + { "end", end }, } }; }