Diff

plugins/mod_mam/mod_mam.lua @ 11988:18c0ca5fcbb8

mod_mam: Switch to new cron API
author Kim Alvefur <zash@zash.se>
date Sun, 21 Nov 2021 18:16:03 +0100
parent 11968:6e1af07921d1
child 12030:9f8206e99b89
line wrap: on
line diff
--- a/plugins/mod_mam/mod_mam.lua	Sun Nov 21 18:13:21 2021 +0100
+++ b/plugins/mod_mam/mod_mam.lua	Sun Nov 21 18:16:03 2021 +0100
@@ -43,7 +43,6 @@
 local archive = module:open_store(archive_store, "archive");
 
 local cleanup_after = module:get_option_string("archive_expires_after", "1w");
-local cleanup_interval = module:get_option_number("archive_cleanup_interval", 4 * 60 * 60);
 local archive_item_limit = module:get_option_number("storage_archive_item_limit", archive.caps and archive.caps.quota or 1000);
 local archive_truncate = math.floor(archive_item_limit * 0.99);
 
@@ -524,7 +523,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
@@ -580,10 +579,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");
 	-- Don't ask the backend to count the potentially unbounded number of items,