From a949a1ffd53c4cd71537b7bbd0838b8f308392da Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 10 Jun 2025 10:07:12 +0300 Subject: [PATCH] delayed project deletion --- app/config/collections/platform.php | 11 ----------- app/controllers/api/projects.php | 14 +++++++++++--- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/app/config/collections/platform.php b/app/config/collections/platform.php index 59f849968b..e61d3d9b3e 100644 --- a/app/config/collections/platform.php +++ b/app/config/collections/platform.php @@ -331,17 +331,6 @@ return [ 'array' => false, 'filters' => ['datetime'], ], - [ - '$id' => ID::custom('scheduleId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], [ '$id' => ID::custom('_deletedAt'), 'type' => Database::VAR_DATETIME, diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 0f780b341a..6786757ffd 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -435,9 +435,10 @@ App::patch('/v1/projects/:projectId') ->param('legalCity', '', new Text(256), 'Project legal city. Max length: 256 chars.', true) ->param('legalAddress', '', new Text(256), 'Project legal address. Max length: 256 chars.', true) ->param('legalTaxId', '', new Text(256), 'Project legal tax ID. Max length: 256 chars.', true) + ->param('restore', null, new Boolean(), 'Restore project from being marked for deletion', true) ->inject('response') ->inject('dbForPlatform') - ->action(function (string $projectId, string $name, string $description, string $logo, string $url, string $legalName, string $legalCountry, string $legalState, string $legalCity, string $legalAddress, string $legalTaxId, Response $response, Database $dbForPlatform) { + ->action(function (string $projectId, string $name, string $description, string $logo, string $url, string $legalName, string $legalCountry, string $legalState, string $legalCity, string $legalAddress, string $legalTaxId, bool $restore, Response $response, Database $dbForPlatform) { $project = $dbForPlatform->getDocument('projects', $projectId); @@ -445,7 +446,7 @@ App::patch('/v1/projects/:projectId') throw new Exception(Exception::PROJECT_NOT_FOUND); } - $project = $dbForPlatform->updateDocument('projects', $project->getId(), $project + $project ->setAttribute('name', $name) ->setAttribute('description', $description) ->setAttribute('logo', $logo) @@ -456,7 +457,14 @@ App::patch('/v1/projects/:projectId') ->setAttribute('legalCity', $legalCity) ->setAttribute('legalAddress', $legalAddress) ->setAttribute('legalTaxId', $legalTaxId) - ->setAttribute('search', implode(' ', [$projectId, $name]))); + ->setAttribute('search', implode(' ', [$projectId, $name])) + ; + + if (!empty($restore)) { + $project->setAttribute('_deletedAt', null); + } + + $project = $dbForPlatform->updateDocument('projects', $project->getId(), $project); $response->dynamic($project, Response::MODEL_PROJECT); });