Diff

plugins/mod_muc_mam.lua @ 11989:871100cdbbad

mod_muc_mam: Switch to mod_cron for message expiry
author Kim Alvefur <zash@zash.se>
date Mon, 22 Nov 2021 14:49:05 +0100
parent 11968:6e1af07921d1
child 12857:cc86d77481fc
line wrap: on
line diff
--- 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