0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-05-19 19:33:45 +02:00

modules/console: Add param to room auth and fed auth cmds to filter by type.

This commit is contained in:
Jason Volk 2023-03-11 14:45:04 -08:00
parent 8ebd2089f2
commit fb9f2b0bcc

View file

@ -12358,7 +12358,7 @@ console_cmd__room__auth(opt &out, const string_view &line)
{ {
const params param{line, " ", const params param{line, " ",
{ {
"event_id|room_id", "event_id" "event_id|room_id", "event_id", "type"
}}; }};
const string_view &p0 const string_view &p0
@ -12395,18 +12395,27 @@ console_cmd__room__auth(opt &out, const string_view &line)
p0 p0
}; };
const auto type
{
param["type"]
};
const m::room::auth::chain ac const m::room::auth::chain ac
{ {
m::index(event_id) m::index(event_id)
}; };
ac.for_each([&out](const auto &idx) ac.for_each([&out, &type]
(const auto &idx)
{ {
const m::event::fetch event const m::event::fetch event
{ {
std::nothrow, idx std::nothrow, idx
}; };
if(type && json::get<"type"_>(event) != type)
return true;
out << idx; out << idx;
if(event.valid) if(event.valid)
out << " " << pretty_oneline(event); out << " " << pretty_oneline(event);
@ -16553,7 +16562,13 @@ console_cmd__fed__auth(opt &out, const string_view &line)
std::sort(begin(events), end(events)); std::sort(begin(events), end(events));
for(const auto &event : events) for(const auto &event : events)
{
if(startswith(param["op"], "m.room."))
if(json::get<"type"_>(event) != param["op"])
continue;
out << pretty_oneline(event) << std::endl; out << pretty_oneline(event) << std::endl;
}
return true; return true;
} }