25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-28 16:34:13 +01:00

Fix reverse order of items when using <before/> in Pubsub with RSM (#3621)

This commit is contained in:
Badlop 2021-06-10 20:21:44 +02:00
parent c2d8bc7b2f
commit 4ee10c155d

View File

@ -758,12 +758,12 @@ get_items(Nidx, _From, #rsm_set{max = Max, index = IncIndex,
{_, <<>>, undefined} -> {_, <<>>, undefined} ->
%% 2.5 Requesting the Last Page in a Result Set %% 2.5 Requesting the Last Page in a Result Set
SubList = lists:reverse(RItems), SubList = lists:reverse(RItems),
{Count, lists:sublist(SubList, Limit)}; {Count-Limit, lists:reverse(lists:sublist(SubList, Limit))};
{_, Stamp, undefined} -> {_, Stamp, undefined} ->
BeforeNow = encode_stamp(Stamp), BeforeNow = encode_stamp(Stamp),
{NewIndex, SubList} = extract_sublist(before_now, BeforeNow, {NewIndex, SubList} = extract_sublist(before_now, BeforeNow,
0, lists:reverse(RItems)), 0, lists:reverse(RItems)),
{Count-NewIndex-1, lists:sublist(SubList, Limit)}; {Count-NewIndex-Limit, lists:reverse(lists:sublist(SubList, Limit))};
{_, undefined, Stamp} -> {_, undefined, Stamp} ->
AfterNow = encode_stamp(Stamp), AfterNow = encode_stamp(Stamp),
{NewIndex, SubList} = extract_sublist(after_now, AfterNow, {NewIndex, SubList} = extract_sublist(after_now, AfterNow,