mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[chore] much improved paging package (#2182)
This commit is contained in:
@@ -34,11 +34,11 @@ import (
|
||||
func (p *Processor) BlocksGet(
|
||||
ctx context.Context,
|
||||
requestingAccount *gtsmodel.Account,
|
||||
page paging.Pager,
|
||||
page *paging.Page,
|
||||
) (*apimodel.PageableResponse, gtserror.WithCode) {
|
||||
blocks, err := p.state.DB.GetAccountBlocks(ctx,
|
||||
requestingAccount.ID,
|
||||
&page,
|
||||
page,
|
||||
)
|
||||
if err != nil && !errors.Is(err, db.ErrNoEntries) {
|
||||
return nil, gtserror.NewErrorInternalError(err)
|
||||
@@ -77,13 +77,10 @@ func (p *Processor) BlocksGet(
|
||||
items = append(items, account)
|
||||
}
|
||||
|
||||
return util.PackagePageableResponse(util.PageableResponseParams{
|
||||
Items: items,
|
||||
Path: "/api/v1/blocks",
|
||||
NextMaxIDKey: "max_id",
|
||||
PrevMinIDKey: "since_id",
|
||||
NextMaxIDValue: nextMaxIDValue,
|
||||
PrevMinIDValue: prevMinIDValue,
|
||||
Limit: page.Limit,
|
||||
})
|
||||
return paging.PackageResponse(paging.ResponseParams{
|
||||
Items: items,
|
||||
Path: "/api/v1/blocks",
|
||||
Next: page.Next(nextMaxIDValue),
|
||||
Prev: page.Prev(prevMinIDValue),
|
||||
}), nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user