mirror of
https://github.com/matrix-construct/construct
synced 2024-11-17 15:30:52 +01:00
modules/console: Add ids_only argument gimmick.
This commit is contained in:
parent
541d95f47e
commit
75abe2b0f9
1 changed files with 18 additions and 2 deletions
|
@ -11663,7 +11663,7 @@ console_cmd__fed__auth(opt &out, const string_view &line)
|
|||
{
|
||||
const params param{line, " ",
|
||||
{
|
||||
"room_id", "event_id", "remote"
|
||||
"room_id", "event_id", "remote", "ids_only"
|
||||
}};
|
||||
|
||||
const auto room_id
|
||||
|
@ -11681,8 +11681,14 @@ console_cmd__fed__auth(opt &out, const string_view &line)
|
|||
param.at(2, event_id.host())
|
||||
};
|
||||
|
||||
const string_view &ids_only
|
||||
{
|
||||
param["ids_only"]
|
||||
};
|
||||
|
||||
m::v1::event_auth::opts opts;
|
||||
opts.remote = remote;
|
||||
opts.ids_only = ids_only == "ids";
|
||||
const unique_buffer<mutable_buffer> buf
|
||||
{
|
||||
16_KiB
|
||||
|
@ -11698,9 +11704,19 @@ console_cmd__fed__auth(opt &out, const string_view &line)
|
|||
|
||||
const json::array &auth_chain
|
||||
{
|
||||
request
|
||||
opts.ids_only?
|
||||
json::object(request.in.content).at("auth_chain_ids"):
|
||||
json::array(request)
|
||||
};
|
||||
|
||||
if(opts.ids_only)
|
||||
{
|
||||
for(const json::string &event_id : auth_chain)
|
||||
out << event_id << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<m::event> events(size(auth_chain));
|
||||
std::transform(begin(auth_chain), end(auth_chain), begin(events), []
|
||||
(const json::object &event) -> m::event
|
||||
|
|
Loading…
Reference in a new issue