mirror of
https://github.com/matrix-construct/construct
synced 2024-11-28 17:52:54 +01:00
modules/console: Add mass-query for room_id/alias argument to key get cmd.
This commit is contained in:
parent
95d5361c20
commit
4339639732
1 changed files with 50 additions and 3 deletions
|
@ -7211,15 +7211,62 @@ console_cmd__key__get(opt &out, const string_view &line)
|
|||
|
||||
const auto server_name
|
||||
{
|
||||
param.at(0)
|
||||
param.at("server_name")
|
||||
};
|
||||
|
||||
const auto query_server
|
||||
{
|
||||
param[1]
|
||||
param["[query_server]"]
|
||||
};
|
||||
|
||||
if(!query_server)
|
||||
if(m::valid(m::id::ROOM, server_name) || m::valid(m::id::ROOM_ALIAS, server_name))
|
||||
{
|
||||
const auto query_server
|
||||
{
|
||||
param.at("[query_server]")
|
||||
};
|
||||
|
||||
const auto room_id
|
||||
{
|
||||
m::room_id(server_name)
|
||||
};
|
||||
|
||||
const m::room::origins origins
|
||||
{
|
||||
room_id
|
||||
};
|
||||
|
||||
std::vector<std::string> servers;
|
||||
servers.reserve(origins.count());
|
||||
origins.for_each([&servers]
|
||||
(const auto &server)
|
||||
{
|
||||
servers.emplace_back(server);
|
||||
});
|
||||
|
||||
std::vector<m::fed::key::server_key> queries(servers.size());
|
||||
std::transform(begin(servers), end(servers), begin(queries), []
|
||||
(const auto &server) -> m::fed::key::server_key
|
||||
{
|
||||
return { server, {} };
|
||||
});
|
||||
|
||||
const auto closure{[&out]
|
||||
(const m::keys &keys)
|
||||
{
|
||||
pretty_oneline(out, keys) << std::endl;
|
||||
return true;
|
||||
}};
|
||||
|
||||
const bool dynamic_response {true};
|
||||
const unique_mutable_buffer buf
|
||||
{
|
||||
64_KiB
|
||||
};
|
||||
|
||||
m::keys::query(query_server, queries, closure, buf, dynamic_response);
|
||||
}
|
||||
else if(!query_server)
|
||||
{
|
||||
m::keys::get(server_name, [&out]
|
||||
(const m::keys &keys)
|
||||
|
|
Loading…
Reference in a new issue