mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-09 16:24:51 +00:00
Update ApiV1Controller, fix /api/v1/favourites pagination
This commit is contained in:
parent
2aa8dd8613
commit
72f681607a
1 changed files with 9 additions and 4 deletions
|
@ -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.'&';
|
||||
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 {
|
||||
|
|
Loading…
Reference in a new issue