Changeset

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 7411:f385cd6127b2
children 7413:228396da1e27
files plugins/muc/muc.lib.lua
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/muc/muc.lib.lua	Thu Apr 28 22:57:53 2016 +0200
+++ b/plugins/muc/muc.lib.lua	Thu Apr 28 23:34:19 2016 +0200
@@ -1322,6 +1322,11 @@
 				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 @@
 	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);