Software /
code /
prosody
Comparison
plugins/muc/mod_muc.lua @ 6206:f937bb5c83c3
plugins/muc: Move locking to seperate module
author | daurnimator <quae@daurnimator.com> |
---|---|
date | Wed, 02 Apr 2014 15:48:25 -0400 |
parent | 6205:49dd381666f3 |
child | 6222:355b29881117 |
comparison
equal
deleted
inserted
replaced
6205:49dd381666f3 | 6206:f937bb5c83c3 |
---|---|
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 |
29 local muclib = module:require "muc"; | 27 local muclib = module:require "muc"; |
30 local muc_new_room = muclib.new_room; | 28 local muc_new_room = muclib.new_room; |
31 local jid_split = require "util.jid".split; | 29 local jid_split = require "util.jid".split; |
32 local jid_bare = require "util.jid".bare; | 30 local jid_bare = require "util.jid".bare; |
45 | 43 |
46 module:depends("disco"); | 44 module:depends("disco"); |
47 module:add_identity("conference", "text", muc_name); | 45 module:add_identity("conference", "text", muc_name); |
48 module:add_feature("http://jabber.org/protocol/muc"); | 46 module:add_feature("http://jabber.org/protocol/muc"); |
49 module:depends "muc_unique" | 47 module:depends "muc_unique" |
48 module:require "muc/lock"; | |
50 | 49 |
51 local function is_admin(jid) | 50 local function is_admin(jid) |
52 return um_is_admin(jid, module.host); | 51 return um_is_admin(jid, module.host); |
53 end | 52 end |
54 | 53 |
90 local room = muc_new_room(jid); | 89 local room = muc_new_room(jid); |
91 room.save = room_save; | 90 room.save = room_save; |
92 rooms[jid] = room; | 91 rooms[jid] = room; |
93 module:fire_event("muc-room-created", { room = room }); | 92 module:fire_event("muc-room-created", { room = room }); |
94 return room; | 93 return room; |
95 end | |
96 | |
97 if lock_rooms then | |
98 module:hook("muc-room-created", function(event) | |
99 local room = event.room; | |
100 room:lock(); | |
101 if lock_room_timeout and lock_room_timeout > 0 then | |
102 module:add_timer(lock_room_timeout, function () | |
103 if room:is_locked() then | |
104 room:destroy(); -- Not unlocked in time | |
105 end | |
106 end); | |
107 end | |
108 end); | |
109 end | 94 end |
110 | 95 |
111 function forget_room(jid) | 96 function forget_room(jid) |
112 rooms[jid] = nil; | 97 rooms[jid] = nil; |
113 end | 98 end |