Software /
code /
prosody
Comparison
plugins/muc/muc.lib.lua @ 7368:4e24aff1e4df
MUC: Flatten format of serialized rooms
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 18 Apr 2016 19:29:23 +0200 |
parent | 7367:2aef5e8b69e9 |
child | 7369:c5cae59831d7 |
comparison
equal
deleted
inserted
replaced
7367:2aef5e8b69e9 | 7368:4e24aff1e4df |
---|---|
1243 _affiliations = {}; | 1243 _affiliations = {}; |
1244 }, room_mt); | 1244 }, room_mt); |
1245 end | 1245 end |
1246 | 1246 |
1247 function room_mt:freeze() | 1247 function room_mt:freeze() |
1248 return { | 1248 local frozen = { |
1249 jid = self.jid; | 1249 _jid = self.jid; |
1250 _data = self._data; | 1250 _data = self._data; |
1251 _affiliations = self._affiliations; | 1251 }; |
1252 } | 1252 for user, affiliation in pairs(self._affiliations) do |
1253 frozen[user] = affiliation; | |
1254 end | |
1255 return frozen; | |
1253 end | 1256 end |
1254 | 1257 |
1255 function _M.restore_room(frozen) | 1258 function _M.restore_room(frozen) |
1256 local room_jid = frozen.jid; | 1259 -- COMPAT |
1260 if frozen.jid and frozen._affiliations then | |
1261 local room = _M.new_room(frozen.jid, frozen._data); | |
1262 room._affiliations = frozen._affiliations; | |
1263 return room; | |
1264 end | |
1265 | |
1266 local room_jid = frozen._jid; | |
1257 local room = _M.new_room(room_jid, frozen._data); | 1267 local room = _M.new_room(room_jid, frozen._data); |
1258 room._affiliations = frozen._affiliations; | 1268 |
1269 for jid, data in pairs(frozen) do | |
1270 local node, host = jid_split(jid); | |
1271 if node or host:sub(1,1) ~= "_" then | |
1272 room._affiliations[jid] = data; | |
1273 end | |
1274 end | |
1259 return room; | 1275 return room; |
1260 end | 1276 end |
1261 | 1277 |
1262 _M.room_mt = room_mt; | 1278 _M.room_mt = room_mt; |
1263 | 1279 |