aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_storage_sql.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
commit5a382ce091fd1edf8d29d4531ec7a6bd957fc4e5 (patch)
treec7d69620635566a6e390e6cf44ba5628b1aab734 /plugins/mod_storage_sql.lua
parent24670cf607bf3eed29ca79dd4e6b7397773db91b (diff)
downloadprosody-5a382ce091fd1edf8d29d4531ec7a6bd957fc4e5.tar.gz
prosody-5a382ce091fd1edf8d29d4531ec7a6bd957fc4e5.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_sql.lua')
-rw-r--r--plugins/mod_storage_sql.lua5
1 files changed, 4 insertions, 1 deletions
diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua
index d6779946..dc960cad 100644
--- a/plugins/mod_storage_sql.lua
+++ b/plugins/mod_storage_sql.lua
@@ -424,7 +424,7 @@ function archive_store:summary(username, query)
local user,store = username,self.store;
local ok, result = engine:transaction(function()
local sql_query = [[
- SELECT DISTINCT "with", COUNT(*)
+ SELECT DISTINCT "with", COUNT(*), MAX("when")
FROM "prosodyarchive"
WHERE %s
GROUP BY "with"
@@ -447,12 +447,15 @@ function archive_store:summary(username, query)
end);
if not ok then return ok, result end
local counts = {};
+ local latest = {};
for row in result do
local with, count = row[1], row[2];
counts[with] = count;
+ latest[with] = row[3];
end
return {
counts = counts;
+ latest = latest;
};
end