[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
This commit is contained in:
tobi
2023-09-29 15:31:10 +02:00
committed by GitHub
parent 736cd37caf
commit 2b6b9cdf83
7 changed files with 75 additions and 62 deletions

View File

@@ -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)