From 2e7b77a4c4ab591903d4236bd61c01da2fccd15f Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 28 Dec 2022 19:34:16 -0700 Subject: [PATCH 1/3] Update DeleteAccountPipeline --- app/Jobs/DeletePipeline/DeleteAccountPipeline.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Jobs/DeletePipeline/DeleteAccountPipeline.php b/app/Jobs/DeletePipeline/DeleteAccountPipeline.php index b7e41fed..8325fb63 100644 --- a/app/Jobs/DeletePipeline/DeleteAccountPipeline.php +++ b/app/Jobs/DeletePipeline/DeleteAccountPipeline.php @@ -55,6 +55,7 @@ use App\Models\Poll; use App\Models\PollVote; use App\Models\Portfolio; use App\Models\UserPronoun; +use App\Jobs\StatusPipeline\StatusDelete; class DeleteAccountPipeline implements ShouldQueue { From 492b92140a81c4ee07cb4b239ec994e75f8f35b6 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 28 Dec 2022 19:42:25 -0700 Subject: [PATCH 2/3] Update DeleteAccountPipeline --- app/Jobs/DeletePipeline/DeleteAccountPipeline.php | 11 +++++------ app/Services/StatusService.php | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/Jobs/DeletePipeline/DeleteAccountPipeline.php b/app/Jobs/DeletePipeline/DeleteAccountPipeline.php index 8325fb63..652a8559 100644 --- a/app/Jobs/DeletePipeline/DeleteAccountPipeline.php +++ b/app/Jobs/DeletePipeline/DeleteAccountPipeline.php @@ -78,6 +78,11 @@ class DeleteAccountPipeline implements ShouldQueue $user = $this->user; $profile = $user->profile; $id = $user->profile_id; + Status::whereProfileId($id)->chunk(50, function($statuses) { + foreach($statuses as $status) { + StatusDelete::dispatchNow($status); + } + }); $this->deleteUserColumns($user); AccountService::del($user->profile_id); @@ -169,12 +174,6 @@ class DeleteAccountPipeline implements ShouldQueue DB::table('oauth_auth_codes')->whereUserId($user->id)->delete(); ProfileSponsor::whereProfileId($id)->delete(); - Status::whereProfileId($id)->chunk(50, function($statuses) { - foreach($statuses as $status) { - StatusDelete::dispatch($status)->onQueue('high'); - } - }); - Report::whereUserId($user->id)->forceDelete(); PublicTimelineService::warmCache(true, 400); Profile::whereUserId($user->id)->delete(); diff --git a/app/Services/StatusService.php b/app/Services/StatusService.php index 9f8188ce..d222ff26 100644 --- a/app/Services/StatusService.php +++ b/app/Services/StatusService.php @@ -137,9 +137,9 @@ class StatusService public static function del($id, $purge = false) { - $status = self::get($id); if($purge) { + $status = self::get($id); if($status && isset($status['account']) && isset($status['account']['id'])) { Cache::forget('profile:embed:' . $status['account']['id']); } From 26b5b42b866ed7fb584d47fb0c7047c18f15aa66 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 28 Dec 2022 19:42:42 -0700 Subject: [PATCH 3/3] Update WebfingerService --- app/Services/WebfingerService.php | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/app/Services/WebfingerService.php b/app/Services/WebfingerService.php index 78a0008b..385bff02 100644 --- a/app/Services/WebfingerService.php +++ b/app/Services/WebfingerService.php @@ -28,13 +28,17 @@ class WebfingerService return []; } - $res = Http::retry(3, 100) - ->acceptJson() - ->withHeaders([ - 'User-Agent' => '(Pixelfed/' . config('pixelfed.version') . '; +' . config('app.url') . ')' - ]) - ->timeout(20) - ->get($url); + try { + $res = Http::retry(3, 100) + ->acceptJson() + ->withHeaders([ + 'User-Agent' => '(Pixelfed/' . config('pixelfed.version') . '; +' . config('app.url') . ')' + ]) + ->timeout(20) + ->get($url); + } catch (\Illuminate\Http\Client\ConnectionException $e) { + return []; + } if(!$res->successful()) { return []; @@ -48,11 +52,9 @@ class WebfingerService $link = collect($webfinger['links']) ->filter(function($link) { return $link && - isset($link['rel']) && - isset($link['type']) && - isset($link['href']) && - $link['rel'] == 'self' && - $link['type'] == 'application/activity+json' || $link['type'] == 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'; + isset($link['rel'], $link['type'], $link['href']) && + $link['rel'] === 'self' && + in_array($link['type'], ['application/activity+json','application/ld+json; profile="https://www.w3.org/ns/activitystreams"']); }) ->pluck('href') ->first();