Mercurial > prosody-modules
annotate mod_muc_rtbl/mod_muc_rtbl.lua @ 6319:04c3273cb81f
mod_auth_cyrus: Add empty 'profile' table to SASL handler objects
This is for compatibility with Prosody's built-in util.sasl objects.
A SASL profile table usually includes methods supported by the backend, which
can be used by SASL mechanism handlers to perform operations (such as testing
the password). It also optionally contains a 'cb' field with channel binding
method handlers.
The Cyrus backend doesn't support channel binding, and doesn't have the same
concept of auth backend methods (it handles all that internally, and Prosody
has no insight or control over it).
Thus, we create an empty profile which informs Prosody that the SASL handler
does not support any of the auth or channel binding methods. Some features
will not work, but they didn't work anyway. This just makes it explicit.
This fixes a traceback in mod_sasl2_fast, which expected SASL handlers to
always contain a 'profile' field.
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Thu, 04 Sep 2025 10:14:46 +0100 |
| parents | 093c47ee2041 |
| children |
| rev | line source |
|---|---|
|
4807
62a65c52c3f5
mod_muc_rtbl: Real-time blocklist checks for MUC services
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 local jid = require "util.jid"; |
|
62a65c52c3f5
mod_muc_rtbl: Real-time blocklist checks for MUC services
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2 local sha256 = require "util.hashes".sha256; |
|
62a65c52c3f5
mod_muc_rtbl: Real-time blocklist checks for MUC services
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 local st = require "util.stanza"; |
|
62a65c52c3f5
mod_muc_rtbl: Real-time blocklist checks for MUC services
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4 |
|
6304
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
5 local url = require "socket.url"; |
|
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
6 |
|
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
7 -- Legacy config (single list only) |
|
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
8 local rtbl_service_jid = module:get_option_string("muc_rtbl_jid"); |
|
4807
62a65c52c3f5
mod_muc_rtbl: Real-time blocklist checks for MUC services
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 local rtbl_node = module:get_option_string("muc_rtbl_node", "muc_bans_sha256"); |
|
62a65c52c3f5
mod_muc_rtbl: Real-time blocklist checks for MUC services
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 |
|
6304
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
11 -- Multi-list config |
|
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
12 local rtbl_config = module:get_option_array("muc_rtbls", { |
|
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
13 rtbl_service_jid and rtbl_node and ("xmpp:"..rtbl_service_jid.."?;node="..rtbl_node) or nil; |
|
4807
62a65c52c3f5
mod_muc_rtbl: Real-time blocklist checks for MUC services
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 }); |
|
62a65c52c3f5
mod_muc_rtbl: Real-time blocklist checks for MUC services
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
15 |
|
6304
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
16 if #rtbl_config == 0 then |
|
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
17 return error("No RTBLs configured"); |
|
4808
8a63a0daf129
mod_muc_rtbl: Sync existing list entries when first loaded
Matthew Wild <mwild1@gmail.com>
parents:
4807
diff
changeset
|
18 end |
|
8a63a0daf129
mod_muc_rtbl: Sync existing list entries when first loaded
Matthew Wild <mwild1@gmail.com>
parents:
4807
diff
changeset
|
19 |
|
6304
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
20 local mod_rtbl = module:depends("rtbl"); |
|
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
21 |
|
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
22 local lists = {}; |
|
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
23 |
|
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
24 local function parse_xmpp_uri(uri) |
|
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
25 local parsed = url.parse(uri); |
|
6306
093c47ee2041
mod_muc_rtbl: Simplify configuration and tweak docs
Matthew Wild <mwild1@gmail.com>
parents:
6304
diff
changeset
|
26 if parsed.scheme and parsed.scheme ~= "xmpp" then |
|
6304
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
27 return nil, "unexpected-scheme"; |
|
4808
8a63a0daf129
mod_muc_rtbl: Sync existing list entries when first loaded
Matthew Wild <mwild1@gmail.com>
parents:
4807
diff
changeset
|
28 end |
|
8a63a0daf129
mod_muc_rtbl: Sync existing list entries when first loaded
Matthew Wild <mwild1@gmail.com>
parents:
4807
diff
changeset
|
29 |
|
6304
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
30 local parsed_query = {}; |
|
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
31 for kv in (parsed.query or ""):gmatch("[^?;]+") do |
|
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
32 local k, v = kv:match("^([^=]+)=?(.*)$"); |
|
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
33 parsed_query[k] = v; |
|
4808
8a63a0daf129
mod_muc_rtbl: Sync existing list entries when first loaded
Matthew Wild <mwild1@gmail.com>
parents:
4807
diff
changeset
|
34 end |
|
8a63a0daf129
mod_muc_rtbl: Sync existing list entries when first loaded
Matthew Wild <mwild1@gmail.com>
parents:
4807
diff
changeset
|
35 |
|
6304
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
36 return { |
|
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
37 jid = jid.prep(parsed.path); |
|
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
38 params = parsed_query; |
|
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
39 }; |
|
4808
8a63a0daf129
mod_muc_rtbl: Sync existing list entries when first loaded
Matthew Wild <mwild1@gmail.com>
parents:
4807
diff
changeset
|
40 end |
|
8a63a0daf129
mod_muc_rtbl: Sync existing list entries when first loaded
Matthew Wild <mwild1@gmail.com>
parents:
4807
diff
changeset
|
41 |
|
6304
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
42 for _, rtbl_uri in ipairs(rtbl_config) do |
|
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
43 local uri = parse_xmpp_uri(rtbl_uri); |
|
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
44 module:log("debug", "Subscribing to %q node %q", uri.jid, uri.params.node); |
|
6306
093c47ee2041
mod_muc_rtbl: Simplify configuration and tweak docs
Matthew Wild <mwild1@gmail.com>
parents:
6304
diff
changeset
|
45 local rtbl = mod_rtbl.new_rtbl_subscription(uri.jid, uri.params.node or "muc_bans_sha256", {}); |
|
6304
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
46 table.insert(lists, rtbl); |
|
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
47 end |
|
4808
8a63a0daf129
mod_muc_rtbl: Sync existing list entries when first loaded
Matthew Wild <mwild1@gmail.com>
parents:
4807
diff
changeset
|
48 |
|
6304
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
49 local function update_occupant_hashes(occupant) |
|
5174
354832098f2f
mod_muc_rtbl: move use of "private" attributes to single function
Jonas Schäfer <jonas@wielicki.name>
parents:
5173
diff
changeset
|
50 local bare_hash, host_hash; |
|
5173
460f78654864
mod_muc_rtbl: also filter messages
Jonas Schäfer <jonas@wielicki.name>
parents:
4813
diff
changeset
|
51 if not occupant.mod_muc_rtbl_bare_hash then |
|
5175
432587ad1642
mod_muc_rtbl: fix traceback because of scoping error
Jonas Schäfer <jonas@wielicki.name>
parents:
5174
diff
changeset
|
52 bare_hash = sha256(jid.bare(occupant.bare_jid), true); |
|
5173
460f78654864
mod_muc_rtbl: also filter messages
Jonas Schäfer <jonas@wielicki.name>
parents:
4813
diff
changeset
|
53 occupant.mod_muc_rtbl_bare_hash = bare_hash; |
|
5174
354832098f2f
mod_muc_rtbl: move use of "private" attributes to single function
Jonas Schäfer <jonas@wielicki.name>
parents:
5173
diff
changeset
|
54 else |
|
354832098f2f
mod_muc_rtbl: move use of "private" attributes to single function
Jonas Schäfer <jonas@wielicki.name>
parents:
5173
diff
changeset
|
55 bare_hash = occupant.mod_muc_rtbl_bare_hash; |
|
5173
460f78654864
mod_muc_rtbl: also filter messages
Jonas Schäfer <jonas@wielicki.name>
parents:
4813
diff
changeset
|
56 end |
|
460f78654864
mod_muc_rtbl: also filter messages
Jonas Schäfer <jonas@wielicki.name>
parents:
4813
diff
changeset
|
57 if not occupant.mod_muc_rtbl_host_hash then |
|
5175
432587ad1642
mod_muc_rtbl: fix traceback because of scoping error
Jonas Schäfer <jonas@wielicki.name>
parents:
5174
diff
changeset
|
58 host_hash = sha256(jid.host(occupant.bare_jid), true); |
|
5177
f6b5f04d4b28
mod_muc_rtbl: fix more incorrect more references to "event"
Jonas Schäfer <jonas@wielicki.name>
parents:
5176
diff
changeset
|
59 occupant.mod_muc_rtbl_host_hash = host_hash; |
|
5174
354832098f2f
mod_muc_rtbl: move use of "private" attributes to single function
Jonas Schäfer <jonas@wielicki.name>
parents:
5173
diff
changeset
|
60 else |
|
5177
f6b5f04d4b28
mod_muc_rtbl: fix more incorrect more references to "event"
Jonas Schäfer <jonas@wielicki.name>
parents:
5176
diff
changeset
|
61 host_hash = occupant.mod_muc_rtbl_host_hash; |
|
5173
460f78654864
mod_muc_rtbl: also filter messages
Jonas Schäfer <jonas@wielicki.name>
parents:
4813
diff
changeset
|
62 end |
|
6304
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
63 return bare_hash, host_hash; |
|
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
64 end |
|
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
65 |
|
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
66 local function is_banned_occupant(occupant) |
|
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
67 local bare_hash, host_hash = update_occupant_hashes(occupant); |
|
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
68 for _, list in ipairs(lists) do |
|
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
69 local items = list.items; |
|
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
70 if items[bare_hash] or items[host_hash] then |
|
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
71 return true; |
|
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
72 end |
|
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
73 end |
|
5173
460f78654864
mod_muc_rtbl: also filter messages
Jonas Schäfer <jonas@wielicki.name>
parents:
4813
diff
changeset
|
74 end |
|
460f78654864
mod_muc_rtbl: also filter messages
Jonas Schäfer <jonas@wielicki.name>
parents:
4813
diff
changeset
|
75 |
|
4807
62a65c52c3f5
mod_muc_rtbl: Real-time blocklist checks for MUC services
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
76 module:hook("muc-occupant-pre-join", function (event) |
|
62a65c52c3f5
mod_muc_rtbl: Real-time blocklist checks for MUC services
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
77 local from_bare = jid.bare(event.stanza.attr.from); |
|
4810
181738ae4117
mod_muc_rtbl: Skip check if user has any explicit affiliation with the MUC
Matthew Wild <mwild1@gmail.com>
parents:
4809
diff
changeset
|
78 |
|
181738ae4117
mod_muc_rtbl: Skip check if user has any explicit affiliation with the MUC
Matthew Wild <mwild1@gmail.com>
parents:
4809
diff
changeset
|
79 local affiliation = event.room:get_affiliation(from_bare); |
|
4811
a1fe59c06c48
mod_muc_rtbl: Fix typo in variable name in previous commit (thanks luacheck)
Matthew Wild <mwild1@gmail.com>
parents:
4810
diff
changeset
|
80 if affiliation and affiliation ~= "none" then |
|
4810
181738ae4117
mod_muc_rtbl: Skip check if user has any explicit affiliation with the MUC
Matthew Wild <mwild1@gmail.com>
parents:
4809
diff
changeset
|
81 -- Skip check for affiliated users |
|
181738ae4117
mod_muc_rtbl: Skip check if user has any explicit affiliation with the MUC
Matthew Wild <mwild1@gmail.com>
parents:
4809
diff
changeset
|
82 return; |
|
181738ae4117
mod_muc_rtbl: Skip check if user has any explicit affiliation with the MUC
Matthew Wild <mwild1@gmail.com>
parents:
4809
diff
changeset
|
83 end |
|
181738ae4117
mod_muc_rtbl: Skip check if user has any explicit affiliation with the MUC
Matthew Wild <mwild1@gmail.com>
parents:
4809
diff
changeset
|
84 |
|
6304
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
85 if is_banned_occupant(event.occupant) then |
|
4807
62a65c52c3f5
mod_muc_rtbl: Real-time blocklist checks for MUC services
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
86 module:log("info", "Blocked user <%s> from room <%s> due to RTBL match", from_bare, event.stanza.attr.to); |
|
62a65c52c3f5
mod_muc_rtbl: Real-time blocklist checks for MUC services
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
87 local error_reply = st.error_reply(event.stanza, "cancel", "forbidden", "You are banned from this service", event.room.jid); |
|
62a65c52c3f5
mod_muc_rtbl: Real-time blocklist checks for MUC services
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
88 event.origin.send(error_reply); |
|
62a65c52c3f5
mod_muc_rtbl: Real-time blocklist checks for MUC services
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
89 return true; |
|
62a65c52c3f5
mod_muc_rtbl: Real-time blocklist checks for MUC services
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
90 end |
|
62a65c52c3f5
mod_muc_rtbl: Real-time blocklist checks for MUC services
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
91 end); |
|
4808
8a63a0daf129
mod_muc_rtbl: Sync existing list entries when first loaded
Matthew Wild <mwild1@gmail.com>
parents:
4807
diff
changeset
|
92 |
|
5173
460f78654864
mod_muc_rtbl: also filter messages
Jonas Schäfer <jonas@wielicki.name>
parents:
4813
diff
changeset
|
93 module:hook("muc-occupant-groupchat", function(event) |
|
6304
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
94 local occupant = event.occupant; |
|
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
95 local affiliation = event.room:get_affiliation(occupant.bare_jid); |
|
5176
4791e0412ff3
mod_muc_rtbl: ignore blocklist for affiliated users for messages
Jonas Schäfer <jonas@wielicki.name>
parents:
5175
diff
changeset
|
96 if affiliation and affiliation ~= "none" then |
|
4791e0412ff3
mod_muc_rtbl: ignore blocklist for affiliated users for messages
Jonas Schäfer <jonas@wielicki.name>
parents:
5175
diff
changeset
|
97 -- Skip check for affiliated users |
|
4791e0412ff3
mod_muc_rtbl: ignore blocklist for affiliated users for messages
Jonas Schäfer <jonas@wielicki.name>
parents:
5175
diff
changeset
|
98 return; |
|
4791e0412ff3
mod_muc_rtbl: ignore blocklist for affiliated users for messages
Jonas Schäfer <jonas@wielicki.name>
parents:
5175
diff
changeset
|
99 end |
|
4791e0412ff3
mod_muc_rtbl: ignore blocklist for affiliated users for messages
Jonas Schäfer <jonas@wielicki.name>
parents:
5175
diff
changeset
|
100 |
|
6304
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
101 if is_banned_occupant(occupant) then |
|
5173
460f78654864
mod_muc_rtbl: also filter messages
Jonas Schäfer <jonas@wielicki.name>
parents:
4813
diff
changeset
|
102 module:log("debug", "Blocked message from user <%s> to room <%s> due to RTBL match", event.stanza.attr.from, event.stanza.attr.to); |
|
460f78654864
mod_muc_rtbl: also filter messages
Jonas Schäfer <jonas@wielicki.name>
parents:
4813
diff
changeset
|
103 local error_reply = st.error_reply(event.stanza, "cancel", "forbidden", "You are banned from this service", event.room.jid); |
|
460f78654864
mod_muc_rtbl: also filter messages
Jonas Schäfer <jonas@wielicki.name>
parents:
4813
diff
changeset
|
104 event.origin.send(error_reply); |
|
460f78654864
mod_muc_rtbl: also filter messages
Jonas Schäfer <jonas@wielicki.name>
parents:
4813
diff
changeset
|
105 return true; |
|
460f78654864
mod_muc_rtbl: also filter messages
Jonas Schäfer <jonas@wielicki.name>
parents:
4813
diff
changeset
|
106 end |
|
460f78654864
mod_muc_rtbl: also filter messages
Jonas Schäfer <jonas@wielicki.name>
parents:
4813
diff
changeset
|
107 end); |
|
460f78654864
mod_muc_rtbl: also filter messages
Jonas Schäfer <jonas@wielicki.name>
parents:
4813
diff
changeset
|
108 |
|
460f78654864
mod_muc_rtbl: also filter messages
Jonas Schäfer <jonas@wielicki.name>
parents:
4813
diff
changeset
|
109 module:hook("muc-private-message", function(event) |
|
460f78654864
mod_muc_rtbl: also filter messages
Jonas Schäfer <jonas@wielicki.name>
parents:
4813
diff
changeset
|
110 local occupant = event.room:get_occupant_by_nick(event.stanza.attr.from); |
|
5352
f6577cdb1d91
mod_muc_rtbl: Use correct occupant object
Matthew Wild <mwild1@gmail.com>
parents:
5274
diff
changeset
|
111 local affiliation = event.room:get_affiliation(occupant.bare_jid); |
|
5176
4791e0412ff3
mod_muc_rtbl: ignore blocklist for affiliated users for messages
Jonas Schäfer <jonas@wielicki.name>
parents:
5175
diff
changeset
|
112 if affiliation and affiliation ~= "none" then |
|
4791e0412ff3
mod_muc_rtbl: ignore blocklist for affiliated users for messages
Jonas Schäfer <jonas@wielicki.name>
parents:
5175
diff
changeset
|
113 -- Skip check for affiliated users |
|
4791e0412ff3
mod_muc_rtbl: ignore blocklist for affiliated users for messages
Jonas Schäfer <jonas@wielicki.name>
parents:
5175
diff
changeset
|
114 return; |
|
4791e0412ff3
mod_muc_rtbl: ignore blocklist for affiliated users for messages
Jonas Schäfer <jonas@wielicki.name>
parents:
5175
diff
changeset
|
115 end |
|
4791e0412ff3
mod_muc_rtbl: ignore blocklist for affiliated users for messages
Jonas Schäfer <jonas@wielicki.name>
parents:
5175
diff
changeset
|
116 |
|
6304
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
117 if is_banned_occupant(occupant) then |
|
5173
460f78654864
mod_muc_rtbl: also filter messages
Jonas Schäfer <jonas@wielicki.name>
parents:
4813
diff
changeset
|
118 module:log("debug", "Blocked private message from user <%s> from room <%s> due to RTBL match", occupant.bare_jid, event.stanza.attr.to); |
|
460f78654864
mod_muc_rtbl: also filter messages
Jonas Schäfer <jonas@wielicki.name>
parents:
4813
diff
changeset
|
119 local error_reply = st.error_reply(event.stanza, "cancel", "forbidden", "You are banned from this service", event.room.jid); |
|
460f78654864
mod_muc_rtbl: also filter messages
Jonas Schäfer <jonas@wielicki.name>
parents:
4813
diff
changeset
|
120 event.origin.send(error_reply); |
|
5890
ba71fdc8ea73
mod_muc_rtbl: Fix blocking of PMs from RTBL matches
Matthew Wild <mwild1@gmail.com>
parents:
5352
diff
changeset
|
121 return false; -- Don't route it |
|
5173
460f78654864
mod_muc_rtbl: also filter messages
Jonas Schäfer <jonas@wielicki.name>
parents:
4813
diff
changeset
|
122 end |
|
460f78654864
mod_muc_rtbl: also filter messages
Jonas Schäfer <jonas@wielicki.name>
parents:
4813
diff
changeset
|
123 end); |
|
460f78654864
mod_muc_rtbl: also filter messages
Jonas Schäfer <jonas@wielicki.name>
parents:
4813
diff
changeset
|
124 |
|
6304
6e2458b69e33
mod_muc_rtbl: Use mod_rtbl, adds support for multiple list subscriptions
Matthew Wild <mwild1@gmail.com>
parents:
5890
diff
changeset
|
125 module.environment.lists = lists |
