Comparison

plugins/muc/mod_muc.lua @ 9079:c040c358d6c0

mod_muc: Fire event when room is (and about to be) restored
author Matthew Wild <mwild1@gmail.com>
date Fri, 03 Aug 2018 13:44:30 +0100
parent 9078:9e339197c724
child 9081:ce57c69a20e2
comparison
equal deleted inserted replaced
9078:9e339197c724 9079:c040c358d6c0
186 local function restore_room(jid) 186 local function restore_room(jid)
187 local node = jid_split(jid); 187 local node = jid_split(jid);
188 local data, err = room_configs:get(node); 188 local data, err = room_configs:get(node);
189 if data then 189 if data then
190 module:log("debug", "Restoring room %s from storage", jid); 190 module:log("debug", "Restoring room %s from storage", jid);
191 if module:fire_event("muc-room-pre-restore", { jid = jid, data = data }) == false then
192 return false;
193 end
191 local state, s_err = room_state:get(node); 194 local state, s_err = room_state:get(node);
192 if not state and s_err then 195 if not state and s_err then
193 module:log("debug", "Could not restore state of room %s: %s", jid, s_err); 196 module:log("debug", "Could not restore state of room %s: %s", jid, s_err);
194 end 197 end
195 local room = muclib.restore_room(data, state); 198 local room = muclib.restore_room(data, state);
196 if track_room(room) then 199 if track_room(room) then
197 room_state:set(node, nil); 200 room_state:set(node, nil);
201 module:fire_event("muc-room-restored", { jid = jid, room = room });
198 return room; 202 return room;
199 else 203 else
200 return false; 204 return false;
201 end 205 end
202 elseif err then 206 elseif err then