Software /
code /
prosody
Changeset
11272:44c9cb4094bb
mod_mam: Add support for before-id and after-id fields
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 09 Jan 2021 21:31:45 +0100 |
parents | 11271:41a962b72a6e |
children | 11273:9f1355689648 |
files | plugins/mod_mam/mod_mam.lua |
diffstat | 1 files changed, 9 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_mam/mod_mam.lua Sat Jan 09 21:08:33 2021 +0100 +++ b/plugins/mod_mam/mod_mam.lua Sat Jan 09 21:31:45 2021 +0100 @@ -1,7 +1,7 @@ -- Prosody IM -- Copyright (C) 2008-2017 Matthew Wild -- Copyright (C) 2008-2017 Waqas Hussain --- Copyright (C) 2011-2020 Kim Alvefur +-- Copyright (C) 2011-2021 Kim Alvefur -- -- This project is MIT/X11 licensed. Please see the -- COPYING file in the source package for more information. @@ -83,6 +83,11 @@ { name = "end"; type = "text-single"; }; }; +if archive.caps and archive.caps.full_id_range then + table.insert(query_form, { name = "before-id"; type = "text-single"; }); + table.insert(query_form, { name = "after-id"; type = "text-single"; }); +end + -- Serve form module:hook("iq-get/self/"..xmlns_mam..":query", function(event) local origin, stanza = event.origin, event.stanza; @@ -102,7 +107,7 @@ get_prefs(origin.username, true); -- Search query parameters - local qwith, qstart, qend; + local qwith, qstart, qend, qbefore, qafter; local form = query:get_child("x", "jabber:x:data"); if form then local form_type, err = get_form_type(form); @@ -119,6 +124,7 @@ return true; end qwith, qstart, qend = form["with"], form["start"], form["end"]; + qbefore, qafter = form["before-id"], form["after-id"]; qwith = qwith and jid_bare(qwith); -- dataforms does jidprep end @@ -142,7 +148,7 @@ local qset = rsm.get(query); local qmax = m_min(qset and qset.max or default_max_items, max_max_items); local reverse = qset and qset.before or false; - local before, after = qset and qset.before, qset and qset.after; + local before, after = qset and qset.before or qbefore, qset and qset.after or qafter; if type(before) ~= "string" then before = nil; end if qset then module:log("debug", "Archive query id=%s rsm=%q", qid or stanza.attr.id, qset); @@ -555,7 +561,6 @@ module:hook("message/full", message_handler, 0); local advertise_extended = module:get_option_boolean("mam_advertise_extend", false); --- TODO before-id, after-id -- TODO ids -- TODO delete feature flag option