1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-28 18:56:58 +00:00

Update ApiV1Controller, fix link header pagination

This commit is contained in:
Daniel Supernault 2020-03-19 15:29:18 -06:00
parent 0a9654e3b8
commit e3b7c7ccb1
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -1254,13 +1254,33 @@ class ApiV1Controller extends Controller
$baseUrl = config('app.url') . '/api/v1/notifications?'; $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([ 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, 'Link' => $link,
]); ]);
} }
return $res;
}
/** /**
* GET /api/v1/timelines/home * GET /api/v1/timelines/home
* *