MUC: Move 'preserialization' step to muc.lib
authorKim Alvefur <zash@zash.se>
Sun, 17 Apr 2016 22:09:44 +0200
changeset 7363 7a37fade5380
parent 7360 d69521003e91
child 7364 3409773ca19a
MUC: Move 'preserialization' step to muc.lib
plugins/muc/mod_muc.lua
plugins/muc/muc.lib.lua
--- a/plugins/muc/mod_muc.lua	Fri Apr 15 18:03:55 2016 +0200
+++ b/plugins/muc/mod_muc.lua	Sun Apr 17 22:09:44 2016 +0200
@@ -102,11 +102,7 @@
 	local is_persistent = persistent.get(room);
 	persistent_rooms:set(nil, room.jid, is_persistent);
 	if is_persistent then
-		local data = {
-			jid = room.jid;
-			_data = room._data;
-			_affiliations = room._affiliations;
-		};
+		local data = room:freeze();
 		room_configs:set(node, data);
 	elseif forced then
 		room_configs:set(node, nil);
--- a/plugins/muc/muc.lib.lua	Fri Apr 15 18:03:55 2016 +0200
+++ b/plugins/muc/muc.lib.lua	Sun Apr 17 22:09:44 2016 +0200
@@ -1235,6 +1235,14 @@
 	}, room_mt);
 end
 
+function room_mt:freeze()
+	return {
+		jid = self.jid;
+		_data = self._data;
+		_affiliations = self._affiliations;
+	}
+end
+
 _M.room_mt = room_mt;
 
 return _M;