1
0
Fork 0
mirror of synced 2024-05-20 12:42:39 +12:00

patch: delete based on collection

This commit is contained in:
Christy Jacob 2020-12-18 16:38:58 +05:30
parent c6a105db7e
commit e3a6c899c3
7 changed files with 17 additions and 11 deletions

View file

@ -253,6 +253,7 @@ App::delete('/v1/database/collections/:collectionId')
$deletes
->setParam('document', $collection)
->setParam('collection', Database::SYSTEM_COLLECTION_COLLECTIONS)
;
$events

View file

@ -366,6 +366,7 @@ App::delete('/v1/functions/:functionId')
$deletes
->setParam('document', $function->getArrayCopy())
->setParam('collection', Database::SYSTEM_COLLECTION_FUNCTIONS)
;
$response->noContent();

View file

@ -429,7 +429,10 @@ App::delete('/v1/projects/:projectId')
throw new Exception('Project not found', 404);
}
$deletes->setParam('document', $project->getArrayCopy());
$deletes
->setParam('document', $project->getArrayCopy())
->setParam('collection', Database::SYSTEM_COLLECTION_PROJECTS)
;
foreach (['keys', 'webhooks', 'tasks', 'platforms', 'domains'] as $key) { // Delete all children (keys, webhooks, tasks [stop tasks?], platforms)
$list = $project->getAttribute('webhooks', []);

View file

@ -517,6 +517,7 @@ App::delete('/v1/users/:userId')
$deletes
->setParam('document', $user)
->setParam('collection', Database::SYSTEM_COLLECTION_USERS)
;
$events

View file

@ -283,7 +283,7 @@ App::shutdown(function ($utopia, $request, $response, $project, $events, $audits
$audits->trigger();
}
if (!empty($deletes->getParam('document'))) {
if (!empty($deletes->getParam('collection'))) {
$deletes->trigger();
}

View file

@ -29,30 +29,30 @@ function getConsoleDB() {
function notifyDeleteExecutionLogs(array $projectIds)
{
Resque::enqueue(DELETE_QUEUE_NAME, DELETE_CLASS_NAME, [
'collection' => Database::SYSTEM_COLLECTION_EXECUTIONS,
'document' => new Document([
'$collection' => Database::SYSTEM_COLLECTION_EXECUTIONS,
'projectIds' => $projectIds
]),
])
]);
}
function notifyDeleteAbuseLogs(array $projectIds)
{
Resque::enqueue(DELETE_QUEUE_NAME, DELETE_CLASS_NAME, [
'collection' => Database::SYSTEM_COLLECTION_EXECUTIONS,
'document' => new Document([
'$collection' => Database::SYSTEM_COLLECTION_EXECUTIONS,
'projectIds' => $projectIds
]),
])
]);
}
function notifyDeleteAuditLogs(array $projectIds)
{
Resque::enqueue(DELETE_QUEUE_NAME, DELETE_CLASS_NAME, [
'collection' => Database::SYSTEM_COLLECTION_EXECUTIONS,
'document' => new Document([
'$collection' => Database::SYSTEM_COLLECTION_EXECUTIONS,
'projectIds' => $projectIds
]),
])
]);
}

View file

@ -29,12 +29,12 @@ class DeletesV1
public function perform()
{
$projectId = $this->args['projectId'];
$document = $this->args['document'];
$document = new Document($document);
$projectId = $this->args['projectId'];
$collection = $this->args['collection'];
switch (strval($document->getCollection())) {
switch (strval($collection)) {
case Database::SYSTEM_COLLECTION_PROJECTS:
$this->deleteProject($document);
break;