aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/muc/lock.lib.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2016-04-28 23:20:41 +0200
committerKim Alvefur <zash@zash.se>2016-04-28 23:20:41 +0200
commitf32cebadb8c651d24ebc71d158a864fe2e861784 (patch)
tree51999c546febd2c2e0f32cd7a58f86c7c16fb3eb /plugins/muc/lock.lib.lua
parenteb916e9760459749556304aeb59a49f9ea4c4bba (diff)
downloadprosody-f32cebadb8c651d24ebc71d158a864fe2e861784.tar.gz
prosody-f32cebadb8c651d24ebc71d158a864fe2e861784.zip
MUC: Use a timestamp to keep track of when to unlock room instead of a timer (so timer does not unlock an evicted room)
Diffstat (limited to 'plugins/muc/lock.lib.lua')
-rw-r--r--plugins/muc/lock.lib.lua16
1 files changed, 7 insertions, 9 deletions
diff --git a/plugins/muc/lock.lib.lua b/plugins/muc/lock.lib.lua
index e316c57c..15dd624b 100644
--- a/plugins/muc/lock.lib.lua
+++ b/plugins/muc/lock.lib.lua
@@ -14,14 +14,19 @@ local lock_room_timeout = module:get_option_number("muc_room_lock_timeout", 300)
local function lock(room)
module:fire_event("muc-room-locked", {room = room;});
- room._data.locked = true;
+ room._data.locked = os.time() + lock_room_timeout;
end
local function unlock(room)
module:fire_event("muc-room-unlocked", {room = room;});
room._data.locked = nil;
end
local function is_locked(room)
- return not not room._data.locked;
+ local ts = room._data.locked or false;
+ if ts then
+ if ts < os.time() then return true; end
+ unlock(room);
+ end
+ return false;
end
if lock_rooms then
@@ -31,13 +36,6 @@ if lock_rooms then
-- Lock room at creation
local room = event.room;
lock(room);
- if lock_room_timeout and lock_room_timeout > 0 then
- module:add_timer(lock_room_timeout, function ()
- if is_locked(room) then
- room:destroy(); -- Not unlocked in time
- end
- end);
- end
end, 10);
end