Update StatusDeletePipeline, use StorageMediaService for media deletes

This commit is contained in:
Daniel Supernault 2021-02-05 21:05:58 -07:00
parent ab5469ff70
commit 9fd90e174b
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -26,6 +26,7 @@ use GuzzleHttp\Client;
use GuzzleHttp\Promise;
use App\Util\ActivityPub\HttpSignature;
use App\Services\StatusService;
use App\Services\MediaStorageService;
class StatusDelete implements ShouldQueue
{
@ -82,38 +83,9 @@ class StatusDelete implements ShouldQueue
public function unlinkRemoveMedia($status)
{
foreach ($status->media as $media) {
$thumbnail = storage_path("app/{$media->thumbnail_path}");
$photo = storage_path("app/{$media->media_path}");
try {
if (is_file($thumbnail)) {
unlink($thumbnail);
}
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->thumbnail_path);
}
}
$media->delete();
} catch (Exception $e) {
}
MediaStorageService::delete($media, true);
}
if($status->in_reply_to_id) {
DB::transaction(function() use($status) {
$parent = Status::findOrFail($status->in_reply_to_id);