diff options
author | 2023-09-29 15:31:10 +0200 | |
---|---|---|
committer | 2023-09-29 15:31:10 +0200 | |
commit | 2b6b9cdf832078980ca668126bce3b4fcfff02a9 (patch) | |
tree | 77928699c5e40a20233ad2b795213cdb98a7d92e /internal/processing/account/statuses.go | |
parent | [frontend] Add `discoverable` flag to settings panel (#2235) (diff) | |
download | gotosocial-2b6b9cdf832078980ca668126bce3b4fcfff02a9.tar.xz |
[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
Diffstat (limited to 'internal/processing/account/statuses.go')
-rw-r--r-- | internal/processing/account/statuses.go | 26 |
1 files changed, 10 insertions, 16 deletions
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) |