comparison plugins/mod_blocklist.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
parents 1dd468c63a3d
children 50324f66ca2a
comparison
equal deleted inserted replaced
12976:a187600ec7d6 12977:74b9e05af71e
7 -- COPYING file in the source package for more information. 7 -- COPYING file in the source package for more information.
8 -- 8 --
9 -- This module implements XEP-0191: Blocking Command 9 -- This module implements XEP-0191: Blocking Command
10 -- 10 --
11 11
12 local user_exists = require"core.usermanager".user_exists; 12 local user_exists = require"prosody.core.usermanager".user_exists;
13 local rostermanager = require"core.rostermanager"; 13 local rostermanager = require"prosody.core.rostermanager";
14 local is_contact_subscribed = rostermanager.is_contact_subscribed; 14 local is_contact_subscribed = rostermanager.is_contact_subscribed;
15 local is_contact_pending_in = rostermanager.is_contact_pending_in; 15 local is_contact_pending_in = rostermanager.is_contact_pending_in;
16 local load_roster = rostermanager.load_roster; 16 local load_roster = rostermanager.load_roster;
17 local save_roster = rostermanager.save_roster; 17 local save_roster = rostermanager.save_roster;
18 local st = require"util.stanza"; 18 local st = require"prosody.util.stanza";
19 local st_error_reply = st.error_reply; 19 local st_error_reply = st.error_reply;
20 local jid_prep = require"util.jid".prep; 20 local jid_prep = require"prosody.util.jid".prep;
21 local jid_split = require"util.jid".split; 21 local jid_split = require"prosody.util.jid".split;
22 22
23 local storage = module:open_store(); 23 local storage = module:open_store();
24 local sessions = prosody.hosts[module.host].sessions; 24 local sessions = prosody.hosts[module.host].sessions;
25 local full_sessions = prosody.full_sessions; 25 local full_sessions = prosody.full_sessions;
26 26
34 -- The size of this affects how often we will need to load a blocklist from 34 -- The size of this affects how often we will need to load a blocklist from
35 -- disk, which we want to avoid during routing. On the other hand, we don't 35 -- disk, which we want to avoid during routing. On the other hand, we don't
36 -- want to use too much memory either, so this can be tuned by advanced 36 -- want to use too much memory either, so this can be tuned by advanced
37 -- users. TODO use science to figure out a better default, 64 is just a guess. 37 -- users. TODO use science to figure out a better default, 64 is just a guess.
38 local cache_size = module:get_option_number("blocklist_cache_size", 64); 38 local cache_size = module:get_option_number("blocklist_cache_size", 64);
39 local cache2 = require"util.cache".new(cache_size); 39 local cache2 = require"prosody.util.cache".new(cache_size);
40 40
41 local null_blocklist = {}; 41 local null_blocklist = {};
42 42
43 module:add_feature("urn:xmpp:blocking"); 43 module:add_feature("urn:xmpp:blocking");
44 44