Changeset

3024:f54c80404ad3

mod_muc_access_control: Multiple fixes to make the module work (fixes #1086)
author Frank Doepper <prosody@woffs.de>
date Tue, 22 May 2018 16:13:03 +0100
parents 3023:38365c1f1fe4
children 3025:5b8983e100da
files mod_muc_access_control/mod_muc_access_control.lua
diffstat 1 files changed, 12 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- 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);