MUC: Move room deserialization to muc.lib
authorKim Alvefur <zash@zash.se>
Mon, 18 Apr 2016 17:26:26 +0000 (19:26 +0200)
committerKim Alvefur <zash@zash.se>
Mon, 18 Apr 2016 17:26:26 +0000 (19:26 +0200)
plugins/muc/mod_muc.lua
plugins/muc/muc.lib.lua

index c8723c162f8a0d198ef0bf2417d5171e76157b3f..4410ba166dfd4786f3fb9481c9a24f4b883135b6 100644 (file)
@@ -130,9 +130,7 @@ local function restore_room(jid)
        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
index a7a968650d72bef06245461e49e268b0953e2e96..b289b8ce3f0319e3bfc5242529475154d91cb87d 100644 (file)
@@ -1252,6 +1252,13 @@ function room_mt:freeze()
        }
 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;