From 3b7df8069b2d474b050d9bbb1c742c5230254a04 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Thu, 31 May 2018 11:09:33 -0700 Subject: [PATCH] modules/console: Add room visible diagnostic cmd. --- modules/console.cc | 48 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/modules/console.cc b/modules/console.cc index 6b2018dc2..239be89ee 100644 --- a/modules/console.cc +++ b/modules/console.cc @@ -3879,6 +3879,54 @@ console_cmd__room__depth(opt &out, const string_view &line) return true; } +bool +console_cmd__room__visible(opt &out, const string_view &line) +{ + const params param{line, " ", + { + "room_id", "user_id|node_id", "event_id" + }}; + + const auto &room_id + { + m::room_id(param.at(0)) + }; + + const string_view &mxid + { + param[1] && param[1] != "*"? + param[1]: + param[1] == "*"? + string_view{}: + param[1] + }; + + const auto &event_id + { + param[2] + }; + + const m::room room + { + room_id, event_id + }; + + const bool visible + { + room.visible(mxid) + }; + + out << room_id << " is " + << (visible? "VISIBLE" : "NOT VISIBLE") + << (mxid? " to " : "") + << mxid + << (event_id? " at " : "") + << event_id + << std::endl; + + return true; +} + bool console_cmd__room__members(opt &out, const string_view &line) {