Update StatusDelete job, handle cloud storage media deletes

This commit is contained in:
Daniel Supernault 2021-01-17 21:51:25 -07:00
parent aac4430970
commit 4b1a0fd750
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -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) {
}