From 5ce158a272b400b3ee4a4b6a1613919b0c500053 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 17 Nov 2022 19:43:01 -0700 Subject: [PATCH 1/4] Update SendUpdateActor command --- app/Console/Commands/SendUpdateActor.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Console/Commands/SendUpdateActor.php b/app/Console/Commands/SendUpdateActor.php index a874ee7c8..369d582a4 100644 --- a/app/Console/Commands/SendUpdateActor.php +++ b/app/Console/Commands/SendUpdateActor.php @@ -80,7 +80,8 @@ class SendUpdateActor extends Command $bar->start(); $startCache = $this->getStorageCache($domain); - User::whereNull('status')->when($startCache, function($query, $startCache) { + User::whereNull('status')->when($startCache, function($query, $startCache) use($bar) { + $bar->advance($startCache); return $query->where('id', '>', $startCache); })->chunk(50, function($users) use($bar, $url, $domain) { foreach($users as $user) { From 8b7121f9fbcb65f77f5b7a80370873b0d60b5804 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 17 Nov 2022 19:51:48 -0700 Subject: [PATCH 2/4] Update AccountService, fix delete status --- app/Services/AccountService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Services/AccountService.php b/app/Services/AccountService.php index 13cccffab..abdc25ad2 100644 --- a/app/Services/AccountService.php +++ b/app/Services/AccountService.php @@ -23,7 +23,7 @@ class AccountService $fractal = new Fractal\Manager(); $fractal->setSerializer(new ArraySerializer()); $profile = Profile::find($id); - if(!$profile) { + if(!$profile || $profile->status === 'delete') { if($softFail) { return null; } From e71972d8f1e3bcad2ecd6ae3783af109e811f3d1 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 17 Nov 2022 20:13:26 -0700 Subject: [PATCH 3/4] Update ApiV1Controller, map AccountService --- app/Http/Controllers/Api/ApiV1Controller.php | 11 +++++++++-- app/Services/AccountService.php | 14 ++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/Api/ApiV1Controller.php b/app/Http/Controllers/Api/ApiV1Controller.php index ea555dfd4..d2c8b2028 100644 --- a/app/Http/Controllers/Api/ApiV1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Controller.php @@ -3023,7 +3023,7 @@ class ApiV1Controller extends Controller } if($sortBy == 'all' && !$request->has('cursor')) { - $ids = Cache::remember('status:replies:all:' . $id, 86400, function() use($id) { + $ids = Cache::remember('status:replies:all:' . $id, 3600, function() use($id) { return DB::table('statuses') ->where('in_reply_to_id', $id) ->orderBy('id') @@ -3058,8 +3058,15 @@ class ApiV1Controller extends Controller $status['favourited'] = LikeService::liked($pid, $post->id); return $status; }) + ->map(function($post) { + if(isset($post['account']) && isset($post['account']['id'])) { + $account = AccountService::get($post['account']['id'], true); + $post['account'] = $account; + } + return $post; + }) ->filter(function($post) { - return $post && isset($post['id']) && isset($post['account']); + return $post && isset($post['id']) && isset($post['account']) && isset($post['account']['id']); }) ->values(); diff --git a/app/Services/AccountService.php b/app/Services/AccountService.php index abdc25ad2..eb744ff9d 100644 --- a/app/Services/AccountService.php +++ b/app/Services/AccountService.php @@ -19,19 +19,21 @@ class AccountService public static function get($id, $softFail = false) { - return Cache::remember(self::CACHE_KEY . $id, 43200, function() use($id, $softFail) { + $res = Cache::remember(self::CACHE_KEY . $id, 43200, function() use($id) { $fractal = new Fractal\Manager(); $fractal->setSerializer(new ArraySerializer()); $profile = Profile::find($id); if(!$profile || $profile->status === 'delete') { - if($softFail) { - return null; - } - abort(404); + return null; } $resource = new Fractal\Resource\Item($profile, new AccountTransformer()); return $fractal->createData($resource)->toArray(); - }); + }); + + if(!$res) { + return $softFail ? null : abort(404); + } + return $res; } public static function getMastodon($id, $softFail = false) From 078966edb8c4e1986d03826621b4053ca71bf0c6 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 17 Nov 2022 20:13:52 -0700 Subject: [PATCH 4/4] Update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f39660d7..875c8c837 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,9 @@ - Enable network timeline caching by default ([c990ac2a](https://github.com/pixelfed/pixelfed/commit/c990ac2a)) - Redirect /home to / ([97032997](https://github.com/pixelfed/pixelfed/commit/97032997)) - Fix 2FA backup code bug ([a231b3c5](https://github.com/pixelfed/pixelfed/commit/a231b3c5)) +- Update federation config, enable remote follows by default ([59702d40](https://github.com/pixelfed/pixelfed/commit/59702d40)) +- Update ApiV1Controller, fix followAccountById with firstOrCreate() ([1d52ad0b](https://github.com/pixelfed/pixelfed/commit/1d52ad0b)) +- Update AccountService, fix delete status ([8b7121f9](https://github.com/pixelfed/pixelfed/commit/8b7121f9)) - ([](https://github.com/pixelfed/pixelfed/commit/)) ## [v0.11.4 (2022-10-04)](https://github.com/pixelfed/pixelfed/compare/v0.11.3...v0.11.4)