# HG changeset patch # User Kim Alvefur # Date 1630853021 -7200 # Node ID aa6ab07544c2dc2dc5007a14731f2185eb46f858 # Parent 5610f7c5b2612ec8c1a19802b00c1158d7baca93 mod_pubsub: Add support for limiting result size #1608 diff -r 5610f7c5b261 -r aa6ab07544c2 plugins/mod_pubsub/pubsub.lib.lua --- a/plugins/mod_pubsub/pubsub.lib.lua Sun Sep 05 16:21:10 2021 +0200 +++ b/plugins/mod_pubsub/pubsub.lib.lua Sun Sep 05 16:43:41 2021 +0200 @@ -323,7 +323,11 @@ 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 -r 5610f7c5b261 -r aa6ab07544c2 spec/scansion/pubsub_max_items.scs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/spec/scansion/pubsub_max_items.scs Sun Sep 05 16:43:41 2021 +0200 @@ -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: + +