Software /
code /
prosody
Comparison
plugins/muc/mod_muc.lua @ 5808:026367992a0f
mod_muc: Support for locking newly-created rooms until they are configured (enabled with muc_room_locking = true)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 30 Aug 2013 14:15:29 +0100 |
parent | 5807:d7212bd61b60 |
child | 5939:56d81af64fc5 |
comparison
equal
deleted
inserted
replaced
5807:d7212bd61b60 | 5808:026367992a0f |
---|---|
21 restrict_room_creation = "admin"; | 21 restrict_room_creation = "admin"; |
22 elseif restrict_room_creation ~= "admin" and restrict_room_creation ~= "local" then | 22 elseif restrict_room_creation ~= "admin" and restrict_room_creation ~= "local" then |
23 restrict_room_creation = nil; | 23 restrict_room_creation = nil; |
24 end | 24 end |
25 end | 25 end |
26 local lock_rooms = module:get_option_boolean("muc_room_locking", false); | |
27 local lock_room_timeout = module:get_option_number("muc_room_lock_timeout", 300); | |
28 | |
26 local muclib = module:require "muc"; | 29 local muclib = module:require "muc"; |
27 local muc_new_room = muclib.new_room; | 30 local muc_new_room = muclib.new_room; |
28 local jid_split = require "util.jid".split; | 31 local jid_split = require "util.jid".split; |
29 local jid_bare = require "util.jid".bare; | 32 local jid_bare = require "util.jid".bare; |
30 local st = require "util.stanza"; | 33 local st = require "util.stanza"; |
86 function create_room(jid) | 89 function create_room(jid) |
87 local room = muc_new_room(jid); | 90 local room = muc_new_room(jid); |
88 room.route_stanza = room_route_stanza; | 91 room.route_stanza = room_route_stanza; |
89 room.save = room_save; | 92 room.save = room_save; |
90 rooms[jid] = room; | 93 rooms[jid] = room; |
94 if lock_rooms then | |
95 room.locked = true; | |
96 if lock_room_timeout and lock_room_timeout > 0 then | |
97 module:add_timer(lock_room_timeout, function () | |
98 if room.locked then | |
99 room:destroy(); -- Not unlocked in time | |
100 end | |
101 end); | |
102 end | |
103 end | |
91 module:fire_event("muc-room-created", { room = room }); | 104 module:fire_event("muc-room-created", { room = room }); |
92 return room; | 105 return room; |
93 end | 106 end |
94 | 107 |
95 local persistent_errors = false; | 108 local persistent_errors = false; |