mod_muc_mam: Copy "include total" behavior from mod_mam 0.12
authorKim Alvefur <zash@zash.se>
Sat, 21 Jan 2023 17:14:55 +0100
branch0.12
changeset 12863 cd738fb8c754
parent 12862 71dc48a89e5a
child 12864 38b3cd292ee5
child 12866 3dfb87814d65
mod_muc_mam: Copy "include total" behavior from mod_mam Not sure why this was missing from MUC MAM, it already had some of the code for dealing with it.
plugins/mod_muc_mam.lua
--- a/plugins/mod_muc_mam.lua	Sat Jan 21 17:09:22 2023 +0100
+++ b/plugins/mod_muc_mam.lua	Sat Jan 21 17:14:55 2023 +0100
@@ -67,6 +67,7 @@
 	module:log("info", "See https://prosody.im/doc/storage and https://prosody.im/doc/archiving for more information");
 	return false;
 end
+local use_total = module:get_option_boolean("muc_log_include_total", true);
 
 local function archiving_enabled(room)
 	if log_all_rooms then
@@ -203,7 +204,7 @@
 		before = before; after = after;
 		ids = qids;
 		reverse = reverse;
-		total = qmax == 0;
+		total = use_total or qmax == 0;
 	});
 
 	if not data then
@@ -564,4 +565,7 @@
 
 else
 	module:log("debug", "Archive expiry disabled");
+	-- Don't ask the backend to count the potentially unbounded number of items,
+	-- it'll get slow.
+	use_total = module:get_option_boolean("mam_include_total", false);
 end