plugins/muc/lock.lib: lock inside of pre-create instead of 'created'
authordaurnimator <quae@daurnimator.com>
Tue, 29 Apr 2014 18:50:30 -0400
changeset 6242 67efeadd9e77
parent 6241 6b4ff34dc8ea
child 6243 b7c95e9c13de
plugins/muc/lock.lib: lock inside of pre-create instead of 'created'
plugins/muc/lock.lib.lua
--- a/plugins/muc/lock.lib.lua	Tue Apr 29 17:18:14 2014 -0400
+++ b/plugins/muc/lock.lib.lua	Tue Apr 29 18:50:30 2014 -0400
@@ -23,7 +23,10 @@
 end
 
 if lock_rooms then
-	module:hook("muc-room-created", function(event)
+	module:hook("muc-room-pre-create", function(event)
+		-- Older groupchat protocol doesn't lock
+		if not event.stanza:get_child("x", "http://jabber.org/protocol/muc") then return end
+		-- Lock room at creation
 		local room = event.room;
 		lock(room);
 		if lock_room_timeout and lock_room_timeout > 0 then
@@ -33,16 +36,9 @@
 				end
 			end);
 		end
-	end);
+	end, 10);
 end
 
--- Older groupchat protocol doesn't lock
-module:hook("muc-room-pre-create", function(event)
-	if is_locked(event.room) and not event.stanza:get_child("x", "http://jabber.org/protocol/muc") then
-		unlock(event.room);
-	end
-end, 10);
-
 -- Don't let users into room while it is locked
 module:hook("muc-occupant-pre-join", function(event)
 	if not event.is_new_room and is_locked(event.room) then -- Deny entry