mirror of https://github.com/pixelfed/pixelfed
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
102 lines
2.9 KiB
PHP
102 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace App\Jobs\DeletePipeline;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use App\Bookmark;
|
|
use App\DirectMessage;
|
|
use App\Like;
|
|
use App\Media;
|
|
use App\MediaTag;
|
|
use App\Mention;
|
|
use App\Report;
|
|
use App\Status;
|
|
use App\StatusHashtag;
|
|
use App\StatusView;
|
|
use App\Notification;
|
|
use App\Services\AccountService;
|
|
use App\Services\NetworkTimelineService;
|
|
use App\Services\StatusService;
|
|
use App\Jobs\MediaPipeline\MediaDeletePipeline;
|
|
use Cache;
|
|
use App\Services\Account\AccountStatService;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class DeleteRemoteStatusPipeline implements ShouldQueue
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
protected $status;
|
|
|
|
public $timeout = 30;
|
|
public $tries = 2;
|
|
public $maxExceptions = 1;
|
|
public $deleteWhenMissingModels = true;
|
|
|
|
/**
|
|
* Create a new job instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct(Status $status)
|
|
{
|
|
$this->status = $status;
|
|
}
|
|
|
|
/**
|
|
* Execute the job.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function handle()
|
|
{
|
|
$status = $this->status;
|
|
|
|
// Verify status exists
|
|
if (!$status) {
|
|
Log::info("DeleteRemoteStatusPipeline: Status no longer exists, skipping job");
|
|
return;
|
|
}
|
|
|
|
// Verify status has a profile
|
|
if (!$status->profile_id) {
|
|
Log::info("DeleteRemoteStatusPipeline: Status {$status->id} has no profile_id, skipping job");
|
|
return;
|
|
}
|
|
|
|
try {
|
|
AccountStatService::decrementPostCount($status->profile_id);
|
|
NetworkTimelineService::del($status->id);
|
|
StatusService::del($status->id, true);
|
|
Bookmark::whereStatusId($status->id)->delete();
|
|
Notification::whereItemType('App\Status')
|
|
->whereItemId($status->id)
|
|
->forceDelete();
|
|
DirectMessage::whereStatusId($status->id)->delete();
|
|
Like::whereStatusId($status->id)->forceDelete();
|
|
MediaTag::whereStatusId($status->id)->delete();
|
|
Media::whereStatusId($status->id)
|
|
->get()
|
|
->each(function($media) {
|
|
MediaDeletePipeline::dispatch($media)->onQueue('mmo');
|
|
});
|
|
Mention::whereStatusId($status->id)->forceDelete();
|
|
Report::whereObjectType('App\Status')->whereObjectId($status->id)->delete();
|
|
StatusHashtag::whereStatusId($status->id)->delete();
|
|
StatusView::whereStatusId($status->id)->delete();
|
|
Status::whereReblogOfId($status->id)->forceDelete();
|
|
$status->forceDelete();
|
|
} catch (\Exception $e) {
|
|
Log::warning("DeleteRemoteStatusPipeline: Failed to delete status {$status->id}: " . $e->getMessage());
|
|
throw $e;
|
|
}
|
|
|
|
return 1;
|
|
}
|
|
}
|