From c1e3b9f4057a098a97aa8976dc1c6ea9aa62e50e Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sun, 25 Aug 2019 14:27:03 -0700 Subject: [PATCH] modules/console: Add a user mitsein command. --- modules/console.cc | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/modules/console.cc b/modules/console.cc index c8760752e..9ff8cb3eb 100644 --- a/modules/console.cc +++ b/modules/console.cc @@ -10790,6 +10790,46 @@ console_cmd__user__sees(opt &out, const string_view &line) return true; } +bool +console_cmd__user__mitsein(opt &out, const string_view &line) +{ + const params param{line, " ", + { + "user_id_a", "user_id_b", "membership" + }}; + + const m::user user_a + { + m::user(param.at("user_id_a")) + }; + + const m::user user_b + { + m::user(param.at("user_id_b")) + }; + + const string_view membership + { + param.at("membership", "join"_sv) + }; + + const m::user::mitsein mitsein + { + user_a + }; + + mitsein.for_each(user_b, membership, [&out] + (const m::room &room, const string_view &membership) + { + out << room.room_id + << std::endl; + + return true; + }); + + return true; +} + bool console_cmd__user__tokens(opt &out, const string_view &line) {