mod_c2s, mod_s2s: Set session.encrypted as session.secure does not allways mean encry...
[prosody.git] / plugins / muc / mod_muc.lua
index a9480465c0417adf5c3f043b03ee2c9c6936393c..cb967c908a0f7b369ceee91183d642c498cbaf4a 100644 (file)
@@ -1,11 +1,12 @@
 -- Prosody IM
 -- Copyright (C) 2008-2010 Matthew Wild
 -- Copyright (C) 2008-2010 Waqas Hussain
--- 
+--
 -- This project is MIT/X11 licensed. Please see the
 -- COPYING file in the source package for more information.
 --
 
+local array = require "util.array";
 
 if module:get_host_type() ~= "component" then
        error("MUC should be loaded as a component, please see http://prosody.im/doc/components", 0);
@@ -16,12 +17,15 @@ 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 then
-       if restrict_room_creation == true 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 lock_rooms = module:get_option_boolean("muc_room_locking", false);
+local lock_room_timeout = module:get_option_number("muc_room_lock_timeout", 300);
+
 local muclib = module:require "muc";
 local muc_new_room = muclib.new_room;
 local jid_split = require "util.jid".split;
@@ -87,6 +91,16 @@ function create_room(jid)
        room.route_stanza = room_route_stanza;
        room.save = room_save;
        rooms[jid] = room;
+       if lock_rooms then
+               room.locked = true;
+               if lock_room_timeout and lock_room_timeout > 0 then
+                       module:add_timer(lock_room_timeout, function ()
+                               if room.locked then
+                                       room:destroy(); -- Not unlocked in time
+                               end
+                       end);
+               end
+       end
        module:fire_event("muc-room-created", { room = room });
        return room;
 end