Software /
code /
prosody
Comparison
plugins/mod_storage_internal.lua @ 10223:d185c4961ee0
mod_storage_internal: Include last text message
A protocol built on this API now allows showing a list of unread
conversations with a counter, ordered by either oldest or newest
message, along with the text body itself.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 23 Aug 2019 01:28:53 +0200 |
parent | 10222:51f145094648 |
child | 10837:f23363380599 |
comparison
equal
deleted
inserted
replaced
10222:51f145094648 | 10223:d185c4961ee0 |
---|---|
218 local iter, err = self:find(username, query) | 218 local iter, err = self:find(username, query) |
219 if not iter then return iter, err; end | 219 if not iter then return iter, err; end |
220 local counts = {}; | 220 local counts = {}; |
221 local earliest = {}; | 221 local earliest = {}; |
222 local latest = {}; | 222 local latest = {}; |
223 for _, _, when, with in iter do | 223 local body = {}; |
224 for _, stanza, when, with in iter do | |
224 counts[with] = (counts[with] or 0) + 1; | 225 counts[with] = (counts[with] or 0) + 1; |
225 if earliest[with] == nil then | 226 if earliest[with] == nil then |
226 earliest[with] = when; | 227 earliest[with] = when; |
227 end | 228 end |
228 latest[with] = when; | 229 latest[with] = when; |
230 body[with] = stanza:get_child_text("body") or body[with]; | |
229 end | 231 end |
230 return { | 232 return { |
231 counts = counts; | 233 counts = counts; |
232 earliest = earliest; | 234 earliest = earliest; |
233 latest = latest; | 235 latest = latest; |
236 body = body; | |
234 }; | 237 }; |
235 end | 238 end |
236 | 239 |
237 function archive:users() | 240 function archive:users() |
238 return datamanager.users(host, self.store, "list"); | 241 return datamanager.users(host, self.store, "list"); |