Software /
code /
prosody
Comparison
plugins/muc/mod_muc.lua @ 6205:49dd381666f3
plugins/muc/mod_muc: Move room locking into hook
author | daurnimator <quae@daurnimator.com> |
---|---|
date | Wed, 02 Apr 2014 15:36:08 -0400 |
parent | 6179:e488a90195bc |
child | 6206:f937bb5c83c3 |
comparison
equal
deleted
inserted
replaced
6204:c3254827698d | 6205:49dd381666f3 |
---|---|
88 | 88 |
89 function create_room(jid) | 89 function create_room(jid) |
90 local room = muc_new_room(jid); | 90 local room = muc_new_room(jid); |
91 room.save = room_save; | 91 room.save = room_save; |
92 rooms[jid] = room; | 92 rooms[jid] = room; |
93 if lock_rooms then | 93 module:fire_event("muc-room-created", { room = room }); |
94 return room; | |
95 end | |
96 | |
97 if lock_rooms then | |
98 module:hook("muc-room-created", function(event) | |
99 local room = event.room; | |
94 room:lock(); | 100 room:lock(); |
95 if lock_room_timeout and lock_room_timeout > 0 then | 101 if lock_room_timeout and lock_room_timeout > 0 then |
96 module:add_timer(lock_room_timeout, function () | 102 module:add_timer(lock_room_timeout, function () |
97 if room:is_locked() then | 103 if room:is_locked() then |
98 room:destroy(); -- Not unlocked in time | 104 room:destroy(); -- Not unlocked in time |
99 end | 105 end |
100 end); | 106 end); |
101 end | 107 end |
102 end | 108 end); |
103 module:fire_event("muc-room-created", { room = room }); | |
104 return room; | |
105 end | 109 end |
106 | 110 |
107 function forget_room(jid) | 111 function forget_room(jid) |
108 rooms[jid] = nil; | 112 rooms[jid] = nil; |
109 end | 113 end |