# HG changeset patch # User Kim Alvefur # Date 1606767121 -3600 # Node ID 342ac5d806fb328e288f5e5e00e0ccdd164baf6d # Parent e3f6f0b39e7b0a8dc25110ce5c6d139918ef7f78 mod_mam: Add support for page flipping This was easy. Needs tests tho, 100% chance of the logic being backwards. diff -r e3f6f0b39e7b -r 342ac5d806fb plugins/mod_mam/mod_mam.lua --- a/plugins/mod_mam/mod_mam.lua Mon Nov 30 21:00:45 2020 +0100 +++ b/plugins/mod_mam/mod_mam.lua Mon Nov 30 21:12:01 2020 +0100 @@ -147,6 +147,10 @@ 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 @@ 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 @@ 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 diff -r e3f6f0b39e7b -r 342ac5d806fb spec/scansion/mam_extended.scs --- a/spec/scansion/mam_extended.scs Mon Nov 30 21:00:45 2020 +0100 +++ b/spec/scansion/mam_extended.scs Mon Nov 30 21:12:01 2020 +0100 @@ -76,3 +76,47 @@ + +# Get results in reverse order +Romeo sends: + + + + + + +Romeo receives: + + + + + + U there? + + + + + +Romeo receives: + + + + + + Hello + + + + + +# FIXME unstable tag order from util.rsm +Romeo receives: + + + + 2 + + + + +