Comparison

plugins/mod_storage_internal.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
216 216
217 function archive:summary(username, query) 217 function archive:summary(username, query)
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 for _, _, _, with in iter do 221 local latest = {};
222 for _, _, when, with in iter do
222 counts[with] = (counts[with] or 0) + 1; 223 counts[with] = (counts[with] or 0) + 1;
224 latest[with] = when;
223 end 225 end
224 return { 226 return {
225 counts = counts; 227 counts = counts;
228 latest = latest;
226 }; 229 };
227 end 230 end
228 231
229 function archive:users() 232 function archive:users()
230 return datamanager.users(host, self.store, "list"); 233 return datamanager.users(host, self.store, "list");