Changeset

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
parents 9078:9e339197c724
children 9080:1b21f8ffaec8
files plugins/muc/mod_muc.lua
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/muc/mod_muc.lua	Fri Aug 03 13:43:47 2018 +0100
+++ b/plugins/muc/mod_muc.lua	Fri Aug 03 13:44:30 2018 +0100
@@ -188,6 +188,9 @@
 	local data, err = room_configs:get(node);
 	if data then
 		module:log("debug", "Restoring room %s from storage", jid);
+		if module:fire_event("muc-room-pre-restore", { jid = jid, data = data }) == false then
+			return false;
+		end
 		local state, s_err = room_state:get(node);
 		if not state and s_err then
 			module:log("debug", "Could not restore state of room %s: %s", jid, s_err);
@@ -195,6 +198,7 @@
 		local room = muclib.restore_room(data, state);
 		if track_room(room) then
 			room_state:set(node, nil);
+			module:fire_event("muc-room-restored", { jid = jid, room = room });
 			return room;
 		else
 			return false;