patch: delete based on collection
This commit is contained in:
parent
c6a105db7e
commit
e3a6c899c3
|
@ -253,6 +253,7 @@ App::delete('/v1/database/collections/:collectionId')
|
|||
|
||||
$deletes
|
||||
->setParam('document', $collection)
|
||||
->setParam('collection', Database::SYSTEM_COLLECTION_COLLECTIONS)
|
||||
;
|
||||
|
||||
$events
|
||||
|
|
|
@ -366,6 +366,7 @@ App::delete('/v1/functions/:functionId')
|
|||
|
||||
$deletes
|
||||
->setParam('document', $function->getArrayCopy())
|
||||
->setParam('collection', Database::SYSTEM_COLLECTION_FUNCTIONS)
|
||||
;
|
||||
|
||||
$response->noContent();
|
||||
|
|
|
@ -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', []);
|
||||
|
|
|
@ -517,6 +517,7 @@ App::delete('/v1/users/:userId')
|
|||
|
||||
$deletes
|
||||
->setParam('document', $user)
|
||||
->setParam('collection', Database::SYSTEM_COLLECTION_USERS)
|
||||
;
|
||||
|
||||
$events
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
]),
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue