fix: cleanup parameter

This commit is contained in:
Andras Bacsai 2024-07-11 12:50:12 +02:00
parent 2b805f869a
commit 574bafd950
3 changed files with 14 additions and 5 deletions

View File

@ -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.',

View File

@ -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.',

View File

@ -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()
{