|
|
|
@ -5,12 +5,19 @@ namespace App\Jobs\StatusPipeline;
|
|
|
|
|
use DB, Storage;
|
|
|
|
|
use App\{
|
|
|
|
|
AccountInterstitial,
|
|
|
|
|
Bookmark,
|
|
|
|
|
CollectionItem,
|
|
|
|
|
DirectMessage,
|
|
|
|
|
Like,
|
|
|
|
|
Media,
|
|
|
|
|
MediaTag,
|
|
|
|
|
Mention,
|
|
|
|
|
Notification,
|
|
|
|
|
Report,
|
|
|
|
|
Status,
|
|
|
|
|
StatusArchived,
|
|
|
|
|
StatusHashtag,
|
|
|
|
|
StatusView
|
|
|
|
|
};
|
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
@ -28,7 +35,7 @@ use GuzzleHttp\Promise;
|
|
|
|
|
use App\Util\ActivityPub\HttpSignature;
|
|
|
|
|
use App\Services\CollectionService;
|
|
|
|
|
use App\Services\StatusService;
|
|
|
|
|
use App\Services\MediaStorageService;
|
|
|
|
|
use App\Jobs\MediaPipeline\MediaDeletePipeline;
|
|
|
|
|
|
|
|
|
|
class StatusDelete implements ShouldQueue
|
|
|
|
|
{
|
|
|
|
@ -71,75 +78,65 @@ class StatusDelete implements ShouldQueue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(config_cache('federation.activitypub.enabled') == true) {
|
|
|
|
|
$this->fanoutDelete($status);
|
|
|
|
|
return $this->fanoutDelete($status);
|
|
|
|
|
} else {
|
|
|
|
|
$this->unlinkRemoveMedia($status);
|
|
|
|
|
return $this->unlinkRemoveMedia($status);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function unlinkRemoveMedia($status)
|
|
|
|
|
{
|
|
|
|
|
foreach ($status->media as $media) {
|
|
|
|
|
MediaStorageService::delete($media, true);
|
|
|
|
|
}
|
|
|
|
|
Media::whereStatusId($status->id)
|
|
|
|
|
->get()
|
|
|
|
|
->each(function($media) {
|
|
|
|
|
MediaDeletePipeline::dispatchNow($media);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if($status->in_reply_to_id) {
|
|
|
|
|
DB::transaction(function() use($status) {
|
|
|
|
|
$parent = Status::findOrFail($status->in_reply_to_id);
|
|
|
|
|
--$parent->reply_count;
|
|
|
|
|
$parent->save();
|
|
|
|
|
});
|
|
|
|
|
$parent = Status::findOrFail($status->in_reply_to_id);
|
|
|
|
|
--$parent->reply_count;
|
|
|
|
|
$parent->save();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DB::transaction(function() use($status) {
|
|
|
|
|
CollectionItem::whereObjectType('App\Status')
|
|
|
|
|
->whereObjectId($status->id)
|
|
|
|
|
->get()
|
|
|
|
|
->each(function($col) {
|
|
|
|
|
$id = $col->collection_id;
|
|
|
|
|
$sid = $col->object_id;
|
|
|
|
|
$col->delete();
|
|
|
|
|
CollectionService::removeItem($id, $sid);
|
|
|
|
|
});
|
|
|
|
|
Bookmark::whereStatusId($status->id)->delete();
|
|
|
|
|
|
|
|
|
|
CollectionItem::whereObjectType('App\Status')
|
|
|
|
|
->whereObjectId($status->id)
|
|
|
|
|
->get()
|
|
|
|
|
->each(function($col) {
|
|
|
|
|
CollectionService::removeItem($col->collection_id, $col->object_id);
|
|
|
|
|
$col->delete();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
DB::transaction(function() use($status) {
|
|
|
|
|
$comments = Status::where('in_reply_to_id', $status->id)->get();
|
|
|
|
|
foreach ($comments as $comment) {
|
|
|
|
|
$comment->in_reply_to_id = null;
|
|
|
|
|
$comment->save();
|
|
|
|
|
Notification::whereItemType('App\Status')
|
|
|
|
|
->whereItemId($comment->id)
|
|
|
|
|
->delete();
|
|
|
|
|
}
|
|
|
|
|
$status->likes()->delete();
|
|
|
|
|
Notification::whereItemType('App\Status')
|
|
|
|
|
->whereItemId($status->id)
|
|
|
|
|
->delete();
|
|
|
|
|
StatusHashtag::whereStatusId($status->id)->delete();
|
|
|
|
|
Report::whereObjectType('App\Status')
|
|
|
|
|
->whereObjectId($status->id)
|
|
|
|
|
->delete();
|
|
|
|
|
MediaTag::where('status_id', $status->id)
|
|
|
|
|
->cursor()
|
|
|
|
|
->each(function($tag) {
|
|
|
|
|
Notification::where('item_type', 'App\MediaTag')
|
|
|
|
|
->where('item_id', $tag->id)
|
|
|
|
|
->forceDelete();
|
|
|
|
|
$tag->delete();
|
|
|
|
|
});
|
|
|
|
|
AccountInterstitial::where('item_type', 'App\Status')
|
|
|
|
|
->where('item_id', $status->id)
|
|
|
|
|
->delete();
|
|
|
|
|
|
|
|
|
|
$status->forceDelete();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
DirectMessage::whereStatusId($status->id)->delete();
|
|
|
|
|
Like::whereStatusId($status->id)->delete();
|
|
|
|
|
|
|
|
|
|
MediaTag::where('status_id', $status->id)->delete();
|
|
|
|
|
Mention::whereStatusId($status->id)->forceDelete();
|
|
|
|
|
|
|
|
|
|
Notification::whereItemType('App\Status')
|
|
|
|
|
->whereItemId($status->id)
|
|
|
|
|
->forceDelete();
|
|
|
|
|
|
|
|
|
|
Report::whereObjectType('App\Status')
|
|
|
|
|
->whereObjectId($status->id)
|
|
|
|
|
->delete();
|
|
|
|
|
|
|
|
|
|
StatusArchived::whereStatusId($status->id)->delete();
|
|
|
|
|
StatusHashtag::whereStatusId($status->id)->delete();
|
|
|
|
|
StatusView::whereStatusId($status->id)->delete();
|
|
|
|
|
Status::whereInReplyToId($status->id)->update(['in_reply_to_id' => null]);
|
|
|
|
|
|
|
|
|
|
AccountInterstitial::where('item_type', 'App\Status')
|
|
|
|
|
->where('item_id', $status->id)
|
|
|
|
|
->delete();
|
|
|
|
|
|
|
|
|
|
$status->forceDelete();
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function fanoutDelete($status)
|
|
|
|
|
public function fanoutDelete($status)
|
|
|
|
|
{
|
|
|
|
|
$audience = $status->profile->getAudienceInbox();
|
|
|
|
|
$profile = $status->profile;
|
|
|
|
@ -189,5 +186,6 @@ class StatusDelete implements ShouldQueue
|
|
|
|
|
|
|
|
|
|
$promise->wait();
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|