aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_mam
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2020-11-30 21:12:01 +0100
committerKim Alvefur <zash@zash.se>2020-11-30 21:12:01 +0100
commit968fd6eb62bf2f9b3527fc4f2fa751dfb36c3bf5 (patch)
treefdb31575660f2a8f260406c6673d4e4aa062659a /plugins/mod_mam
parent741a2fc37b9c842260f735a682fd458c85100ff1 (diff)
downloadprosody-968fd6eb62bf2f9b3527fc4f2fa751dfb36c3bf5.tar.gz
prosody-968fd6eb62bf2f9b3527fc4f2fa751dfb36c3bf5.zip
mod_mam: Add support for page flipping
This was easy. Needs tests tho, 100% chance of the logic being backwards.
Diffstat (limited to 'plugins/mod_mam')
-rw-r--r--plugins/mod_mam/mod_mam.lua11
1 files changed, 8 insertions, 3 deletions
diff --git a/plugins/mod_mam/mod_mam.lua b/plugins/mod_mam/mod_mam.lua
index cc7b7fba..f252d179 100644
--- a/plugins/mod_mam/mod_mam.lua
+++ b/plugins/mod_mam/mod_mam.lua
@@ -147,6 +147,10 @@ module:hook("iq-set/self/"..xmlns_mam..":query", function(event)
if qset then
module:log("debug", "Archive query id=%s rsm=%q", qid or stanza.attr.id, qset);
end
+ -- A reverse query needs to be flipped
+ local flip = reverse;
+ -- A flip-page query needs to be the opposite of that.
+ if query:get_child("flip-page") then flip = not flip end
-- Load all the data!
local data, err = archive:find(origin.username, {
@@ -199,17 +203,19 @@ module:hook("iq-set/self/"..xmlns_mam..":query", function(event)
if not first then first = id; end
last = id;
- if reverse then
+ if flip then
results[count] = fwd_st;
else
origin.send(fwd_st);
end
end
- if reverse then
+ if flip then
for i = #results, 1, -1 do
origin.send(results[i]);
end
+ end
+ if reverse then
first, last = last, first;
end
@@ -516,7 +522,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 page flipping
-- TODO archive metadata query
-- TODO delete feature flag option