Software /
code /
prosody
Comparison
plugins/muc/muc.lib.lua @ 7631:f50c039d6bb1
MUC: Fix compatibility with new and old storage format
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 24 Aug 2016 00:34:46 +0200 |
parent | 7488:cdabf8199903 |
child | 7661:37ab6c6326fe |
comparison
equal
deleted
inserted
replaced
7630:abe2697b5e92 | 7631:f50c039d6bb1 |
---|---|
1343 end | 1343 end |
1344 return frozen, state; | 1344 return frozen, state; |
1345 end | 1345 end |
1346 | 1346 |
1347 function _M.restore_room(frozen, state) | 1347 function _M.restore_room(frozen, state) |
1348 -- COMPAT | 1348 local room_jid = frozen._jid or frozen.jid; |
1349 if frozen.jid and frozen._affiliations then | |
1350 local room = _M.new_room(frozen.jid, frozen._data); | |
1351 room._affiliations = frozen._affiliations; | |
1352 return room; | |
1353 end | |
1354 | |
1355 local room_jid = frozen._jid; | |
1356 local room = _M.new_room(room_jid, frozen._data); | 1349 local room = _M.new_room(room_jid, frozen._data); |
1357 | 1350 |
1358 if state and state._last_message and state._last_message_at then | 1351 if state and state._last_message and state._last_message_at then |
1359 room._history = { | 1352 room._history = { |
1360 { stanza = st.deserialize(state._last_message), | 1353 { stanza = st.deserialize(state._last_message), |
1363 end | 1356 end |
1364 | 1357 |
1365 local occupants = {}; | 1358 local occupants = {}; |
1366 local occupant_sessions = {}; | 1359 local occupant_sessions = {}; |
1367 local room_name, room_host = jid_split(room_jid); | 1360 local room_name, room_host = jid_split(room_jid); |
1368 for jid, data in pairs(frozen) do | 1361 |
1369 local node, host, resource = jid_split(jid); | 1362 if frozen.jid and frozen._affiliations then |
1370 if host:sub(1,1) ~= "_" and not resource and type(data) == "string" then | 1363 room._affiliations = frozen._affiliations; |
1371 -- bare jid: affiliation | 1364 else |
1372 room._affiliations[jid] = data; | 1365 for jid, data in pairs(frozen) do |
1366 local node, host, resource = jid_split(jid); | |
1367 if host:sub(1,1) ~= "_" and not resource and type(data) == "string" then | |
1368 -- bare jid: affiliation | |
1369 room._affiliations[jid] = data; | |
1370 end | |
1373 end | 1371 end |
1374 end | 1372 end |
1375 for jid, data in pairs(state or frozen) do | 1373 for jid, data in pairs(state or frozen) do |
1376 local node, host, resource = jid_split(jid); | 1374 local node, host, resource = jid_split(jid); |
1377 if node or host:sub(1,1) ~= "_" then | 1375 if node or host:sub(1,1) ~= "_" then |