aboutsummaryrefslogtreecommitdiffstats
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
commitb3b9ebb0c460d0cd270adc67ba68564431d4db27 (patch)
tree280984a25101eccacf9f395ef4a43b898338d81b
parentad74a6b7198de6964abceeb6dfd94edcd7c4d609 (diff)
downloadprosody-b3b9ebb0c460d0cd270adc67ba68564431d4db27.tar.gz
prosody-b3b9ebb0c460d0cd270adc67ba68564431d4db27.zip
MUC: Flatten format of serialized rooms
-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