Hide VCS factory behind DI closures

This commit is contained in:
harsh mahajan committed 2026-07-13 17:11:52 +05:30
1 parent 0fd8c449ff
commit 8a12d98705
3 files changed
+10 -8

No files matched your search

+4
View File
@@ -378,10 +378,14 @@ $container->set('promiseAdapter', fn ($register) => $register->get('promiseAdapt
$container->set('vcsFactory', fn (Cache $cache) => new VcsFactory($cache), ['cache']);
$container->set('vcsProviders', fn (VcsFactory $vcsFactory) => fn () => $vcsFactory->getProviders(), ['vcsFactory']);
$container->set('vcsForInstallation', fn (VcsFactory $vcsFactory) => fn (Document $installation) => $vcsFactory->fromInstallation($installation), ['vcsFactory']);
$container->set('vcsForProvider', fn (VcsFactory $vcsFactory) => fn (string $provider) => $vcsFactory->fromProvider($provider), ['vcsFactory']);
$container->set('vcsWebhookSecret', fn (VcsFactory $vcsFactory) => fn (string $provider) => $vcsFactory->getWebhookSecret($provider), ['vcsFactory']);
$container->set('plan', fn () => []);
$container->set('smsRates', fn () => []);
@@ -7,7 +7,6 @@ use Appwrite\SDK\ContentType;
use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Utopia\Response;
use Appwrite\Vcs\Factory;
use Utopia\Database\Database;
use Utopia\Database\Document;
use Utopia\Domains\Domain;
@@ -47,7 +46,7 @@ class Get extends Action
],
contentType: ContentType::JSON
))
->inject('vcsFactory')
->inject('vcsProviders')
->inject('response')
->inject('platform')
->inject('dbForProject')
@@ -55,7 +54,7 @@ class Get extends Action
}
public function action(
Factory $vcsFactory,
callable $vcsProviders,
Response $response,
array $platform,
Database $dbForProject
@@ -72,7 +71,7 @@ class Get extends Action
$isDomainEnabled = $isAAAAValid || $isAValid || $isCNAMEValid;
$isVcsEnabled = !empty($vcsFactory->getProviders());
$isVcsEnabled = !empty($vcsProviders());
$isAssistantEnabled = !empty(System::getEnv('_APP_ASSISTANT_OPENAI_API_KEY', ''));
@@ -8,7 +8,6 @@ use Appwrite\Platform\Action;
use Appwrite\Platform\Modules\VCS\Http\GitHub\Deployment;
use Appwrite\Utopia\Request;
use Appwrite\Utopia\Response;
use Appwrite\Vcs\Factory as VcsFactory;
use OpenRuntimes\Orchestrator\Jobs;
use Utopia\Console;
use Utopia\Database\Database;
@@ -37,7 +36,7 @@ class Create extends Action
->desc('Create event')
->groups(['api', 'vcs'])
->label('scope', 'public')
->inject('vcsFactory')
->inject('vcsWebhookSecret')
->inject('vcsForProvider')
->inject('vcsForInstallation')
->inject('request')
@@ -52,7 +51,7 @@ class Create extends Action
}
public function action(
VcsFactory $vcsFactory,
callable $vcsWebhookSecret,
callable $vcsForProvider,
callable $vcsForInstallation,
Request $request,
@@ -73,7 +72,7 @@ class Create extends Action
$payload = $request->getRawPayload();
$signature = $request->getHeaderLine('x-hub-signature-256', '');
$secretKey = $vcsFactory->getWebhookSecret('github');
$secretKey = $vcsWebhookSecret('github');
$valid = empty($secretKey) ? true : $vcs->validateWebhookEvent($payload, $signature, $secretKey);
Span::add('vcs.github.event.signature.valid', $valid);