mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 14:31:26 +00:00
Update ApiV1Controller, fix link header pagination
This commit is contained in:
parent
0a9654e3b8
commit
e3b7c7ccb1
1 changed files with 24 additions and 4 deletions
|
@ -1254,11 +1254,31 @@ class ApiV1Controller extends Controller
|
|||
|
||||
$baseUrl = config('app.url') . '/api/v1/notifications?';
|
||||
|
||||
$link = '<'.$baseUrl.'max_id='.$maxId.'>; rel="next",<'.$baseUrl.'min_id='.$minId.'>; rel="prev"';
|
||||
if($minId == $maxId) {
|
||||
$minId = null;
|
||||
}
|
||||
|
||||
return response()->json($res)->withHeaders([
|
||||
'Link' => $link,
|
||||
]);
|
||||
if($maxId) {
|
||||
$link = '<'.$baseUrl.'max_id='.$maxId.'>; rel="next"';
|
||||
}
|
||||
|
||||
if($minId) {
|
||||
$link = '<'.$baseUrl.'min_id='.$minId.'>; rel="prev"';
|
||||
}
|
||||
|
||||
if($maxId && $minId) {
|
||||
$link = '<'.$baseUrl.'max_id='.$maxId.'>; rel="next",<'.$baseUrl.'min_id='.$minId.'>; rel="prev"';
|
||||
}
|
||||
|
||||
$res = response()->json($res);
|
||||
|
||||
if(isset($link)) {
|
||||
$res->withHeaders([
|
||||
'Link' => $link,
|
||||
]);
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue