diff --git a/Dockerfile b/Dockerfile index 768457b132..30b017b573 100755 --- a/Dockerfile +++ b/Dockerfile @@ -67,7 +67,6 @@ RUN chmod +x /usr/local/bin/doctor && \ chmod +x /usr/local/bin/schedule-functions && \ chmod +x /usr/local/bin/schedule-executions && \ chmod +x /usr/local/bin/schedule-messages && \ - chmod +x /usr/local/bin/schedule-projects && \ chmod +x /usr/local/bin/sdks && \ chmod +x /usr/local/bin/specs && \ chmod +x /usr/local/bin/ssl && \ diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 1532bc172e..0f780b341a 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -1172,32 +1172,10 @@ App::delete('/v1/projects/:projectId') throw new Exception(Exception::PROJECT_NOT_FOUND); } - $interval = (int)System::getEnv('_APP_PROJECTS_DELETE_EXPIRATION','3600'); - $expiration = new \DateTime(); - $expiration->add(new \DateInterval('PT' . $interval . 'S')); - $cronPattern = sprintf('%d %d %d %d *', - (int)$expiration->format('i'), // minute - (int)$expiration->format('G'), // hour - (int)$expiration->format('j'), // day of month - (int)$expiration->format('n') // month - ); - - $cronExpression = new CronExpression($cronPattern); - $scheduledAt = $cronExpression->getExpression(); - - $schedule = $dbForPlatform->createDocument('schedules', new Document([ - 'region' => $project->getAttribute('region'), - 'resourceType' => 'project', - 'resourceId' => $project->getId(), - 'resourceInternalId' => $project->getInternalId(), - 'resourceUpdatedAt' => DateTime::now(), - 'projectId' => $project->getId(), - 'schedule' => $scheduledAt, - 'active' => true, - ])); - - $dbForPlatform->updateDocument('projects', $project->getId(), $project - ->setAttribute('scheduleId', $schedule->getId())) + $expiration = System::getEnv('_APP_PROJECTS_DELETE_EXPIRATION','3600'); + $deletedAt = DateTime::formatTz(DateTime::addSeconds(new \DateTime(), (int)$expiration)); + $dbForPlatform->updateDocument('projects', $project->getId(), + $project->setAttribute('_deletedAt', $deletedAt)) ; $response->noContent(); diff --git a/bin/schedule-projects b/bin/schedule-projects deleted file mode 100644 index eea1ad1c18..0000000000 --- a/bin/schedule-projects +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -exec php /usr/src/code/app/cli.php schedule-projects $@ diff --git a/src/Appwrite/Platform/Services/Tasks.php b/src/Appwrite/Platform/Services/Tasks.php index 74ee2c332d..3ada193cf7 100644 --- a/src/Appwrite/Platform/Services/Tasks.php +++ b/src/Appwrite/Platform/Services/Tasks.php @@ -10,7 +10,6 @@ use Appwrite\Platform\Tasks\QueueRetry; use Appwrite\Platform\Tasks\ScheduleExecutions; use Appwrite\Platform\Tasks\ScheduleFunctions; use Appwrite\Platform\Tasks\ScheduleMessages; -use Appwrite\Platform\Tasks\ScheduleProjects; use Appwrite\Platform\Tasks\Screenshot; use Appwrite\Platform\Tasks\SDKs; use Appwrite\Platform\Tasks\Specs; @@ -38,7 +37,6 @@ class Tasks extends Service ->addAction(ScheduleFunctions::getName(), new ScheduleFunctions()) ->addAction(ScheduleExecutions::getName(), new ScheduleExecutions()) ->addAction(ScheduleMessages::getName(), new ScheduleMessages()) - ->addAction(ScheduleProjects::getName(), new ScheduleProjects()) ->addAction(Specs::getName(), new Specs()) ->addAction(Upgrade::getName(), new Upgrade()) ->addAction(Vars::getName(), new Vars()) diff --git a/src/Appwrite/Platform/Tasks/ScheduleProjects.php b/src/Appwrite/Platform/Tasks/ScheduleProjects.php deleted file mode 100644 index e860550306..0000000000 --- a/src/Appwrite/Platform/Tasks/ScheduleProjects.php +++ /dev/null @@ -1,59 +0,0 @@ -schedules as $schedule) { - if (!$schedule['active']) { - continue; - } - - $now = new \DateTime(); - $scheduledAt = new \DateTime($schedule['schedule']); - - if ($scheduledAt > $now) { - continue; - } - - \go(function () use ($schedule, $scheduledAt, $dbForPlatform) { - - (new Delete($this->publisher)) - ->setProject($schedule['project']) - ->setType(DELETE_TYPE_DOCUMENT) - ->setDocument($schedule['project']) - ->trigger(); - - $dbForPlatform->deleteDocument('projects', $schedule['project']->getId()); - $dbForPlatform->deleteDocument('schedules', $schedule['$id']); - - $this->recordEnqueueDelay($scheduledAt); - unset($this->schedules[$schedule['$internalId']]); - }); - } - } -}