Mercurial > prosody-hg
comparison plugins/muc/muc.lib.lua @ 7412:f9744effae04
MUC: Include the very last message in serialized form to keep it across eviction and restore
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Thu, 28 Apr 2016 23:34:19 +0200 |
| parents | f385cd6127b2 |
| children | 228396da1e27 |
comparison
equal
deleted
inserted
replaced
| 7411:f385cd6127b2 | 7412:f9744effae04 |
|---|---|
| 1320 } | 1320 } |
| 1321 for jid, presence in occupant:each_session() do | 1321 for jid, presence in occupant:each_session() do |
| 1322 frozen[jid] = st.preserialize(presence); | 1322 frozen[jid] = st.preserialize(presence); |
| 1323 end | 1323 end |
| 1324 end | 1324 end |
| 1325 local history = self._history; | |
| 1326 if history then | |
| 1327 frozen._last_message = st.preserialize(history[#history].stanza); | |
| 1328 frozen._last_message_at = history[#history].timestamp; | |
| 1329 end | |
| 1325 end | 1330 end |
| 1326 return frozen; | 1331 return frozen; |
| 1327 end | 1332 end |
| 1328 | 1333 |
| 1329 function _M.restore_room(frozen) | 1334 function _M.restore_room(frozen) |
| 1334 return room; | 1339 return room; |
| 1335 end | 1340 end |
| 1336 | 1341 |
| 1337 local room_jid = frozen._jid; | 1342 local room_jid = frozen._jid; |
| 1338 local room = _M.new_room(room_jid, frozen._data); | 1343 local room = _M.new_room(room_jid, frozen._data); |
| 1344 | |
| 1345 if frozen._last_message and frozen._last_message_at then | |
| 1346 room._history = { | |
| 1347 { stanza = st.deserialize(frozen._last_message), | |
| 1348 timestamp = frozen._last_message_at, }, | |
| 1349 }; | |
| 1350 end | |
| 1339 | 1351 |
| 1340 local occupants = {}; | 1352 local occupants = {}; |
| 1341 local occupant_sessions = {}; | 1353 local occupant_sessions = {}; |
| 1342 local room_name, room_host = jid_split(room_jid); | 1354 local room_name, room_host = jid_split(room_jid); |
| 1343 for jid, data in pairs(frozen) do | 1355 for jid, data in pairs(frozen) do |
