From 22060f15ccd6851e77dd0cd38efaecb91bd0d623 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 5 Sep 2021 16:43:41 +0200 Subject: mod_pubsub: Add support for limiting result size #1608 --- plugins/mod_pubsub/pubsub.lib.lua | 6 +- spec/scansion/pubsub_max_items.scs | 196 +++++++++++++++++++++++++++++++++++++ 2 files changed, 201 insertions(+), 1 deletion(-) create mode 100644 spec/scansion/pubsub_max_items.scs diff --git a/plugins/mod_pubsub/pubsub.lib.lua b/plugins/mod_pubsub/pubsub.lib.lua index 3c38218a..92e210ca 100644 --- a/plugins/mod_pubsub/pubsub.lib.lua +++ b/plugins/mod_pubsub/pubsub.lib.lua @@ -323,7 +323,11 @@ function handlers.get_items(origin, stanza, items, service) origin.send(pubsub_error_reply(stanza, "nodeid-required")); return true; end - local ok, results = service:get_items(node, stanza.attr.from, requested_items); + local resultspec; -- TODO rsm.get() + if items.attr.max_items then + resultspec = { max = tonumber(items.attr.max_items) }; + end + local ok, results = service:get_items(node, stanza.attr.from, requested_items, resultspec); if not ok then origin.send(pubsub_error_reply(stanza, results)); return true; diff --git a/spec/scansion/pubsub_max_items.scs b/spec/scansion/pubsub_max_items.scs new file mode 100644 index 00000000..7f0b531d --- /dev/null +++ b/spec/scansion/pubsub_max_items.scs @@ -0,0 +1,196 @@ +# Pubsub: Requesting the Most Recent Items (#1608) + +[Client] Alice + jid: admin@localhost + password: password + +--------- + +Alice connects + +Alice sends: + + +Alice receives: + + +Alice sends: + + + + + + +Alice receives: + + +Alice sends: + + + + + + +Alice receives: + + + + + + http://jabber.org/protocol/pubsub#node_config + + + + + + + 20 + + + 1 + + + + + + + + open + + + + + + publishers + + + 1 + + + 1 + + + + + headline + + + 1 + + + 1 + + + + + + +Alice sends: + + + + + foo + + + + + +Alice receives: + + + + + + + + +Alice sends: + + + + + bar + + + + + +Alice receives: + + + + + + + + +Alice sends: + + + + + + +Alice receives: + + + + + bar + + + + + +Alice sends: + + + + + + +Alice receives: + + + + + foo + + + bar + + + + + +Alice sends: + + + + + + +Alice receives: + + -- cgit v1.2.3