1
0
Fork 0
mirror of synced 2024-06-10 14:54:43 +12:00

adds certificates to deletes worker

This commit is contained in:
Torsten Dittmann 2021-02-05 11:57:43 +01:00
parent ef29a87f61
commit f97c87a3e9
3 changed files with 12 additions and 7 deletions

View file

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

View file

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

View file

@ -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}");
}
}