diff --git a/app/Http/Controllers/Admin/AdminReportController.php b/app/Http/Controllers/Admin/AdminReportController.php index d045edd55..4924acfa8 100644 --- a/app/Http/Controllers/Admin/AdminReportController.php +++ b/app/Http/Controllers/Admin/AdminReportController.php @@ -27,8 +27,8 @@ use App\Services\StoryService; use App\Services\ModLogService; use App\Jobs\DeletePipeline\DeleteAccountPipeline; use App\Jobs\DeletePipeline\DeleteRemoteProfilePipeline; -use App\Jobs\DeletePipeline\DeleteRemoteStatusPipeline; use App\Jobs\StatusPipeline\StatusDelete; +use App\Jobs\StatusPipeline\RemoteStatusDelete; use App\Http\Resources\AdminReport; use App\Http\Resources\AdminSpamReport; use App\Services\NotificationService; @@ -1049,7 +1049,7 @@ trait AdminReportController StatusDelete::dispatch($status)->onQueue('high'); } else { NetworkTimelineService::del($status->id); - DeleteRemoteStatusPipeline::dispatch($status)->onQueue('high'); + RemoteStatusDelete::dispatch($status)->onQueue('high'); } Report::whereObjectId($report->object_id) diff --git a/app/Http/Controllers/Api/ApiV1Dot1Controller.php b/app/Http/Controllers/Api/ApiV1Dot1Controller.php index 1b9fdcecd..6ed047af9 100644 --- a/app/Http/Controllers/Api/ApiV1Dot1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Dot1Controller.php @@ -34,6 +34,7 @@ use App\Mail\PasswordChange; use App\Mail\ConfirmAppEmail; use App\Http\Resources\StatusStateless; use App\Jobs\StatusPipeline\StatusDelete; +use App\Jobs\StatusPipeline\RemoteStatusDelete; use App\Jobs\ReportPipeline\ReportNotifyAdminViaEmail; use Illuminate\Support\Facades\RateLimiter; @@ -838,7 +839,7 @@ class ApiV1Dot1Controller extends Controller Cache::forget('profile:embed:' . $status->profile_id); StatusService::del($status->id, true); Cache::forget('profile:status_count:'.$status->profile_id); - StatusDelete::dispatch($status); + $status->uri ? RemoteStatusDelete::dispatch($status) : StatusDelete::dispatch($status); return []; } diff --git a/app/Http/Controllers/StatusController.php b/app/Http/Controllers/StatusController.php index 43ac03263..873f5eace 100644 --- a/app/Http/Controllers/StatusController.php +++ b/app/Http/Controllers/StatusController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers; use App\Jobs\ImageOptimizePipeline\ImageOptimize; use App\Jobs\StatusPipeline\NewStatusPipeline; use App\Jobs\StatusPipeline\StatusDelete; +use App\Jobs\StatusPipeline\RemoteStatusDelete; use App\Jobs\SharePipeline\SharePipeline; use App\Jobs\SharePipeline\UndoSharePipeline; use App\AccountInterstitial; @@ -242,7 +243,7 @@ class StatusController extends Controller Cache::forget('profile:embed:' . $status->profile_id); StatusService::del($status->id, true); Cache::forget('profile:status_count:'.$status->profile_id); - StatusDelete::dispatch($status); + $status->uri ? RemoteStatusDelete::dispatch($status) : StatusDelete::dispatch($status); } } else if ($status->profile_id == $user->profile_id || $user->is_admin == true) { Cache::forget('_api:statuses:recent_9:' . $status->profile_id); @@ -250,7 +251,7 @@ class StatusController extends Controller Cache::forget('profile:embed:' . $status->profile_id); StatusService::del($status->id, true); Cache::forget('profile:status_count:'.$status->profile_id); - StatusDelete::dispatch($status); + $status->uri ? RemoteStatusDelete::dispatch($status) : StatusDelete::dispatch($status); } if($request->wantsJson()) { diff --git a/app/Jobs/DeletePipeline/DeleteRemoteProfilePipeline.php b/app/Jobs/DeletePipeline/DeleteRemoteProfilePipeline.php index 095cf98e3..7dce73fdc 100644 --- a/app/Jobs/DeletePipeline/DeleteRemoteProfilePipeline.php +++ b/app/Jobs/DeletePipeline/DeleteRemoteProfilePipeline.php @@ -51,6 +51,7 @@ use App\Models\Conversation; use App\Models\Poll; use App\Models\PollVote; use App\Services\AccountService; +use App\Jobs\StatusPipeline\RemoteStatusDelete; class DeleteRemoteProfilePipeline implements ShouldQueue { @@ -86,7 +87,7 @@ class DeleteRemoteProfilePipeline implements ShouldQueue Status::whereProfileId($pid) ->chunk(50, function($statuses) { foreach($statuses as $status) { - DeleteRemoteStatusPipeline::dispatch($status)->onQueue('delete'); + RemoteStatusDelete::dispatch($status)->onQueue('delete'); } }); diff --git a/app/Jobs/StatusPipeline/RemoteStatusDelete.php b/app/Jobs/StatusPipeline/RemoteStatusDelete.php new file mode 100644 index 000000000..8725ba6a9 --- /dev/null +++ b/app/Jobs/StatusPipeline/RemoteStatusDelete.php @@ -0,0 +1,144 @@ +status = $status; + } + + /** + * Execute the job. + * + * @return void + */ + public function handle() + { + $status = $this->status; + $profile = $this->status->profile; + + StatusService::del($status->id, true); + + if($profile->status_count && $profile->status_count > 0) { + $profile->status_count = $profile->status_count - 1; + $profile->save(); + } + + return $this->unlinkRemoveMedia($status); + } + + public function unlinkRemoveMedia($status) + { + Media::whereStatusId($status->id) + ->get() + ->each(function($media) { + MediaDeletePipeline::dispatch($media); + }); + + if($status->in_reply_to_id) { + $parent = Status::findOrFail($status->in_reply_to_id); + --$parent->reply_count; + $parent->save(); + StatusService::del($parent->id); + } + + 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(); + }); + + 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->delete(); + + StatusService::del($status->id, true); + AccountService::del($status->profile_id); + + return 1; + } +} diff --git a/app/Util/ActivityPub/Inbox.php b/app/Util/ActivityPub/Inbox.php index fe9beeb27..4441becfb 100644 --- a/app/Util/ActivityPub/Inbox.php +++ b/app/Util/ActivityPub/Inbox.php @@ -25,7 +25,7 @@ use Illuminate\Support\Str; use App\Jobs\LikePipeline\LikePipeline; use App\Jobs\FollowPipeline\FollowPipeline; use App\Jobs\DeletePipeline\DeleteRemoteProfilePipeline; -use App\Jobs\DeletePipeline\DeleteRemoteStatusPipeline; +use App\Jobs\StatusPipeline\RemoteStatusDelete; use App\Jobs\StoryPipeline\StoryExpire; use App\Jobs\StoryPipeline\StoryFetch; use App\Jobs\StatusPipeline\StatusRemoteUpdatePipeline; @@ -707,7 +707,7 @@ class Inbox if(!$status) { return; } - DeleteRemoteStatusPipeline::dispatch($status)->onQueue('high'); + RemoteStatusDelete::dispatch($status)->onQueue('high'); return; break;