0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-07-05 10:08:36 +02:00

modules/console: Add room state keys iteration cmd.

This commit is contained in:
Jason Volk 2018-10-24 15:18:41 -07:00
parent d95b86c7a8
commit af0cca91c3

View file

@ -6016,6 +6016,57 @@ console_cmd__room__state__types(opt &out, const string_view &line)
return true;
}
bool
console_cmd__room__state__keys(opt &out, const string_view &line)
{
const params param{line, " ",
{
"room_id", "type", "event_id", "prefix"
}};
const auto &room_id
{
m::room_id(param.at("room_id"))
};
const auto &type
{
param.at("type")
};
const auto &event_id
{
param.at("event_id", string_view{})
};
const string_view &prefix
{
param.at("prefix", string_view{})
};
const m::room room
{
room_id, event_id
};
const m::room::state state
{
room
};
state.for_each(type, prefix, m::room::state::keys_bool{[&out, &prefix]
(const string_view &state_key)
{
if(prefix && !startswith(state_key, prefix))
return false;
out << state_key << std::endl;
return true;
}});
return true;
}
bool
console_cmd__room__state__force(opt &out, const string_view &line)
{