comparison mod_muc_rtbl/mod_muc_rtbl.lua @ 4810:181738ae4117

mod_muc_rtbl: Skip check if user has any explicit affiliation with the MUC
author Matthew Wild <mwild1@gmail.com>
date Mon, 06 Dec 2021 12:24:07 +0000
parents 9e9ec0f0b128
children a1fe59c06c48
comparison
equal deleted inserted replaced
4809:9e9ec0f0b128 4810:181738ae4117
91 91
92 module:hook("iq-result/host/rtbl-request", update_list); 92 module:hook("iq-result/host/rtbl-request", update_list);
93 93
94 module:hook("muc-occupant-pre-join", function (event) 94 module:hook("muc-occupant-pre-join", function (event)
95 local from_bare = jid.bare(event.stanza.attr.from); 95 local from_bare = jid.bare(event.stanza.attr.from);
96
97 local affiliation = event.room:get_affiliation(from_bare);
98 if affiliation and affilition ~= "none" then
99 -- Skip check for affiliated users
100 return;
101 end
102
96 local hash = sha256(jid.bare(event.stanza.attr.from), true); 103 local hash = sha256(jid.bare(event.stanza.attr.from), true);
97 if banned_hashes[hash] then 104 if banned_hashes[hash] then
98 module:log("info", "Blocked user <%s> from room <%s> due to RTBL match", from_bare, event.stanza.attr.to); 105 module:log("info", "Blocked user <%s> from room <%s> due to RTBL match", from_bare, event.stanza.attr.to);
99 local error_reply = st.error_reply(event.stanza, "cancel", "forbidden", "You are banned from this service", event.room.jid); 106 local error_reply = st.error_reply(event.stanza, "cancel", "forbidden", "You are banned from this service", event.room.jid);
100 event.origin.send(error_reply); 107 event.origin.send(error_reply);