mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 09:28:40 +00:00
Merge branch '0.9.x' of github.com:appwrite/appwrite into 0.9.x
This commit is contained in:
commit
9ab76690b6
2 changed files with 20 additions and 20 deletions
|
|
@ -212,7 +212,8 @@ App::delete('/v1/teams/:teamId')
|
||||||
->inject('response')
|
->inject('response')
|
||||||
->inject('projectDB')
|
->inject('projectDB')
|
||||||
->inject('events')
|
->inject('events')
|
||||||
->action(function ($teamId, $response, $projectDB, $events) {
|
->inject('deletes')
|
||||||
|
->action(function ($teamId, $response, $projectDB, $events, $deletes) {
|
||||||
/** @var Appwrite\Utopia\Response $response */
|
/** @var Appwrite\Utopia\Response $response */
|
||||||
/** @var Appwrite\Database\Database $projectDB */
|
/** @var Appwrite\Database\Database $projectDB */
|
||||||
/** @var Appwrite\Event\Event $events */
|
/** @var Appwrite\Event\Event $events */
|
||||||
|
|
@ -223,25 +224,15 @@ App::delete('/v1/teams/:teamId')
|
||||||
throw new Exception('Team not found', 404);
|
throw new Exception('Team not found', 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$memberships = $projectDB->getCollection([
|
|
||||||
'limit' => 2000, // TODO add members limit
|
|
||||||
'offset' => 0,
|
|
||||||
'filters' => [
|
|
||||||
'$collection='.Database::SYSTEM_COLLECTION_MEMBERSHIPS,
|
|
||||||
'teamId='.$teamId,
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
|
|
||||||
foreach ($memberships as $member) {
|
|
||||||
if (!$projectDB->deleteDocument($member->getId())) {
|
|
||||||
throw new Exception('Failed to remove membership for team from DB', 500);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$projectDB->deleteDocument($teamId)) {
|
if (!$projectDB->deleteDocument($teamId)) {
|
||||||
throw new Exception('Failed to remove team from DB', 500);
|
throw new Exception('Failed to remove team from DB', 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$deletes
|
||||||
|
->setParam('type', DELETE_TYPE_DOCUMENT)
|
||||||
|
->setParam('document', $team)
|
||||||
|
;
|
||||||
|
|
||||||
$events
|
$events
|
||||||
->setParam('eventData', $response->output($team, Response::MODEL_TEAM))
|
->setParam('eventData', $response->output($team, Response::MODEL_TEAM))
|
||||||
;
|
;
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ class DeletesV1 extends Worker
|
||||||
|
|
||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
$projectId = isset($this->args['projectId']) ? $this->args['projectId'] : '';
|
$projectId = isset($this->args['projectId']) ? $this->args['projectId'] : '';
|
||||||
$type = $this->args['type'];
|
$type = $this->args['type'];
|
||||||
|
|
||||||
switch (strval($type)) {
|
switch (strval($type)) {
|
||||||
|
|
@ -51,6 +51,9 @@ class DeletesV1 extends Worker
|
||||||
case Database::SYSTEM_COLLECTION_COLLECTIONS:
|
case Database::SYSTEM_COLLECTION_COLLECTIONS:
|
||||||
$this->deleteDocuments($document, $projectId);
|
$this->deleteDocuments($document, $projectId);
|
||||||
break;
|
break;
|
||||||
|
case Database::SYSTEM_COLLECTION_TEAMS:
|
||||||
|
$this->deleteMemberships($document, $projectId);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Console::error('No lazy delete operation available for document of type: '.$document->getCollection());
|
Console::error('No lazy delete operation available for document of type: '.$document->getCollection());
|
||||||
break;
|
break;
|
||||||
|
|
@ -95,6 +98,14 @@ class DeletesV1 extends Worker
|
||||||
], $this->getProjectDB($projectId));
|
], $this->getProjectDB($projectId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function deleteMemberships(Document $document, $projectId) {
|
||||||
|
// Delete Memberships
|
||||||
|
$this->deleteByGroup([
|
||||||
|
'$collection='.Database::SYSTEM_COLLECTION_MEMBERSHIPS,
|
||||||
|
'teamId='.$document->getId(),
|
||||||
|
], $this->getProjectDB($projectId));
|
||||||
|
}
|
||||||
|
|
||||||
protected function deleteProject(Document $document)
|
protected function deleteProject(Document $document)
|
||||||
{
|
{
|
||||||
// Delete all DBs
|
// Delete all DBs
|
||||||
|
|
@ -212,7 +223,7 @@ class DeletesV1 extends Worker
|
||||||
Console::success('Delete code tag: '.$document->getAttribute('path', ''));
|
Console::success('Delete code tag: '.$document->getAttribute('path', ''));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Console::error('Dailed to delete code tag: '.$document->getAttribute('path', ''));
|
Console::error('Failed to delete code tag: '.$document->getAttribute('path', ''));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -260,7 +271,6 @@ class DeletesV1 extends Worker
|
||||||
Authorization::disable();
|
Authorization::disable();
|
||||||
$projects = $this->getConsoleDB()->getCollection([
|
$projects = $this->getConsoleDB()->getCollection([
|
||||||
'limit' => $limit,
|
'limit' => $limit,
|
||||||
'offset' => $count,
|
|
||||||
'orderType' => 'ASC',
|
'orderType' => 'ASC',
|
||||||
'orderCast' => 'string',
|
'orderCast' => 'string',
|
||||||
'filters' => [
|
'filters' => [
|
||||||
|
|
@ -303,7 +313,6 @@ class DeletesV1 extends Worker
|
||||||
|
|
||||||
$results = $database->getCollection([
|
$results = $database->getCollection([
|
||||||
'limit' => $limit,
|
'limit' => $limit,
|
||||||
'offset' => $count,
|
|
||||||
'orderField' => '$id',
|
'orderField' => '$id',
|
||||||
'orderType' => 'ASC',
|
'orderType' => 'ASC',
|
||||||
'orderCast' => 'string',
|
'orderCast' => 'string',
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue