Software /
code /
prosody
Comparison
plugins/mod_storage_memory.lua @ 10221:068692cb9e78
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.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 23 Aug 2019 01:10:27 +0200 |
parent | 10220:1e2b444acb72 |
child | 10222:51f145094648 |
comparison
equal
deleted
inserted
replaced
10220:1e2b444acb72 | 10221:068692cb9e78 |
---|---|
169 | 169 |
170 function archive_store:summary(username, query) | 170 function archive_store:summary(username, query) |
171 local iter, err = self:find(username, query) | 171 local iter, err = self:find(username, query) |
172 if not iter then return iter, err; end | 172 if not iter then return iter, err; end |
173 local counts = {}; | 173 local counts = {}; |
174 for _, _, _, with in iter do | 174 local latest = {}; |
175 for _, _, when, with in iter do | |
175 counts[with] = (counts[with] or 0) + 1; | 176 counts[with] = (counts[with] or 0) + 1; |
177 latest[with] = when; | |
176 end | 178 end |
177 return { | 179 return { |
178 counts = counts; | 180 counts = counts; |
181 latest = latest; | |
179 }; | 182 }; |
180 end | 183 end |
181 | 184 |
182 | 185 |
183 function archive_store:delete(username, query) | 186 function archive_store:delete(username, query) |