Comparison

plugins/mod_mam/mod_mam.lua @ 10683:2f0b7f1d5e75

Merge 0.11->trunk
author Kim Alvefur <zash@zash.se>
date Wed, 11 Mar 2020 22:44:41 +0100
parent 10568:b6f93babebe8
parent 10682:62ef68f95b6f
child 10734:136c41a3d03c
comparison
equal deleted inserted replaced
10680:19692fc5c106 10683:2f0b7f1d5e75
401 last_date:set(username, date); 401 last_date:set(username, date);
402 end 402 end
403 end 403 end
404 local cleanup_time = module:measure("cleanup", "times"); 404 local cleanup_time = module:measure("cleanup", "times");
405 405
406 cleanup_runner = require "util.async".runner(function () 406 local async = require "util.async";
407 cleanup_runner = async.runner(function ()
407 local cleanup_done = cleanup_time(); 408 local cleanup_done = cleanup_time();
408 local users = {}; 409 local users = {};
409 local cut_off = datestamp(os.time() - cleanup_after); 410 local cut_off = datestamp(os.time() - cleanup_after);
410 for date in cleanup_storage:users() do 411 for date in cleanup_storage:users() do
411 if date <= cut_off then 412 if date <= cut_off then
431 sum = sum + (tonumber(ok) or 0); 432 sum = sum + (tonumber(ok) or 0);
432 else 433 else
433 cleanup_map:set(cut_off, user, true); 434 cleanup_map:set(cut_off, user, true);
434 module:log("error", "Could not delete messages for user '%s': %s", user, err); 435 module:log("error", "Could not delete messages for user '%s': %s", user, err);
435 end 436 end
437 local wait, done = async.waiter();
438 module:add_timer(0.01, done);
439 wait();
436 end 440 end
437 module:log("info", "Deleted %d expired messages for %d users", sum, num_users); 441 module:log("info", "Deleted %d expired messages for %d users", sum, num_users);
438 cleanup_done(); 442 cleanup_done();
439 end); 443 end);
440 444