# HG changeset patch # User Waqas Hussain # Date 1289231093 -18000 # Node ID bc3dfc00da5d23b60766bc470088d6f2756c0267 # Parent 1e088ec07d333922ab3261e95f315897efd08263 MUC: Allow restricting room creation to local JIDs (thanks thomas.mangin). diff -r 1e088ec07d33 -r bc3dfc00da5d plugins/muc/mod_muc.lua --- 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; });