From 64630490a551114bb241c7cde44dd6a533a13466 Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Wed, 1 Nov 2023 14:36:31 +0530 Subject: [PATCH] Delete linked VCS repos and comments on function deletion --- src/Appwrite/Platform/Workers/Deletes.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index 2130499257..1a2b378590 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -45,7 +45,7 @@ class Deletes extends Action ->inject('getFunctionsDevice') ->inject('getBuildsDevice') ->inject('getCacheDevice') - ->callback(fn($message, $dbForConsole, callable $getProjectDB, callable $getFilesDevice, callable $getFunctionsDevice, callable $getBuildsDevice, callable $getCacheDevice) => $this->action($message, $dbForConsole, $getProjectDB, $getFilesDevice, $getFunctionsDevice, $getBuildsDevice, $getCacheDevice)); + ->callback(fn ($message, $dbForConsole, callable $getProjectDB, callable $getFilesDevice, callable $getFunctionsDevice, callable $getBuildsDevice, callable $getCacheDevice) => $this->action($message, $dbForConsole, $getProjectDB, $getFilesDevice, $getFunctionsDevice, $getBuildsDevice, $getCacheDevice)); } /** @@ -688,7 +688,7 @@ class Deletes extends Action $this->deleteDeploymentFiles($functionsStorage, $document); }); - /** + /** * Delete builds */ Console::info("Deleting builds for function " . $functionId); @@ -709,6 +709,22 @@ class Deletes extends Action Query::equal('functionInternalId', [$functionInternalId]) ], $dbForProject); + /** + * Delete VCS Repositories and VCS Comments + */ + Console::info("Deleting VCS repositories and comments linked to function " . $functionId); + $this->deleteByGroup('repositories', [ + Query::equal('resourceInternalId', [$functionInternalId]), + Query::equal('resourceType', ['function']), + ], $dbForConsole, function (Document $document) use ($dbForConsole) { + $providerRepositoryId = $document->getAttribute('providerRepositoryId', ''); + $projectId = $document->getAttribute('projectId', ''); + $this->deleteByGroup('vcsComments', [ + Query::equal('providerRepositoryId', [$providerRepositoryId]), + Query::equal('projectId', [$projectId]), + ], $dbForConsole); + }); + /** * Request executor to delete all deployment containers */