From f97c87a3e9c19c7f78b0ddc991029cd6944f0e9f Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Fri, 5 Feb 2021 11:57:43 +0100 Subject: [PATCH] adds certificates to deletes worker --- app/controllers/api/projects.php | 2 +- app/init.php | 1 + app/workers/deletes.php | 16 ++++++++++------ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index bee94871ac..8781e6edb5 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -1585,7 +1585,7 @@ App::delete('/v1/projects/:projectId/domains/:domainId') if ($consoleDB->deleteDocument($domain->getId())) { $deletes - ->setParam('type', DELETE_TYPE_DOCUMENT) + ->setParam('type', DELETE_TYPE_CERTIFICATES) ->setParam('document', $domain) ; } else { diff --git a/app/init.php b/app/init.php index 977efd94d6..085b5347c7 100644 --- a/app/init.php +++ b/app/init.php @@ -60,6 +60,7 @@ const DELETE_TYPE_DOCUMENT = 'document'; const DELETE_TYPE_EXECUTIONS = 'executions'; const DELETE_TYPE_AUDIT = 'audit'; const DELETE_TYPE_ABUSE = 'abuse'; +const DELETE_TYPE_CERTIFICATES = 'certificates'; $register = new Registry(); diff --git a/app/workers/deletes.php b/app/workers/deletes.php index 92ee86d486..a329afe24f 100644 --- a/app/workers/deletes.php +++ b/app/workers/deletes.php @@ -38,7 +38,7 @@ class DeletesV1 switch (strval($type)) { case DELETE_TYPE_DOCUMENT: $document = $this->args['document']; - $document = new Document($document); + $document = new Document($document); switch (strval($document->getCollection())) { case Database::SYSTEM_COLLECTION_PROJECTS: $this->deleteProject($document); @@ -52,9 +52,6 @@ class DeletesV1 case Database::SYSTEM_COLLECTION_COLLECTIONS: $this->deleteDocuments($document, $projectId); break; - case Database::SYSTEM_COLLECTION_DOMAINS: - $this->deleteCertificates($document); - break; default: Console::error('No lazy delete operation available for document of type: '.$document->getCollection()); break; @@ -72,6 +69,11 @@ class DeletesV1 case DELETE_TYPE_ABUSE: $this->deleteAbuseLogs($this->args['timestamp']); break; + + case DELETE_TYPE_CERTIFICATES: + $document = new Document($this->args['document']); + $this->deleteCertificates($document); + break; default: Console::error('No delete operation for type: '.$type); @@ -310,13 +312,15 @@ class DeletesV1 protected function deleteCertificates(Document $document) { - $domain = $document->getAttribute('domain', null); + $domain = $document->getAttribute('domain'); $directory = APP_STORAGE_CERTIFICATES . '/' . $domain; if($domain && is_dir($directory)) { array_map('unlink', glob("$directory/*.*")); rmdir($directory); - Console::info("Deleted certificate files for domain {$domain}"); + Console::info("Deleted certificate files for {$domain}"); + } else { + Console::info("No certificate files found for {$domain}"); } }