From 72f681607a1487045e9461d8ecb2163718fa689f Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 8 Jul 2024 02:47:00 -0600 Subject: [PATCH 1/2] Update ApiV1Controller, fix /api/v1/favourites pagination --- app/Http/Controllers/Api/ApiV1Controller.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Api/ApiV1Controller.php b/app/Http/Controllers/Api/ApiV1Controller.php index 627a6d3e8..3e45ec9e1 100644 --- a/app/Http/Controllers/Api/ApiV1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Controller.php @@ -1334,12 +1334,17 @@ class ApiV1Controller extends Controller if ($res->count()) { $ids = $res->map(function ($status) { return $status['like_id']; - }); - $max = $ids->max(); - $min = $ids->min(); + })->filter(); + + $max = $ids->min() - 1; + $min = $ids->max(); $baseUrl = config('app.url').'/api/v1/favourites?limit='.$limit.'&'; - $link = '<'.$baseUrl.'max_id='.$max.'>; rel="next",<'.$baseUrl.'min_id='.$min.'>; rel="prev"'; + if ($maxId) { + $link = '<'.$baseUrl.'max_id='.$max.'>; rel="next",<'.$baseUrl.'min_id='.$min.'>; rel="prev"'; + } else { + $link = '<'.$baseUrl.'max_id='.$max.'>; rel="next"'; + } return $this->json($res, 200, ['Link' => $link]); } else { From d3ef35fa22e0521bd6c6baea630e1c691793ad4f Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 8 Jul 2024 02:47:28 -0600 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96ec84051..5b739cd4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Updates - Update ApiV1Controller, add support for notification filter types ([f61159a1](https://github.com/pixelfed/pixelfed/commit/f61159a1)) - Update ApiV1Dot1Controller, fix mutual api ([a8bb97b2](https://github.com/pixelfed/pixelfed/commit/a8bb97b2)) +- Update ApiV1Controller, fix /api/v1/favourits pagination ([72f68160](https://github.com/pixelfed/pixelfed/commit/72f68160)) - ([](https://github.com/pixelfed/pixelfed/commit/)) ## [v0.12.3 (2024-07-01)](https://github.com/pixelfed/pixelfed/compare/v0.12.2...v0.12.3)