aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-02-25 15:48:28 +0100
committerKim Alvefur <zash@zash.se>2019-02-25 15:48:28 +0100
commitc1a1511e2662fdd1749c30cfc1cabc3d4b89f082 (patch)
tree21f89ef04949ba04cad55d6d93b4e97b66709053 /plugins
parentbd52e2269b0fff09fc8aea6c6807a9f08727bb31 (diff)
downloadprosody-c1a1511e2662fdd1749c30cfc1cabc3d4b89f082.tar.gz
prosody-c1a1511e2662fdd1749c30cfc1cabc3d4b89f082.zip
mod_storage_internal: Implement a summary API returning message counts per contact
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_storage_internal.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/plugins/mod_storage_internal.lua b/plugins/mod_storage_internal.lua
index c87d01be..aa5c3c8a 100644
--- a/plugins/mod_storage_internal.lua
+++ b/plugins/mod_storage_internal.lua
@@ -196,6 +196,16 @@ function archive:dates(username)
return array(items):pluck("when"):map(datetime.date):unique();
end
+function archive:summary(username, query)
+ local iter, err = self:find(username, query)
+ if not iter then return iter, err; end
+ local summary = {};
+ for _, _, _, with in iter do
+ summary[with] = (summary[with] or 0) + 1;
+ end
+ return summary;
+end
+
function archive:delete(username, query)
local cache_key = jid_join(username, host, self.store);
if not query or next(query) == nil then