mod_map: Include timestamps of first/last message (if reported)
authorKim Alvefur <zash@zash.se>
Fri, 23 Aug 2019 01:16:58 +0200
changeset 3655 95f7291db669
parent 3654 30743ae1fe1a
child 3656 d0c2f001735f
mod_map: Include timestamps of first/last message (if reported) Allows ordering conversations by recent activity or oldest unread.
mod_map/mod_map.lua
--- a/mod_map/mod_map.lua	Fri Aug 23 01:08:12 2019 +0200
+++ b/mod_map/mod_map.lua	Fri Aug 23 01:16:58 2019 +0200
@@ -3,6 +3,7 @@
 local jid_bare = require "util.jid".bare;
 local rsm = require "util.rsm";
 local dataform = require "util.dataforms".new;
+local datetime = require "util.datetime".datetime;
 
 local archive = module:open_store("archive", "archive");
 
@@ -59,6 +60,12 @@
 		if type(count) == "number" then
 			reply:text_tag("count", ("%d"):format(count));
 		end
+		if summary.earliest and summary.earliest[jid] then
+			reply:text_tag("start", datetime(summary.earliest[jid]));
+		end
+		if summary.latest and summary.latest[jid] then
+			reply:text_tag("end", datetime(summary.latest[jid]));
+		end
 		reply:up();
 	end