comparison mod_muc_rtbl/mod_muc_rtbl.lua @ 5176:4791e0412ff3

mod_muc_rtbl: ignore blocklist for affiliated users for messages Just like we ignore the blocklist for join attempts from affiliated users, we also do that now on messages.
author Jonas Schäfer <jonas@wielicki.name>
date Wed, 22 Feb 2023 13:35:03 +0100
parents 432587ad1642
children f6b5f04d4b28
comparison
equal deleted inserted replaced
5175:432587ad1642 5176:4791e0412ff3
127 return true; 127 return true;
128 end 128 end
129 end); 129 end);
130 130
131 module:hook("muc-occupant-groupchat", function(event) 131 module:hook("muc-occupant-groupchat", function(event)
132 local affiliation = event.room:get_affiliation(event.occupant.bare_jid);
133 if affiliation and affiliation ~= "none" then
134 -- Skip check for affiliated users
135 return;
136 end
137
132 local bare_hash, host_hash = update_hashes(event.occupant); 138 local bare_hash, host_hash = update_hashes(event.occupant);
133 if banned_hashes[bare_hash] or banned_hashes[host_hash] then 139 if banned_hashes[bare_hash] or banned_hashes[host_hash] then
134 module:log("debug", "Blocked message from user <%s> to room <%s> due to RTBL match", event.stanza.attr.from, event.stanza.attr.to); 140 module:log("debug", "Blocked message from user <%s> to room <%s> due to RTBL match", event.stanza.attr.from, event.stanza.attr.to);
135 local error_reply = st.error_reply(event.stanza, "cancel", "forbidden", "You are banned from this service", event.room.jid); 141 local error_reply = st.error_reply(event.stanza, "cancel", "forbidden", "You are banned from this service", event.room.jid);
136 event.origin.send(error_reply); 142 event.origin.send(error_reply);
138 end 144 end
139 end); 145 end);
140 146
141 module:hook("muc-private-message", function(event) 147 module:hook("muc-private-message", function(event)
142 local occupant = event.room:get_occupant_by_nick(event.stanza.attr.from); 148 local occupant = event.room:get_occupant_by_nick(event.stanza.attr.from);
149 local affiliation = event.room:get_affiliation(event.occupant.bare_jid);
150 if affiliation and affiliation ~= "none" then
151 -- Skip check for affiliated users
152 return;
153 end
154
143 local bare_hash, host_hash = update_hashes(occupant); 155 local bare_hash, host_hash = update_hashes(occupant);
144 if banned_hashes[bare_hash] or banned_hashes[host_hash] then 156 if banned_hashes[bare_hash] or banned_hashes[host_hash] then
145 module:log("debug", "Blocked private message from user <%s> from room <%s> due to RTBL match", occupant.bare_jid, event.stanza.attr.to); 157 module:log("debug", "Blocked private message from user <%s> from room <%s> due to RTBL match", occupant.bare_jid, event.stanza.attr.to);
146 local error_reply = st.error_reply(event.stanza, "cancel", "forbidden", "You are banned from this service", event.room.jid); 158 local error_reply = st.error_reply(event.stanza, "cancel", "forbidden", "You are banned from this service", event.room.jid);
147 event.origin.send(error_reply); 159 event.origin.send(error_reply);