From 1a130f3e334ce04fa4291c3f4c2c7c7a3af9bbb0 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 8 Feb 2023 02:47:24 -0700 Subject: [PATCH] Update ApiV1Controller, fix favourited_by and reblogged_by follows attribute --- app/Http/Controllers/Api/ApiV1Controller.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Api/ApiV1Controller.php b/app/Http/Controllers/Api/ApiV1Controller.php index f189604bc..8e9e7375b 100644 --- a/app/Http/Controllers/Api/ApiV1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Controller.php @@ -2519,8 +2519,13 @@ class ApiV1Controller extends Controller $headers = ['Link' => $links]; } - $res = $res->map(function($status) { - return AccountService::get($status->profile_id); + $res = $res->map(function($status) use($user) { + $account = AccountService::getMastodon($status->profile_id, true); + if(!$account) { + return false; + } + $account['follows'] = $status->profile_id == $user->profile_id ? null : FollowerService::follows($user->profile_id, $status->profile_id); + return $account; }) ->filter(function($account) { return $account && isset($account['id']); @@ -2594,9 +2599,12 @@ class ApiV1Controller extends Controller $headers = ['Link' => $links]; } - $res = $res->map(function($like) { + $res = $res->map(function($like) use($user) { $account = AccountService::getMastodon($like->profile_id, true); - $account['follows'] = isset($like->created_at); + if(!$account) { + return false; + } + $account['follows'] = $like->profile_id == $user->profile_id ? null : FollowerService::follows($user->profile_id, $like->profile_id); return $account; }) ->filter(function($account) use($user) {