Comparison

plugins/muc/mod_muc.lua @ 6222:355b29881117

plugins/muc: Move persistent room configuration to own module
author daurnimator <quae@daurnimator.com>
date Tue, 15 Apr 2014 17:06:04 -0400
parent 6206:f937bb5c83c3
child 6234:cc8a6ca2d7c5
comparison
equal deleted inserted replaced
6221:f321536afeec 6222:355b29881117
24 end 24 end
25 end 25 end
26 26
27 local muclib = module:require "muc"; 27 local muclib = module:require "muc";
28 local muc_new_room = muclib.new_room; 28 local muc_new_room = muclib.new_room;
29 local persistent = module:require "muc/persistent";
29 local jid_split = require "util.jid".split; 30 local jid_split = require "util.jid".split;
30 local jid_bare = require "util.jid".bare; 31 local jid_bare = require "util.jid".bare;
31 local st = require "util.stanza"; 32 local st = require "util.stanza";
32 local um_is_admin = require "core.usermanager".is_admin; 33 local um_is_admin = require "core.usermanager".is_admin;
33 local hosts = prosody.hosts; 34 local hosts = prosody.hosts;
63 return _set_affiliation(self, actor, jid, affiliation, callback, reason); 64 return _set_affiliation(self, actor, jid, affiliation, callback, reason);
64 end 65 end
65 66
66 local function room_save(room, forced) 67 local function room_save(room, forced)
67 local node = jid_split(room.jid); 68 local node = jid_split(room.jid);
68 persistent_rooms[room.jid] = room._data.persistent; 69 local is_persistent = persistent.get(room);
69 if room._data.persistent then 70 persistent_rooms[room.jid] = is_persistent;
71 if is_persistent then
70 local history = room._data.history; 72 local history = room._data.history;
71 room._data.history = nil; 73 room._data.history = nil;
72 local data = { 74 local data = {
73 jid = room.jid; 75 jid = room.jid;
74 _data = room._data; 76 _data = room._data;
136 forget_room(room.jid) 138 forget_room(room.jid)
137 end) 139 end)
138 140
139 module:hook("muc-occupant-left",function(event) 141 module:hook("muc-occupant-left",function(event)
140 local room = event.room 142 local room = event.room
141 if not next(room._occupants) and not persistent_rooms[room.jid] then -- empty, non-persistent room 143 if not next(room._occupants) and not persistent.get(room) then -- empty, non-persistent room
142 module:fire_event("muc-room-destroyed", { room = room }); 144 module:fire_event("muc-room-destroyed", { room = room });
143 end 145 end
144 end); 146 end);
145 147
146 -- Watch presence to create rooms 148 -- Watch presence to create rooms