0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-16 15:00:51 +01:00

modules/federation/state_ids: Chunk direct to socket.

This commit is contained in:
Jason Volk 2018-04-30 10:35:04 -07:00
parent 4a25f3be72
commit 7e96e00184

View file

@ -35,49 +35,56 @@ get__state_ids(client &client,
url::decode(request.parv[0], room_id) url::decode(request.parv[0], room_id)
}; };
//TODO: =
m::event::id::buf event_id; m::event::id::buf event_id;
if(request.query["event_id"]) // if(request.query["event_id"])
url::decode(request.query.at("event_id"), event_id); // event_id = url::decode(request.query.at("event_id"), event_id);
//TODO: direct to socket const m::room room
const unique_buffer<mutable_buffer> buf{1_MiB}; //TODO: XXX
json::stack out{buf};
{ {
json::stack::object top{out}; room_id, event_id
json::stack::member pdus_m
{
top, "pdu_ids"
};
json::stack::array pdus
{
pdus_m
};
const m::room::state state
{
m::room
{
room_id, event_id
}
};
state.for_each([&pdus]
(const m::event &event)
{
const auto event_id
{
at<"event_id"_>(event)
};
pdus.append(event_id);
});
}
return resource::response
{
client, json::object{out.completed()}
}; };
const m::room::state state
{
room
};
const unique_buffer<mutable_buffer> buf
{
8_KiB
};
resource::response::chunked response
{
client, http::OK
};
json::stack out{buf, [&response]
(const const_buffer &buf)
{
response.write(buf);
return buf;
}};
json::stack::object top{out};
json::stack::member pdus_m
{
top, "pdu_ids"
};
json::stack::array pdus
{
pdus_m
};
state.for_each(m::event::id::closure{[&pdus]
(const m::event::id &event_id)
{
pdus.append(event_id);
}});
return {};
} }
resource::method resource::method