MUC: Move 'preserialization' step to muc.lib
authorKim Alvefur <zash@zash.se>
Sun, 17 Apr 2016 20:09:44 +0000 (22:09 +0200)
committerKim Alvefur <zash@zash.se>
Sun, 17 Apr 2016 20:09:44 +0000 (22:09 +0200)
plugins/muc/mod_muc.lua
plugins/muc/muc.lib.lua

index 871b90b46af67293d274584270e5d7eaaa22c475..354ab1d144ed00bf38e1765a397c6296fa01071d 100644 (file)
@@ -102,11 +102,7 @@ local function room_save(room, forced)
        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);
index 42a0af25c9062c5b44281af4f5e4ab1a805c72c8..2026bc4717c668adc0def9bf16712c6767e8eefd 100644 (file)
@@ -1235,6 +1235,14 @@ function _M.new_room(jid, config) -- luacheck: ignore 212
        }, 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;