aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/muc
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2016-04-28 23:34:19 +0200
committerKim Alvefur <zash@zash.se>2016-04-28 23:34:19 +0200
commit802eb3518e219f8218deedd94294892ab89ff86b (patch)
treeed4af3dea95ce00ef28d0c47897cc5d96d1979bf /plugins/muc
parent8bb9e615d5841b84fcbab596363931ee7e089af1 (diff)
downloadprosody-802eb3518e219f8218deedd94294892ab89ff86b.tar.gz
prosody-802eb3518e219f8218deedd94294892ab89ff86b.zip
MUC: Include the very last message in serialized form to keep it across eviction and restore
Diffstat (limited to 'plugins/muc')
-rw-r--r--plugins/muc/muc.lib.lua12
1 files changed, 12 insertions, 0 deletions
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);