X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=plugins%2Fmuc%2Fmuc.lib.lua;h=071f1f8b01f05eaf1a90e86233adf20c7052fcd5;hb=8a49437ee31cd0d1123ff9e5b708780ea8879f6b;hp=337d2ae41f364a48f291f6cac4c54f47e5fddaf0;hpb=9d986cb78caf1ccfea214052e80f0b2d345c4b2a;p=prosody.git diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua index 337d2ae4..071f1f8b 100644 --- a/plugins/muc/muc.lib.lua +++ b/plugins/muc/muc.lib.lua @@ -1322,6 +1322,11 @@ function room_mt:freeze(live) frozen[jid] = st.preserialize(presence); end end + local history = self._history; + if history then + frozen._last_message = st.preserialize(history[#history].stanza); + frozen._last_message_at = history[#history].timestamp; + end end return frozen; end @@ -1337,6 +1342,13 @@ function _M.restore_room(frozen) local room_jid = frozen._jid; local room = _M.new_room(room_jid, frozen._data); + if frozen._last_message and frozen._last_message_at then + room._history = { + { stanza = st.deserialize(frozen._last_message), + timestamp = frozen._last_message_at, }, + }; + end + local occupants = {}; local occupant_sessions = {}; local room_name, room_host = jid_split(room_jid);