From 4e79c772826f0e2db4c01259a1d27c5d79c7b3dc Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 25 Mar 2023 06:19:04 -0600 Subject: [PATCH 1/3] Update ApiV1Controller, improve timeline account hydration --- app/Http/Controllers/Api/ApiV1Controller.php | 24 +++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Api/ApiV1Controller.php b/app/Http/Controllers/Api/ApiV1Controller.php index d4c994bc5..0877fc9db 100644 --- a/app/Http/Controllers/Api/ApiV1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Controller.php @@ -2130,6 +2130,10 @@ class ApiV1Controller extends Controller ->get() ->map(function($s) use($pid, $napi) { try { + $account = $napi ? AccountService::get($s['profile_id'], true) : AccountService::getMastodon($s['profile_id'], true); + if(!$account) { + return false; + } $status = $napi ? StatusService::get($s['id'], false) : StatusService::getMastodon($s['id'], false); if(!$status || !isset($status['account']) || !isset($status['account']['id'])) { return false; @@ -2138,6 +2142,8 @@ class ApiV1Controller extends Controller return false; } + $status['account'] = $account; + if($pid) { $status['favourited'] = (bool) LikeService::liked($pid, $s['id']); $status['reblogged'] = (bool) ReblogService::get($pid, $status['id']); @@ -2167,7 +2173,7 @@ class ApiV1Controller extends Controller ->get() ->map(function($s) use($pid, $napi) { try { - $account = AccountService::get($s['profile_id'], true); + $account = $napi ? AccountService::get($s['profile_id'], true) : AccountService::getMastodon($s['profile_id'], true); if(!$account) { return false; } @@ -2179,6 +2185,8 @@ class ApiV1Controller extends Controller return false; } + $status['account'] = $account; + if($pid) { $status['favourited'] = (bool) LikeService::liked($pid, $s['id']); $status['reblogged'] = (bool) ReblogService::get($pid, $status['id']); @@ -2289,11 +2297,21 @@ class ApiV1Controller extends Controller } }) ->map(function($k) use($user, $napi) { - $status = $napi ? StatusService::get($k) : StatusService::getMastodon($k); - if(!$status || !isset($status['account']) || !isset($status['account']['id'])) { + try { + $status = $napi ? StatusService::get($k) : StatusService::getMastodon($k); + } catch(\Exception $e) { + if(!$status || !isset($status['account']) || !isset($status['account']['id'])) { + return false; + } + } + + $account = $napi ? AccountService::get($status['account']['id'], true) : AccountService::getMastodon($status['account']['id'], true); + if(!$account) { return false; } + $status['account'] = $account; + if($user) { $status['favourited'] = (bool) LikeService::liked($user->profile_id, $k); $status['reblogged'] = (bool) ReblogService::get($user->profile_id, $status['id']); From 4d5614726f3e9e82442887a796f65730f40dbf6e Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 25 Mar 2023 06:30:33 -0600 Subject: [PATCH 2/3] Update ApiV1Controller, improve timeline account hydration --- app/Http/Controllers/Api/ApiV1Controller.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/ApiV1Controller.php b/app/Http/Controllers/Api/ApiV1Controller.php index 0877fc9db..77df97704 100644 --- a/app/Http/Controllers/Api/ApiV1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Controller.php @@ -2299,10 +2299,11 @@ class ApiV1Controller extends Controller ->map(function($k) use($user, $napi) { try { $status = $napi ? StatusService::get($k) : StatusService::getMastodon($k); - } catch(\Exception $e) { if(!$status || !isset($status['account']) || !isset($status['account']['id'])) { return false; } + } catch(\Exception $e) { + return false; } $account = $napi ? AccountService::get($status['account']['id'], true) : AccountService::getMastodon($status['account']['id'], true); From b64dbe17a2c88c0b12128a32ae21d9422490c989 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 25 Mar 2023 06:32:00 -0600 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f5c777634..ebbb6b52c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -143,6 +143,7 @@ - Update private profile view, add rel=me support, hide avatar/bio when not logged in and add robots meta tag to block search engine indexing on private profiles ([ab4bb9a0](https://github.com/pixelfed/pixelfed/commit/ab4bb9a0)) - Update settings, set maxlength on name and bio inputs. Fixes #4248 ([558700fc](https://github.com/pixelfed/pixelfed/commit/558700fc)) - Update api routes, add post method support to /api/v1/accounts/update_credentials to properly handle binary form data (avatars). Fixes #4250 ([1ae19ea5](https://github.com/pixelfed/pixelfed/commit/1ae19ea5)) +- Update ApiV1Controller, improve timeline account hydration ([4e79c772](https://github.com/pixelfed/pixelfed/commit/4e79c772)) - ([](https://github.com/pixelfed/pixelfed/commit/)) ## [v0.11.4 (2022-10-04)](https://github.com/pixelfed/pixelfed/compare/v0.11.3...v0.11.4)