Software /
code /
prosody
Comparison
plugins/muc/mod_muc.lua @ 8025:8a7c4497569a
MUC: Only create rooms in a locked state when they are created by someone joining (fixes timed deletion of all rooms on startup)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 31 Mar 2017 18:52:53 +0200 |
parent | 7746:3dff38ffdcd0 |
child | 8026:f237d0155e59 |
child | 8702:7e7aa0f770c7 |
comparison
equal
deleted
inserted
replaced
8024:8eec715c13a6 | 8025:8a7c4497569a |
---|---|
84 end | 84 end |
85 end | 85 end |
86 if forced then persistent_rooms_storage:set(nil, persistent_rooms); end | 86 if forced then persistent_rooms_storage:set(nil, persistent_rooms); end |
87 end | 87 end |
88 | 88 |
89 function create_room(jid) | 89 function create_room(jid, locked) |
90 local room = muc_new_room(jid); | 90 local room = muc_new_room(jid); |
91 room.route_stanza = room_route_stanza; | 91 room.route_stanza = room_route_stanza; |
92 room.save = room_save; | 92 room.save = room_save; |
93 rooms[jid] = room; | 93 rooms[jid] = room; |
94 if lock_rooms then | 94 if locked then |
95 room.locked = true; | 95 room.locked = true; |
96 if lock_room_timeout and lock_room_timeout > 0 then | 96 if lock_room_timeout and lock_room_timeout > 0 then |
97 module:add_timer(lock_room_timeout, function () | 97 module:add_timer(lock_room_timeout, function () |
98 if room.locked then | 98 if room.locked then |
99 room:destroy(); -- Not unlocked in time | 99 room:destroy(); -- Not unlocked in time |
164 return true; | 164 return true; |
165 end | 165 end |
166 if not(restrict_room_creation) or | 166 if not(restrict_room_creation) or |
167 is_admin(stanza.attr.from) or | 167 is_admin(stanza.attr.from) or |
168 (restrict_room_creation == "local" and select(2, jid_split(stanza.attr.from)) == module.host:gsub("^[^%.]+%.", "")) then | 168 (restrict_room_creation == "local" and select(2, jid_split(stanza.attr.from)) == module.host:gsub("^[^%.]+%.", "")) then |
169 room = create_room(bare); | 169 room = create_room(bare, lock_rooms); |
170 end | 170 end |
171 end | 171 end |
172 if room then | 172 if room then |
173 room:handle_stanza(origin, stanza); | 173 room:handle_stanza(origin, stanza); |
174 if not next(room._occupants) and not persistent_rooms[room.jid] then -- empty, non-persistent room | 174 if not next(room._occupants) and not persistent_rooms[room.jid] then -- empty, non-persistent room |