Update PublicApiController, fix edge case in timeline pagination

This commit is contained in:
Daniel Supernault 2022-04-03 00:50:25 -06:00
parent aa4b011e25
commit 9a7289198a
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -378,7 +378,7 @@ class PublicApiController extends Controller
return $status;
})
->filter(function($s) use($filtered) {
return $s && in_array($s['account']['id'], $filtered) == false;
return $s && isset($s['account']) && in_array($s['account']['id'], $filtered) == false;
})
->values();
@ -402,7 +402,7 @@ class PublicApiController extends Controller
$res = collect($feed)
->map(function($k) use($user) {
$status = StatusService::get($k);
if($user) {
if($status && isset($status['account']) && $user) {
$status['favourited'] = (bool) LikeService::liked($user->profile_id, $k);
$status['bookmarked'] = (bool) BookmarkService::get($user->profile_id, $k);
$status['reblogged'] = (bool) ReblogService::get($user->profile_id, $k);
@ -411,7 +411,7 @@ class PublicApiController extends Controller
return $status;
})
->filter(function($s) use($filtered) {
return isset($s['account']) && in_array($s['account']['id'], $filtered) == false;
return $s && isset($s['account']) && in_array($s['account']['id'], $filtered) == false;
})
->values()
->toArray();