From 4b1a0fd7501eb82fc83341da82d53e12c1a36ce7 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 17 Jan 2021 21:51:25 -0700 Subject: [PATCH] Update StatusDelete job, handle cloud storage media deletes --- app/Jobs/StatusPipeline/StatusDelete.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/app/Jobs/StatusPipeline/StatusDelete.php b/app/Jobs/StatusPipeline/StatusDelete.php index ede5c67e..47ed14cf 100644 --- a/app/Jobs/StatusPipeline/StatusDelete.php +++ b/app/Jobs/StatusPipeline/StatusDelete.php @@ -2,7 +2,7 @@ namespace App\Jobs\StatusPipeline; -use DB; +use DB, Storage; use App\{ AccountInterstitial, MediaTag, @@ -17,6 +17,7 @@ use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use League\Fractal; +use Illuminate\Support\Str; use League\Fractal\Serializer\ArraySerializer; use App\Transformer\ActivityPub\Verb\DeleteNote; use App\Util\ActivityPub\Helpers; @@ -89,6 +90,24 @@ class StatusDelete implements ShouldQueue if (is_file($photo)) { unlink($photo); } + if( config('pixelfed.cloud_storage') == true) { + if( Str::of($media->media_path) + ->startsWith('public/') && + Storage::disk(config('filesystems.cloud')) + ->exists($media->media_path) + ) { + Storage::disk(config('filesystems.cloud')) + ->delete($media->media_path); + } + if( Str::of($media->thumbnail_path) + ->startsWith('public/') && + Storage::disk(config('filesystems.cloud')) + ->exists($media->thumbnail_path) + ) { + Storage::disk(config('filesystems.cloud')) + ->delete($media->media_path); + } + } $media->delete(); } catch (Exception $e) { }