0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-27 07:54:05 +01:00

modules/console: Add basic node cmd w/ node keys iteration.

This commit is contained in:
Jason Volk 2018-05-11 02:08:36 -07:00
parent dc38da5566
commit 53fedc4c4b

View file

@ -297,6 +297,7 @@ console_cmd__test(opt &out, const string_view &line)
//
bool console_id__user(opt &, const m::user::id &id, const string_view &line);
bool console_id__node(opt &, const m::node::id &id, const string_view &line);
bool console_id__room(opt &, const m::room::id &id, const string_view &line);
bool console_id__event(opt &, const m::event::id &id, const string_view &line);
bool console_json(const json::object &);
@ -313,6 +314,9 @@ console_command_derived(opt &out, const string_view &line)
case m::id::ROOM:
return console_id__room(out, id, line);
case m::id::NODE:
return console_id__node(out, id, line);
case m::id::USER:
return console_id__user(out, id, line);
@ -3604,6 +3608,58 @@ console_cmd__user__read(opt &out, const string_view &line)
return true;
}
//
// node
//
//TODO: XXX
bool
console_id__node(opt &out,
const m::node::id &id,
const string_view &args)
{
return true;
}
bool
console_cmd__node__keys(opt &out, const string_view &line)
{
const params param{line, " ",
{
"node_id", "[limit]"
}};
const m::node &node
{
param.at(0)
};
auto limit
{
param.at(1, size_t(1))
};
const m::node::room node_room
{
node
};
const m::room::state state{node_room};
state.for_each("ircd.key", [&out, &limit]
(const m::event &event)
{
const m::keys keys
{
json::get<"content"_>(event)
};
out << keys << std::endl;
return --limit;
});
return true;
}
//
// feds
//