mod_c2s, mod_s2s: Set session.encrypted as session.secure does not allways mean encry...
[prosody.git] / plugins / muc / mod_muc.lua
index 6b4c70065125b88e08bff62dc07671e6ab4352e3..cb967c908a0f7b369ceee91183d642c498cbaf4a 100644 (file)
@@ -6,6 +6,7 @@
 -- 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);
@@ -22,6 +23,9 @@ if restrict_room_creation 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