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:
parent
4a25f3be72
commit
7e96e00184
1 changed files with 46 additions and 39 deletions
|
@ -35,14 +35,38 @@ get__state_ids(client &client,
|
|||
url::decode(request.parv[0], room_id)
|
||||
};
|
||||
|
||||
//TODO: =
|
||||
m::event::id::buf event_id;
|
||||
if(request.query["event_id"])
|
||||
url::decode(request.query.at("event_id"), event_id);
|
||||
// if(request.query["event_id"])
|
||||
// event_id = url::decode(request.query.at("event_id"), event_id);
|
||||
|
||||
//TODO: direct to socket
|
||||
const unique_buffer<mutable_buffer> buf{1_MiB}; //TODO: XXX
|
||||
json::stack out{buf};
|
||||
const m::room room
|
||||
{
|
||||
room_id, event_id
|
||||
};
|
||||
|
||||
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
|
||||
{
|
||||
|
@ -54,30 +78,13 @@ get__state_ids(client &client,
|
|||
pdus_m
|
||||
};
|
||||
|
||||
const m::room::state state
|
||||
state.for_each(m::event::id::closure{[&pdus]
|
||||
(const m::event::id &event_id)
|
||||
{
|
||||
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()}
|
||||
};
|
||||
return {};
|
||||
}
|
||||
|
||||
resource::method
|
||||
|
|
Loading…
Reference in a new issue