From 738925c20d53628786262d8d6adc05f3bb56850c Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 9 Apr 2023 12:05:59 -0600 Subject: [PATCH] Update StatusController, allow users to delete replies to posts --- app/Http/Controllers/StatusController.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/StatusController.php b/app/Http/Controllers/StatusController.php index 087f679e0..4762c3f84 100644 --- a/app/Http/Controllers/StatusController.php +++ b/app/Http/Controllers/StatusController.php @@ -219,7 +219,17 @@ class StatusController extends Controller $u->save(); } - if ($status->profile_id == $user->profile->id || $user->is_admin == true) { + if($status->in_reply_to_id) { + $parent = Status::find($status->in_reply_to_id); + if($parent && ($parent->profile_id == $user->profile_id) || ($status->profile_id == $user->profile_id) || $user->is_admin) { + Cache::forget('_api:statuses:recent_9:' . $status->profile_id); + Cache::forget('profile:status_count:' . $status->profile_id); + Cache::forget('profile:embed:' . $status->profile_id); + StatusService::del($status->id, true); + Cache::forget('profile:status_count:'.$status->profile_id); + StatusDelete::dispatch($status); + } + } else if ($status->profile_id == $user->profile_id || $user->is_admin == true) { Cache::forget('_api:statuses:recent_9:' . $status->profile_id); Cache::forget('profile:status_count:' . $status->profile_id); Cache::forget('profile:embed:' . $status->profile_id);