mirror of
https://github.com/matrix-construct/construct
synced 2024-12-27 07:54:05 +01:00
modules/console: Add fed frontfill cmd.
This commit is contained in:
parent
289d855bf2
commit
252b78b660
1 changed files with 66 additions and 0 deletions
|
@ -6453,6 +6453,72 @@ console_cmd__fed__backfill(opt &out, const string_view &line)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
console_cmd__fed__frontfill(opt &out, const string_view &line)
|
||||
{
|
||||
const params param{line, " ",
|
||||
{
|
||||
"room_id", "remote", "earliest", "latest", "[limit]", "[min_depth]"
|
||||
}};
|
||||
|
||||
const auto &room_id
|
||||
{
|
||||
m::room_id(param.at(0))
|
||||
};
|
||||
|
||||
const net::hostport remote
|
||||
{
|
||||
param.at(1, room_id.host())
|
||||
};
|
||||
|
||||
const m::event::id &earliest
|
||||
{
|
||||
param.at(2)
|
||||
};
|
||||
|
||||
const m::event::id::buf &latest
|
||||
{
|
||||
param.at(3, m::head(std::nothrow, room_id))
|
||||
};
|
||||
|
||||
const auto &limit
|
||||
{
|
||||
param.at(4, 32UL)
|
||||
};
|
||||
|
||||
const auto &min_depth
|
||||
{
|
||||
param.at(5, 0UL)
|
||||
};
|
||||
|
||||
m::v1::frontfill::opts opts;
|
||||
opts.remote = remote;
|
||||
opts.limit = limit;
|
||||
opts.min_depth = min_depth;
|
||||
const unique_buffer<mutable_buffer> buf
|
||||
{
|
||||
16_KiB
|
||||
};
|
||||
|
||||
m::v1::frontfill request
|
||||
{
|
||||
room_id, {earliest, latest}, buf, std::move(opts)
|
||||
};
|
||||
|
||||
request.wait(out.timeout);
|
||||
request.get();
|
||||
|
||||
const json::array &response
|
||||
{
|
||||
request
|
||||
};
|
||||
|
||||
for(const json::object &event : response)
|
||||
out << pretty_oneline(m::event{event}) << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
console_cmd__fed__event(opt &out, const string_view &line)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue