From 574bafd9504931889db80cef4c90d064a2273de5 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 11 Jul 2024 12:50:12 +0200 Subject: [PATCH] fix: cleanup parameter --- app/Http/Controllers/Api/ApplicationsController.php | 7 +++++-- app/Http/Controllers/Api/DatabasesController.php | 7 +++++-- app/Jobs/DeleteResourceJob.php | 5 ++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/Api/ApplicationsController.php b/app/Http/Controllers/Api/ApplicationsController.php index 6c2f8e24b..d8175ffe9 100644 --- a/app/Http/Controllers/Api/ApplicationsController.php +++ b/app/Http/Controllers/Api/ApplicationsController.php @@ -1283,7 +1283,7 @@ public function application_by_uuid(Request $request) public function delete_by_uuid(Request $request) { $teamId = getTeamIdFromToken(); - $cleanup = $request->query->get('cleanup') ?? true; + $cleanup = filter_var($request->query->get('cleanup', true), FILTER_VALIDATE_BOOLEAN); if (is_null($teamId)) { return invalidTokenResponse(); } @@ -1297,7 +1297,10 @@ public function delete_by_uuid(Request $request) 'message' => 'Application not found', ], 404); } - DeleteResourceJob::dispatch($application, deleteConfigurations: $cleanup, deleteVolumes: $cleanup); + DeleteResourceJob::dispatch( + resource: $application, + deleteConfigurations: $cleanup, + deleteVolumes: $cleanup); return response()->json([ 'message' => 'Application deletion request queued.', diff --git a/app/Http/Controllers/Api/DatabasesController.php b/app/Http/Controllers/Api/DatabasesController.php index 7cf32e058..0f1ee00d8 100644 --- a/app/Http/Controllers/Api/DatabasesController.php +++ b/app/Http/Controllers/Api/DatabasesController.php @@ -1572,7 +1572,7 @@ public function create_database(Request $request, NewDatabaseTypes $type) public function delete_by_uuid(Request $request) { $teamId = getTeamIdFromToken(); - $cleanup = $request->query->get('cleanup') ?? true; + $cleanup = filter_var($request->query->get('cleanup', true), FILTER_VALIDATE_BOOLEAN); if (is_null($teamId)) { return invalidTokenResponse(); } @@ -1583,7 +1583,10 @@ public function delete_by_uuid(Request $request) if (! $database) { return response()->json(['message' => 'Database not found.'], 404); } - DeleteResourceJob::dispatch($database, deleteConfigurations: $cleanup, deleteVolumes: $cleanup); + DeleteResourceJob::dispatch( + resource: $database, + deleteConfigurations: $cleanup, + deleteVolumes: $cleanup); return response()->json([ 'message' => 'Database deletion request queued.', diff --git a/app/Jobs/DeleteResourceJob.php b/app/Jobs/DeleteResourceJob.php index 9ecbfc09e..68663f3a2 100644 --- a/app/Jobs/DeleteResourceJob.php +++ b/app/Jobs/DeleteResourceJob.php @@ -28,7 +28,10 @@ class DeleteResourceJob implements ShouldBeEncrypted, ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; - public function __construct(public Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse $resource, public bool $deleteConfigurations = false, public bool $deleteVolumes = false) {} + public function __construct( + public Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse $resource, + public bool $deleteConfigurations = false, + public bool $deleteVolumes = false) {} public function handle() {