Comparison

plugins/mod_muc_mam.lua @ 10683:2f0b7f1d5e75

Merge 0.11->trunk
author Kim Alvefur <zash@zash.se>
date Wed, 11 Mar 2020 22:44:41 +0100
parent 10671:5e1384298e97
parent 10682:62ef68f95b6f
child 10800:62794e065e33
comparison
equal deleted inserted replaced
10680:19692fc5c106 10683:2f0b7f1d5e75
484 end 484 end
485 end 485 end
486 486
487 local cleanup_time = module:measure("cleanup", "times"); 487 local cleanup_time = module:measure("cleanup", "times");
488 488
489 cleanup_runner = require "util.async".runner(function () 489 local async = require "util.async";
490 cleanup_runner = async.runner(function ()
490 local cleanup_done = cleanup_time(); 491 local cleanup_done = cleanup_time();
491 local rooms = {}; 492 local rooms = {};
492 local cut_off = datestamp(os.time() - cleanup_after); 493 local cut_off = datestamp(os.time() - cleanup_after);
493 for date in cleanup_storage:users() do 494 for date in cleanup_storage:users() do
494 if date <= cut_off then 495 if date <= cut_off then
514 sum = sum + (tonumber(ok) or 0); 515 sum = sum + (tonumber(ok) or 0);
515 else 516 else
516 cleanup_map:set(cut_off, room, true); 517 cleanup_map:set(cut_off, room, true);
517 module:log("error", "Could not delete messages for room '%s': %s", room, err); 518 module:log("error", "Could not delete messages for room '%s': %s", room, err);
518 end 519 end
520 local wait, done = async.waiter();
521 module:add_timer(0.01, done);
522 wait();
519 end 523 end
520 module:log("info", "Deleted %d expired messages for %d rooms", sum, num_rooms); 524 module:log("info", "Deleted %d expired messages for %d rooms", sum, num_rooms);
521 cleanup_done(); 525 cleanup_done();
522 end); 526 end);
523 527