From 2b6b9cdf832078980ca668126bce3b4fcfff02a9 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Fri, 29 Sep 2023 15:31:10 +0200 Subject: [bugfix] Fix paging for empty items (#2236) * use minID properly for public timeline * return paged response properly even when 0 items * use gtserror * page more consistently (for now) * test * aaa --- internal/processing/account/statuses.go | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'internal/processing/account/statuses.go') diff --git a/internal/processing/account/statuses.go b/internal/processing/account/statuses.go index 99e9edbcf..716157a14 100644 --- a/internal/processing/account/statuses.go +++ b/internal/processing/account/statuses.go @@ -74,21 +74,8 @@ func (p *Processor) StatusesGet( return nil, gtserror.NewErrorInternalError(err) } - if len(statuses) == 0 { - return util.EmptyPageableResponse(), nil - } - - // Filtering + serialization process is the same for - // both pinned status queries and 'normal' ones. - filtered, err := p.filter.StatusesVisible(ctx, requestingAccount, statuses) - if err != nil { - return nil, gtserror.NewErrorInternalError(err) - } - - count := len(filtered) + count := len(statuses) if count == 0 { - // After filtering there were - // no statuses left to serve. return util.EmptyPageableResponse(), nil } @@ -97,10 +84,17 @@ func (p *Processor) StatusesGet( // Set next + prev values before filtering and API // converting, so caller can still page properly. - nextMaxIDValue = filtered[count-1].ID - prevMinIDValue = filtered[0].ID + nextMaxIDValue = statuses[count-1].ID + prevMinIDValue = statuses[0].ID ) + // Filtering + serialization process is the same for + // both pinned status queries and 'normal' ones. + filtered, err := p.filter.StatusesVisible(ctx, requestingAccount, statuses) + if err != nil { + return nil, gtserror.NewErrorInternalError(err) + } + for _, s := range filtered { // Convert filtered statuses to API statuses. item, err := p.converter.StatusToAPIStatus(ctx, s, requestingAccount) -- cgit v1.2.3