mod_muc_mam: Switch to mod_cron for message expiry
authorKim Alvefur <zash@zash.se>
Mon, 22 Nov 2021 14:49:05 +0100
changeset 11993 871100cdbbad
parent 11992 18c0ca5fcbb8
child 11994 6f4790b8deec
mod_muc_mam: Switch to mod_cron for message expiry
plugins/mod_muc_mam.lua
--- a/plugins/mod_muc_mam.lua	Sun Nov 21 18:16:03 2021 +0100
+++ b/plugins/mod_muc_mam.lua	Mon Nov 22 14:49:05 2021 +0100
@@ -35,7 +35,6 @@
 local default_max_items, max_max_items = 20, module:get_option_number("max_archive_query_results", 50);
 
 local cleanup_after = module:get_option_string("muc_log_expires_after", "1w");
-local cleanup_interval = module:get_option_number("muc_log_cleanup_interval", 4 * 60 * 60);
 
 local default_history_length = 20;
 local max_history_length = module:get_option_number("max_history_messages", math.huge);
@@ -494,7 +493,7 @@
 	local cleanup_time = module:measure("cleanup", "times");
 
 	local async = require "util.async";
-	cleanup_runner = async.runner(function ()
+	module:daily("Remove expired messages", function ()
 		local cleanup_done = cleanup_time();
 
 		if archive.caps and archive.caps.wildcard_delete then
@@ -550,10 +549,6 @@
 		cleanup_done();
 	end);
 
-	cleanup_task = module:add_timer(1, function ()
-		cleanup_runner:run(true);
-		return cleanup_interval;
-	end);
 else
 	module:log("debug", "Archive expiry disabled");
 end