Mercurial > prosody-hg
comparison plugins/mod_muc_mam.lua @ 10030:98ef41a60fc3
Merge 0.11->trunk
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Mon, 27 May 2019 19:17:12 +0200 |
| parents | b56654f89cd5 2c8f674b9243 |
| children | 0f335815244f |
comparison
equal
deleted
inserted
replaced
| 10027:c0ee2ed8ef19 | 10030:98ef41a60fc3 |
|---|---|
| 456 | 456 |
| 457 -- For each day, store a set of rooms that have new messages. To expire | 457 -- For each day, store a set of rooms that have new messages. To expire |
| 458 -- messages, we collect the union of sets of rooms from dates that fall | 458 -- messages, we collect the union of sets of rooms from dates that fall |
| 459 -- outside the cleanup range. | 459 -- outside the cleanup range. |
| 460 | 460 |
| 461 local last_date = require "util.cache".new(module:get_option_number("muc_log_cleanup_date_cache_size", 1000)); | |
| 461 function schedule_cleanup(roomname, date) | 462 function schedule_cleanup(roomname, date) |
| 462 cleanup_map:set(date or datestamp(), roomname, true); | 463 date = date or datestamp(); |
| 464 if last_date:get(roomname) == date then return end | |
| 465 local ok = cleanup_map:set(date, roomname, true); | |
| 466 if ok then | |
| 467 last_date:set(roomname, date); | |
| 468 end | |
| 463 end | 469 end |
| 464 | 470 |
| 465 cleanup_runner = require "util.async".runner(function () | 471 cleanup_runner = require "util.async".runner(function () |
| 466 local rooms = {}; | 472 local rooms = {}; |
| 467 local cut_off = datestamp(os.time() - cleanup_after); | 473 local cut_off = datestamp(os.time() - cleanup_after); |
