aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/muc/mod_muc.lua
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2010-11-08 20:44:53 +0500
committerWaqas Hussain <waqas20@gmail.com>2010-11-08 20:44:53 +0500
commiteadfb06d3b586a61451d17cdb7bd35290aede129 (patch)
tree7061a7b8cde3b273df2d403cfe73195a675e15cf /plugins/muc/mod_muc.lua
parent8e91da96f84888ec6d2840ce0e3b139139e4f6d5 (diff)
downloadprosody-eadfb06d3b586a61451d17cdb7bd35290aede129.tar.gz
prosody-eadfb06d3b586a61451d17cdb7bd35290aede129.zip
MUC: Allow restricting room creation to local JIDs (thanks thomas.mangin).
Diffstat (limited to 'plugins/muc/mod_muc.lua')
-rw-r--r--plugins/muc/mod_muc.lua13
1 files changed, 10 insertions, 3 deletions
diff --git a/plugins/muc/mod_muc.lua b/plugins/muc/mod_muc.lua
index b58f8bd0..f1d3b24f 100644
--- a/plugins/muc/mod_muc.lua
+++ b/plugins/muc/mod_muc.lua
@@ -15,8 +15,13 @@ local muc_host = module:get_host();
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 @@ function stanza_handler(event)
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;
});