Changeset

10223:d185c4961ee0

mod_storage_internal: Include last text message A protocol built on this API now allows showing a list of unread conversations with a counter, ordered by either oldest or newest message, along with the text body itself.
author Kim Alvefur <zash@zash.se>
date Fri, 23 Aug 2019 01:28:53 +0200
parents 10222:51f145094648
children 10224:94e341dee51c
files plugins/mod_storage_internal.lua
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_storage_internal.lua	Fri Aug 23 01:15:44 2019 +0200
+++ b/plugins/mod_storage_internal.lua	Fri Aug 23 01:28:53 2019 +0200
@@ -220,17 +220,20 @@
 	local counts = {};
 	local earliest = {};
 	local latest = {};
-	for _, _, when, with in iter do
+	local body = {};
+	for _, stanza, when, with in iter do
 		counts[with] = (counts[with] or 0) + 1;
 		if earliest[with] == nil then
 			earliest[with] = when;
 		end
 		latest[with] = when;
+		body[with] = stanza:get_child_text("body") or body[with];
 	end
 	return {
 		counts = counts;
 		earliest = earliest;
 		latest = latest;
+		body = body;
 	};
 end