Changeset

7367:2aef5e8b69e9

MUC: Move room deserialization to muc.lib
author Kim Alvefur <zash@zash.se>
date Mon, 18 Apr 2016 19:26:26 +0200
parents 7366:eb3928903009
children 7368:4e24aff1e4df
files plugins/muc/mod_muc.lua plugins/muc/muc.lib.lua
diffstat 2 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/muc/mod_muc.lua	Mon Apr 18 19:20:51 2016 +0200
+++ b/plugins/muc/mod_muc.lua	Mon Apr 18 19:26:26 2016 +0200
@@ -130,9 +130,7 @@
 	local node = jid_split(jid);
 	local data = room_configs:get(node);
 	if data then
-		local room = muclib.new_room(jid);
-		room._data = data._data;
-		room._affiliations = data._affiliations;
+		local room = muclib.restore_room(data);
 		track_room(room);
 		return room;
 	end
--- a/plugins/muc/muc.lib.lua	Mon Apr 18 19:20:51 2016 +0200
+++ b/plugins/muc/muc.lib.lua	Mon Apr 18 19:26:26 2016 +0200
@@ -1252,6 +1252,13 @@
 	}
 end
 
+function _M.restore_room(frozen)
+	local room_jid = frozen.jid;
+	local room = _M.new_room(room_jid, frozen._data);
+	room._affiliations = frozen._affiliations;
+	return room;
+end
+
 _M.room_mt = room_mt;
 
 return _M;