MUC: Allow restricting room creation to local JIDs (thanks thomas.mangin).

Mon, 08 Nov 2010 20:44:53 +0500

author
Waqas Hussain <waqas20@gmail.com>
date
Mon, 08 Nov 2010 20:44:53 +0500
changeset 3575
bc3dfc00da5d
parent 3574
1e088ec07d33
child 3576
8d8ce17b83ca

MUC: Allow restricting room creation to local JIDs (thanks thomas.mangin).

plugins/muc/mod_muc.lua file | annotate | diff | comparison | revisions
--- a/plugins/muc/mod_muc.lua	Mon Nov 08 03:12:30 2010 +0000
+++ b/plugins/muc/mod_muc.lua	Mon Nov 08 20:44:53 2010 +0500
@@ -15,8 +15,13 @@
 local muc_name = module:get_option("name");
 if type(muc_name) ~= "string" then muc_name = "Prosody Chatrooms"; end
 local restrict_room_creation = module:get_option("restrict_room_creation");
-if restrict_room_creation and restrict_room_creation ~= true then restrict_room_creation = nil; end
-
+if restrict_room_creation then
+	if restrict_room_creation == true then 
+		restrict_room_creation = "admin";
+	elseif restrict_room_creation ~= "admin" and restrict_room_creation ~= "local" then
+		restrict_room_creation = nil;
+	end
+end
 local muc_new_room = module:require "muc".new_room;
 local register_component = require "core.componentmanager".register_component;
 local deregister_component = require "core.componentmanager".deregister_component;
@@ -121,7 +126,9 @@
 		if to_host == muc_host or bare == muc_host then
 			local room = rooms[bare];
 			if not room then
-				if not(restrict_room_creation) or is_admin(stanza.attr.from) then
+				if not(restrict_room_creation) or
+				  (restrict_room_creation == "admin" and is_admin(stanza.attr.from)) or
+				  (restrict_room_creation == "local" and select(2, jid_split(stanza.attr.from)) == module.host:gsub("^[^%.]+%.", "")) then
 					room = muc_new_room(bare, {
 						history_length = max_history_messages;
 					});

mercurial