Mercurial > prosody-modules
comparison mod_map/mod_map.lua @ 3651:95f7291db669
mod_map: Include timestamps of first/last message (if reported)
Allows ordering conversations by recent activity or oldest unread.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Fri, 23 Aug 2019 01:16:58 +0200 |
| parents | 30743ae1fe1a |
| children | d0c2f001735f |
comparison
equal
deleted
inserted
replaced
| 3650:30743ae1fe1a | 3651:95f7291db669 |
|---|---|
| 1 | 1 |
| 2 local st = require "util.stanza"; | 2 local st = require "util.stanza"; |
| 3 local jid_bare = require "util.jid".bare; | 3 local jid_bare = require "util.jid".bare; |
| 4 local rsm = require "util.rsm"; | 4 local rsm = require "util.rsm"; |
| 5 local dataform = require "util.dataforms".new; | 5 local dataform = require "util.dataforms".new; |
| 6 local datetime = require "util.datetime".datetime; | |
| 6 | 7 |
| 7 local archive = module:open_store("archive", "archive"); | 8 local archive = module:open_store("archive", "archive"); |
| 8 | 9 |
| 9 local query_form = dataform { | 10 local query_form = dataform { |
| 10 { name = "with"; type = "jid-single"; }; | 11 { name = "with"; type = "jid-single"; }; |
| 57 for jid, count in pairs(summary.counts) do | 58 for jid, count in pairs(summary.counts) do |
| 58 reply:tag("item", { jid = jid }); | 59 reply:tag("item", { jid = jid }); |
| 59 if type(count) == "number" then | 60 if type(count) == "number" then |
| 60 reply:text_tag("count", ("%d"):format(count)); | 61 reply:text_tag("count", ("%d"):format(count)); |
| 61 end | 62 end |
| 63 if summary.earliest and summary.earliest[jid] then | |
| 64 reply:text_tag("start", datetime(summary.earliest[jid])); | |
| 65 end | |
| 66 if summary.latest and summary.latest[jid] then | |
| 67 reply:text_tag("end", datetime(summary.latest[jid])); | |
| 68 end | |
| 62 reply:up(); | 69 reply:up(); |
| 63 end | 70 end |
| 64 | 71 |
| 65 module:send(reply); | 72 module:send(reply); |
| 66 return true; | 73 return true; |
