From 126653e01b2651ee422229cd2bc46439a8fcf98a Mon Sep 17 00:00:00 2001 From: Christophe Romain Date: Wed, 27 Sep 2017 20:54:50 +0200 Subject: Pubsub: implment '6.5.7 Requesting the Most Recent Items' --- src/mod_pubsub.erl | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src/mod_pubsub.erl') diff --git a/src/mod_pubsub.erl b/src/mod_pubsub.erl index 669422d1..0f344cc1 100644 --- a/src/mod_pubsub.erl +++ b/src/mod_pubsub.erl @@ -1959,15 +1959,11 @@ purge_node(Host, Node, Owner) -> -spec get_items(host(), binary(), jid(), binary(), binary(), [binary()], undefined | rsm_set()) -> {result, pubsub()} | {error, stanza_error()}. -get_items(Host, Node, From, SubId, SMaxItems, ItemIds, RSM) -> - MaxItems = if SMaxItems == undefined -> - case get_max_items_node(Host) of - undefined -> ?MAXITEMS; - Max -> Max - end; - true -> - SMaxItems - end, +get_items(Host, Node, From, SubId, MaxItems, ItemIds, undefined) + when MaxItems =/= undefined -> + get_items(Host, Node, From, SubId, MaxItems, ItemIds, + #rsm_set{max = MaxItems, before = <<>>}); +get_items(Host, Node, From, SubId, _MaxItems, ItemIds, RSM) -> Action = fun(#pubsub_node{options = Options, type = Type, id = Nidx, owners = O}) -> @@ -2009,7 +2005,7 @@ get_items(Host, Node, From, SubId, SMaxItems, ItemIds, RSM) -> end, {result, #pubsub{items = #ps_items{node = Node, - items = itemsEls(lists:sublist(SendItems, MaxItems))}, + items = itemsEls(SendItems)}, rsm = RsmOut}}; {result, {_, Item}} -> {result, -- cgit v1.2.3