From d7ca00c4a17eb0fd8d8afc67ffdb631f336a793b Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Wed, 22 Aug 2018 18:06:22 -0700 Subject: [PATCH] modules/console: Add peer error filter option for origins random cmd. --- modules/console.cc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/modules/console.cc b/modules/console.cc index 520f6b7ec..39b15d910 100644 --- a/modules/console.cc +++ b/modules/console.cc @@ -4685,7 +4685,7 @@ console_cmd__room__origins__random(opt &out, const string_view &line) const params param{line, " ", { - "room_id" + "room_id", "[noerror]" }}; const auto &room_id @@ -4693,15 +4693,29 @@ console_cmd__room__origins__random(opt &out, const string_view &line) m::room_id(param.at("room_id")) }; + const bool noerror + { + param.at("[noerror]", false) + }; + const m::room room { room_id }; + const auto ok{[&noerror] + (const string_view &origin) + { + if(noerror && ircd::server::errmsg(origin)) + return false; + + return true; + }}; + char buf[256]; const string_view origin { - random_origin(room, buf, nullptr) + random_origin(room, buf, ok) }; if(!origin)