From 53fedc4c4bc44d5614cc492d858d9e6bed8bbf1e Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 11 May 2018 02:08:36 -0700 Subject: [PATCH] modules/console: Add basic node cmd w/ node keys iteration. --- modules/console.cc | 56 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/modules/console.cc b/modules/console.cc index 469bcf211..50c152358 100644 --- a/modules/console.cc +++ b/modules/console.cc @@ -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 //