aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/muc/muc.lib.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2016-08-24 00:34:46 +0200
committerKim Alvefur <zash@zash.se>2016-08-24 00:34:46 +0200
commit5455518362d1e9404d36fbddbc96c5d4f854b578 (patch)
treed1226d97c8c72670ca8b9913075fd8d119f43269 /plugins/muc/muc.lib.lua
parentfeef5c41f1c29a5b157b60bbfd1e93bd9cc11e56 (diff)
downloadprosody-5455518362d1e9404d36fbddbc96c5d4f854b578.tar.gz
prosody-5455518362d1e9404d36fbddbc96c5d4f854b578.zip
MUC: Fix compatibility with new and old storage format
Diffstat (limited to 'plugins/muc/muc.lib.lua')
-rw-r--r--plugins/muc/muc.lib.lua24
1 files changed, 11 insertions, 13 deletions
diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua
index ac8ebadd..b50964d2 100644
--- a/plugins/muc/muc.lib.lua
+++ b/plugins/muc/muc.lib.lua
@@ -1345,14 +1345,7 @@ function room_mt:freeze(live)
end
function _M.restore_room(frozen, state)
- -- COMPAT
- if frozen.jid and frozen._affiliations then
- local room = _M.new_room(frozen.jid, frozen._data);
- room._affiliations = frozen._affiliations;
- return room;
- end
-
- local room_jid = frozen._jid;
+ local room_jid = frozen._jid or frozen.jid;
local room = _M.new_room(room_jid, frozen._data);
if state and state._last_message and state._last_message_at then
@@ -1365,11 +1358,16 @@ function _M.restore_room(frozen, state)
local occupants = {};
local occupant_sessions = {};
local room_name, room_host = jid_split(room_jid);
- for jid, data in pairs(frozen) do
- local node, host, resource = jid_split(jid);
- if host:sub(1,1) ~= "_" and not resource and type(data) == "string" then
- -- bare jid: affiliation
- room._affiliations[jid] = data;
+
+ if frozen.jid and frozen._affiliations then
+ room._affiliations = frozen._affiliations;
+ else
+ for jid, data in pairs(frozen) do
+ local node, host, resource = jid_split(jid);
+ if host:sub(1,1) ~= "_" and not resource and type(data) == "string" then
+ -- bare jid: affiliation
+ room._affiliations[jid] = data;
+ end
end
end
for jid, data in pairs(state or frozen) do