diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b0cc291..a4a245ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -90,6 +90,8 @@ - Updated AccountController, refresh RelationshipService on mute/block. ([6f1b0245](https://github.com/pixelfed/pixelfed/commit/6f1b0245)) - Updated ApiV1Controller, fix version on instance endpoint. ([a6261221](https://github.com/pixelfed/pixelfed/commit/a6261221)) - Updated components, fix api endpoints. Fixes #3138. ([e724633e](https://github.com/pixelfed/pixelfed/commit/e724633e)) +- Updated ApiV1Controller, fix public timeline endpoint. ([80c7def3](https://github.com/pixelfed/pixelfed/commit/80c7def3)) +- Updated PublicApiController, fix public timeline endpoint. ([dcb7ba9c](https://github.com/pixelfed/pixelfed/commit/dcb7ba9c)) - ([](https://github.com/pixelfed/pixelfed/commit/)) ## [v0.11.1 (2021-09-07)](https://github.com/pixelfed/pixelfed/compare/v0.11.0...v0.11.1) diff --git a/app/Http/Controllers/Api/ApiV1Controller.php b/app/Http/Controllers/Api/ApiV1Controller.php index 00e98a99..3f116e3f 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); } diff --git a/app/Http/Controllers/PublicApiController.php b/app/Http/Controllers/PublicApiController.php index a15c517d..eb172148 100644 --- a/app/Http/Controllers/PublicApiController.php +++ b/app/Http/Controllers/PublicApiController.php @@ -323,6 +323,9 @@ class PublicApiController extends Controller ->get() ->map(function($s) use ($user) { $status = StatusService::getFull($s->id, $user->profile_id); + if(!$status) { + return false; + } $status['favourited'] = (bool) LikeService::liked($user->profile_id, $s->id); return $status; }) @@ -362,6 +365,9 @@ class PublicApiController extends Controller ->get() ->map(function($s) use ($user) { $status = StatusService::getFull($s->id, $user->profile_id); + if(!$status) { + return false; + } $status['favourited'] = (bool) LikeService::liked($user->profile_id, $s->id); return $status; }) @@ -777,7 +783,6 @@ class PublicApiController extends Controller $visibility = ['public', 'unlisted']; } } - $dir = $min_id ? '>' : '<'; $id = $min_id ?? $max_id; $res = Status::whereProfileId($profile['id'])