# HG changeset patch # User Kim Alvefur # Date 1461000563 -7200 # Node ID 4e24aff1e4df78e21fc3ba66174f8a22f851e94d # Parent 2aef5e8b69e94fce2905515eb8eca4b73b081539 MUC: Flatten format of serialized rooms diff -r 2aef5e8b69e9 -r 4e24aff1e4df plugins/muc/muc.lib.lua --- a/plugins/muc/muc.lib.lua Mon Apr 18 19:26:26 2016 +0200 +++ b/plugins/muc/muc.lib.lua Mon Apr 18 19:29:23 2016 +0200 @@ -1245,17 +1245,33 @@ 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