Software /
code /
prosody
Changeset
3575:bc3dfc00da5d
MUC: Allow restricting room creation to local JIDs (thanks thomas.mangin).
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Mon, 08 Nov 2010 20:44:53 +0500 |
parents | 3574:1e088ec07d33 |
children | 3576:8d8ce17b83ca |
files | plugins/muc/mod_muc.lua |
diffstat | 1 files changed, 10 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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; });