2022-10-07 09:15:34 +00:00
|
|
|
<?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;
|
2022-12-24 11:28:52 +00:00
|
|
|
use App\Services\AccountService;
|
2022-10-07 09:15:34 +00:00
|
|
|
use App\Services\NetworkTimelineService;
|
|
|
|
use App\Services\StatusService;
|
|
|
|
use App\Jobs\ProfilePipeline\DecrementPostCount;
|
|
|
|
use App\Jobs\MediaPipeline\MediaDeletePipeline;
|
2022-12-24 11:28:52 +00:00
|
|
|
use Cache;
|
2022-10-07 09:15:34 +00:00
|
|
|
|
|
|
|
class DeleteRemoteStatusPipeline implements ShouldQueue
|
|
|
|
{
|
|
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
|
|
|
|
protected $status;
|
|
|
|
|
2022-12-24 11:28:52 +00:00
|
|
|
public $timeout = 30;
|
|
|
|
public $tries = 2;
|
2022-12-24 09:01:30 +00:00
|
|
|
public $maxExceptions = 1;
|
2022-12-24 11:28:52 +00:00
|
|
|
public $deleteWhenMissingModels = true;
|
2022-12-24 09:01:30 +00:00
|
|
|
|
2022-10-07 09:15:34 +00:00
|
|
|
/**
|
|
|
|
* Create a new job instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct(Status $status)
|
|
|
|
{
|
2022-12-24 11:28:52 +00:00
|
|
|
$this->status = $status;
|
2022-10-07 09:15:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the job.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
|
|
|
$status = $this->status;
|
|
|
|
|
2022-12-24 11:28:52 +00:00
|
|
|
if(AccountService::get($status->profile_id, true)) {
|
|
|
|
DecrementPostCount::dispatch($status->profile_id)->onQueue('feed');
|
|
|
|
}
|
|
|
|
|
2022-10-07 09:15:34 +00:00
|
|
|
NetworkTimelineService::del($status->id);
|
2023-03-25 07:23:05 +00:00
|
|
|
StatusService::del($status->id, true);
|
2022-10-07 09:15:34 +00:00
|
|
|
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) {
|
2022-12-24 09:01:30 +00:00
|
|
|
MediaDeletePipeline::dispatch($media)->onQueue('mmo');
|
2022-10-07 09:15:34 +00:00
|
|
|
});
|
|
|
|
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();
|
2022-12-24 11:28:52 +00:00
|
|
|
$status->forceDelete();
|
|
|
|
return 1;
|
2022-10-07 09:15:34 +00:00
|
|
|
}
|
|
|
|
}
|