# HG changeset patch # User Frank Doepper # Date 1527001983 -3600 # Node ID f54c80404ad30e050f6799eb859bc95443450dfd # Parent 38365c1f1fe44e2193fda4295a99ad3cb67fcc72 mod_muc_access_control: Multiple fixes to make the module work (fixes #1086) diff -r 38365c1f1fe4 -r f54c80404ad3 mod_muc_access_control/mod_muc_access_control.lua --- a/mod_muc_access_control/mod_muc_access_control.lua Tue May 22 14:20:23 2018 +0100 +++ b/mod_muc_access_control/mod_muc_access_control.lua Tue May 22 16:13:03 2018 +0100 @@ -13,13 +13,14 @@ else local prepped_list = {}; for _, unprepped_jid in ipairs(unprepped_list) do - local prepped_jid = jid.prep(jid); + local prepped_jid = jid.prep(unprepped_jid); if not prepped_jid then module:log("error", "Invalid JID: %s", unprepped_jid); else - table.insert(prepped_list, jid.pep(jid)); + prepped_list[prepped_jid] = true; end end + access_lists[prepped_room_name] = prepped_list; end end @@ -34,11 +35,11 @@ end module:hook("presence/full", function(event) - local stanza = event.stanza; + local stanza = event.stanza; - if stanza.name == "presence" and stanza.attr.type == "unavailable" then -- Leaving events get discarded - return; - end + if stanza.name == "presence" and stanza.attr.type == "unavailable" then -- Leaving events get discarded + return; + end -- Get the room local room = jid.split(stanza.attr.to); @@ -49,9 +50,9 @@ -- Checking whether room is restricted local check_restricted = is_restricted(room, who) - if check_restricted ~= nil then - event.allowed = false; - event.stanza.attr.type = 'error'; - return event.origin.send(st.error_reply(event.stanza, "cancel", "forbidden", "You're not allowed to enter this room: " .. check_restricted)); - end + if check_restricted ~= nil then + event.allowed = false; + event.stanza.attr.type = 'error'; + return event.origin.send(st.error_reply(event.stanza, "cancel", "forbidden", "You're not allowed to enter this room: " .. check_restricted)); + end end, 10);