From 01a751ca96595a7a2112355476260e216e8a8a78 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Thu, 22 Aug 2019 09:19:04 -0700 Subject: [PATCH] modules/console: Add rooms head reset cmd. --- modules/console.cc | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/modules/console.cc b/modules/console.cc index 7a8caae6d..135b548ed 100644 --- a/modules/console.cc +++ b/modules/console.cc @@ -7691,6 +7691,47 @@ console_cmd__rooms__fetch(opt &out, const string_view &line) return true; } +bool +console_cmd__rooms__head__reset(opt &out, const string_view &line) +{ + const params param{line, " ", + { + "server" + }}; + + const string_view &server + { + param["server"] != "*" && + param["server"] != "remote_joined_only" && + param["server"] != "local_only"? + param["server"]: + string_view{} + }; + + m::rooms::opts opts; + opts.server = server; + + if(param["server"] == "remote_joined_only") + opts.remote_joined_only = true; + + if(param["server"] == "local_only") + opts.local_only = true; + + m::rooms::for_each(opts, [&out] + (const m::room::id &room_id) -> bool + { + const m::room::head head + { + room_id + }; + + m::room::head::reset(head); + return true; + }); + + return true; +} + // // room //