aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_storage_internal.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-08-23 01:10:27 +0200
committerKim Alvefur <zash@zash.se>2019-08-23 01:10:27 +0200
commitd3c559bcc89ef91ebecde3cc3b4520873a98ea4d (patch)
treec7d69620635566a6e390e6cf44ba5628b1aab734 /plugins/mod_storage_internal.lua
parent39cb87a158a017441e129ed8514f83bfbfdae64f (diff)
downloadprosody-d3c559bcc89ef91ebecde3cc3b4520873a98ea4d.tar.gz
prosody-d3c559bcc89ef91ebecde3cc3b4520873a98ea4d.zip
mod_storage_*: Include timestamp of latest message in :summary API
Clients may want to show a list of conversations ordered by how timestamp of most recent message. The counts allow a badge with unread message counter.
Diffstat (limited to 'plugins/mod_storage_internal.lua')
-rw-r--r--plugins/mod_storage_internal.lua5
1 files changed, 4 insertions, 1 deletions
diff --git a/plugins/mod_storage_internal.lua b/plugins/mod_storage_internal.lua
index 28caa071..1ee860d6 100644
--- a/plugins/mod_storage_internal.lua
+++ b/plugins/mod_storage_internal.lua
@@ -218,11 +218,14 @@ function archive:summary(username, query)
local iter, err = self:find(username, query)
if not iter then return iter, err; end
local counts = {};
- for _, _, _, with in iter do
+ local latest = {};
+ for _, _, when, with in iter do
counts[with] = (counts[with] or 0) + 1;
+ latest[with] = when;
end
return {
counts = counts;
+ latest = latest;
};
end