aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/muc
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2016-04-18 19:29:23 +0200
committerKim Alvefur <zash@zash.se>2016-04-18 19:29:23 +0200
commitbf656edb80380825c68fa93be86435583d12a853 (patch)
tree280984a25101eccacf9f395ef4a43b898338d81b /plugins/muc
parent850bf3dc9ed3aed9942f56e0e61cd1be4d51748e (diff)
downloadprosody-bf656edb80380825c68fa93be86435583d12a853.tar.gz
prosody-bf656edb80380825c68fa93be86435583d12a853.zip
MUC: Flatten format of serialized rooms
Diffstat (limited to 'plugins/muc')
-rw-r--r--plugins/muc/muc.lib.lua28
1 files changed, 22 insertions, 6 deletions
diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua
index b289b8ce..75bc825e 100644
--- a/plugins/muc/muc.lib.lua
+++ b/plugins/muc/muc.lib.lua
@@ -1245,17 +1245,33 @@ function _M.new_room(jid, config)
end
function room_mt:freeze()
- return {
- jid = self.jid;
+ local frozen = {
+ _jid = self.jid;
_data = self._data;
- _affiliations = self._affiliations;
- }
+ };
+ for user, affiliation in pairs(self._affiliations) do
+ frozen[user] = affiliation;
+ end
+ return frozen;
end
function _M.restore_room(frozen)
- local room_jid = frozen.jid;
+ -- 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 = _M.new_room(room_jid, frozen._data);
- room._affiliations = frozen._affiliations;
+
+ for jid, data in pairs(frozen) do
+ local node, host = jid_split(jid);
+ if node or host:sub(1,1) ~= "_" then
+ room._affiliations[jid] = data;
+ end
+ end
return room;
end