Comparison

plugins/mod_muc_mam.lua @ 12977:74b9e05af71e

plugins: Prefix module imports with prosody namespace
author Kim Alvefur <zash@zash.se>
date Fri, 24 Mar 2023 13:15:28 +0100
parent 12861:57e86d537ffe
child 13213:50324f66ca2a
comparison
equal deleted inserted replaced
12976:a187600ec7d6 12977:74b9e05af71e
14 local xmlns_forward = "urn:xmpp:forward:0"; 14 local xmlns_forward = "urn:xmpp:forward:0";
15 local xmlns_st_id = "urn:xmpp:sid:0"; 15 local xmlns_st_id = "urn:xmpp:sid:0";
16 local xmlns_muc_user = "http://jabber.org/protocol/muc#user"; 16 local xmlns_muc_user = "http://jabber.org/protocol/muc#user";
17 local muc_form_enable = "muc#roomconfig_enablearchiving" 17 local muc_form_enable = "muc#roomconfig_enablearchiving"
18 18
19 local st = require "util.stanza"; 19 local st = require "prosody.util.stanza";
20 local rsm = require "util.rsm"; 20 local rsm = require "prosody.util.rsm";
21 local jid_bare = require "util.jid".bare; 21 local jid_bare = require "prosody.util.jid".bare;
22 local jid_split = require "util.jid".split; 22 local jid_split = require "prosody.util.jid".split;
23 local jid_prep = require "util.jid".prep; 23 local jid_prep = require "prosody.util.jid".prep;
24 local dataform = require "util.dataforms".new; 24 local dataform = require "prosody.util.dataforms".new;
25 local get_form_type = require "util.dataforms".get_type; 25 local get_form_type = require "prosody.util.dataforms".get_type;
26 26
27 local mod_muc = module:depends"muc"; 27 local mod_muc = module:depends"muc";
28 local get_room_from_jid = mod_muc.get_room_from_jid; 28 local get_room_from_jid = mod_muc.get_room_from_jid;
29 29
30 local is_stanza = st.is_stanza; 30 local is_stanza = st.is_stanza;
31 local tostring = tostring; 31 local tostring = tostring;
32 local time_now = require "util.time".now; 32 local time_now = require "prosody.util.time".now;
33 local m_min = math.min; 33 local m_min = math.min;
34 local timestamp, datestamp = import("util.datetime", "datetime", "date"); 34 local timestamp, datestamp = import("prosody.util.datetime", "datetime", "date");
35 local default_max_items, max_max_items = 20, module:get_option_number("max_archive_query_results", 50); 35 local default_max_items, max_max_items = 20, module:get_option_number("max_archive_query_results", 50);
36 36
37 local cleanup_after = module:get_option_string("muc_log_expires_after", "1w"); 37 local cleanup_after = module:get_option_string("muc_log_expires_after", "1w");
38 38
39 local default_history_length = 20; 39 local default_history_length = 20;
490 490
491 -- For each day, store a set of rooms that have new messages. To expire 491 -- For each day, store a set of rooms that have new messages. To expire
492 -- messages, we collect the union of sets of rooms from dates that fall 492 -- messages, we collect the union of sets of rooms from dates that fall
493 -- outside the cleanup range. 493 -- outside the cleanup range.
494 494
495 local last_date = require "util.cache".new(module:get_option_number("muc_log_cleanup_date_cache_size", 1000)); 495 local last_date = require "prosody.util.cache".new(module:get_option_number("muc_log_cleanup_date_cache_size", 1000));
496 if not ( archive.caps and archive.caps.wildcard_delete ) then 496 if not ( archive.caps and archive.caps.wildcard_delete ) then
497 function schedule_cleanup(roomname, date) 497 function schedule_cleanup(roomname, date)
498 date = date or datestamp(); 498 date = date or datestamp();
499 if last_date:get(roomname) == date then return end 499 if last_date:get(roomname) == date then return end
500 local ok = cleanup_map:set(date, roomname, true); 500 local ok = cleanup_map:set(date, roomname, true);
504 end 504 end
505 end 505 end
506 506
507 local cleanup_time = module:measure("cleanup", "times"); 507 local cleanup_time = module:measure("cleanup", "times");
508 508
509 local async = require "util.async"; 509 local async = require "prosody.util.async";
510 module:daily("Remove expired messages", function () 510 module:daily("Remove expired messages", function ()
511 local cleanup_done = cleanup_time(); 511 local cleanup_done = cleanup_time();
512 512
513 if archive.caps and archive.caps.wildcard_delete then 513 if archive.caps and archive.caps.wildcard_delete then
514 local ok, err = archive:delete(true, { ["end"] = os.time() - cleanup_after }) 514 local ok, err = archive:delete(true, { ["end"] = os.time() - cleanup_after })