From 80c7def3dfca099a12604710c6442517c4ed0aee Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 9 Jan 2022 19:30:53 -0700 Subject: [PATCH] Update ApiV1Controller, fix public timeline endpoint --- app/Http/Controllers/Api/ApiV1Controller.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/ApiV1Controller.php b/app/Http/Controllers/Api/ApiV1Controller.php index 00e98a991..3f116e3f1 100644 --- a/app/Http/Controllers/Api/ApiV1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Controller.php @@ -1794,6 +1794,10 @@ class ApiV1Controller extends Controller $res = collect($feed) ->map(function($k) use($user) { $status = StatusService::getMastodon($k); + if(!$status || !isset($status['account']) || !isset($status['account']['id'])) { + return false; + } + if($user) { $status['favourited'] = (bool) LikeService::liked($user->profile_id, $k); $status['relationship'] = RelationshipService::get($user->profile_id, $status['account']['id']); @@ -1801,8 +1805,9 @@ class ApiV1Controller extends Controller return $status; }) ->filter(function($s) use($filtered) { - return in_array($s['account']['id'], $filtered) == false; + return $s && isset($s['account']) && in_array($s['account']['id'], $filtered) == false; }) + ->values() ->toArray(); return response()->json($res); }