forked from mirror/pixelfed
Update StatusDeletePipeline, use StorageMediaService for media deletes
This commit is contained in:
parent
ab5469ff70
commit
9fd90e174b
|
@ -26,6 +26,7 @@ use GuzzleHttp\Client;
|
||||||
use GuzzleHttp\Promise;
|
use GuzzleHttp\Promise;
|
||||||
use App\Util\ActivityPub\HttpSignature;
|
use App\Util\ActivityPub\HttpSignature;
|
||||||
use App\Services\StatusService;
|
use App\Services\StatusService;
|
||||||
|
use App\Services\MediaStorageService;
|
||||||
|
|
||||||
class StatusDelete implements ShouldQueue
|
class StatusDelete implements ShouldQueue
|
||||||
{
|
{
|
||||||
|
@ -82,38 +83,9 @@ class StatusDelete implements ShouldQueue
|
||||||
public function unlinkRemoveMedia($status)
|
public function unlinkRemoveMedia($status)
|
||||||
{
|
{
|
||||||
foreach ($status->media as $media) {
|
foreach ($status->media as $media) {
|
||||||
$thumbnail = storage_path("app/{$media->thumbnail_path}");
|
MediaStorageService::delete($media, true);
|
||||||
$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) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($status->in_reply_to_id) {
|
if($status->in_reply_to_id) {
|
||||||
DB::transaction(function() use($status) {
|
DB::transaction(function() use($status) {
|
||||||
$parent = Status::findOrFail($status->in_reply_to_id);
|
$parent = Status::findOrFail($status->in_reply_to_id);
|
||||||
|
|
Loading…
Reference in New Issue