From bb91bd22064a8a2be74c20a1382bfc106cc916a5 Mon Sep 17 00:00:00 2001 From: Hemachandar Date: Thu, 26 Feb 2026 18:32:42 +0530 Subject: [PATCH] Add authorized field to VCS repository model --- .../VCS/Http/Installations/Repositories/Create.php | 2 ++ .../VCS/Http/Installations/Repositories/Get.php | 11 +++++++++++ .../VCS/Http/Installations/Repositories/XList.php | 2 ++ .../Utopia/Response/Model/ProviderRepository.php | 12 ++++++++++++ 4 files changed, 27 insertions(+) diff --git a/src/Appwrite/Platform/Modules/VCS/Http/Installations/Repositories/Create.php b/src/Appwrite/Platform/Modules/VCS/Http/Installations/Repositories/Create.php index e357d1d5fa..bba062a730 100644 --- a/src/Appwrite/Platform/Modules/VCS/Http/Installations/Repositories/Create.php +++ b/src/Appwrite/Platform/Modules/VCS/Http/Installations/Repositories/Create.php @@ -152,6 +152,8 @@ class Create extends Action $repository['pushedAt'] = $repository['pushed_at'] ?? ''; $repository['organization'] = $installation->getAttribute('organization', ''); $repository['provider'] = $installation->getAttribute('provider', ''); + $repository['providerInstallationId'] = $installation->getAttribute('providerInstallationId', ''); + $repository['authorized'] = true; $response->dynamic(new Document($repository), Response::MODEL_PROVIDER_REPOSITORY); } diff --git a/src/Appwrite/Platform/Modules/VCS/Http/Installations/Repositories/Get.php b/src/Appwrite/Platform/Modules/VCS/Http/Installations/Repositories/Get.php index 4dee84752b..835ee0f95b 100644 --- a/src/Appwrite/Platform/Modules/VCS/Http/Installations/Repositories/Get.php +++ b/src/Appwrite/Platform/Modules/VCS/Http/Installations/Repositories/Get.php @@ -85,11 +85,22 @@ class Get extends Action $repository = $github->getRepository($owner, $repositoryName); + $authorized = false; + ['items' => $repos] = $github->searchRepositories($providerInstallationId, $owner, 1, 25, $repositoryName); + foreach ($repos as $repo) { + if (\strval($repo['id']) === $providerRepositoryId) { + $authorized = true; + break; + } + } + $repository['id'] = \strval($repository['id']) ?? ''; $repository['pushedAt'] = $repository['pushed_at'] ?? ''; $repository['organization'] = $installation->getAttribute('organization', ''); $repository['provider'] = $installation->getAttribute('provider', ''); $repository['defaultBranch'] = $repository['default_branch'] ?? ''; + $repository['authorized'] = $authorized; + $repository['providerInstallationId'] = $providerInstallationId; $response->dynamic(new Document($repository), Response::MODEL_PROVIDER_REPOSITORY); } diff --git a/src/Appwrite/Platform/Modules/VCS/Http/Installations/Repositories/XList.php b/src/Appwrite/Platform/Modules/VCS/Http/Installations/Repositories/XList.php index 2cb1a996a4..53713f8407 100644 --- a/src/Appwrite/Platform/Modules/VCS/Http/Installations/Repositories/XList.php +++ b/src/Appwrite/Platform/Modules/VCS/Http/Installations/Repositories/XList.php @@ -148,6 +148,8 @@ class XList extends Action $repo['pushedAt'] = $repo['pushed_at'] ?? null; $repo['provider'] = $installation->getAttribute('provider', '') ?? ''; $repo['organization'] = $installation->getAttribute('organization', '') ?? ''; + $repo['providerInstallationId'] = $installation->getAttribute('providerInstallationId', ''); + $repo['authorized'] = true; return $repo; }, $repos); diff --git a/src/Appwrite/Utopia/Response/Model/ProviderRepository.php b/src/Appwrite/Utopia/Response/Model/ProviderRepository.php index ddad0b059c..4dd9789872 100644 --- a/src/Appwrite/Utopia/Response/Model/ProviderRepository.php +++ b/src/Appwrite/Utopia/Response/Model/ProviderRepository.php @@ -47,6 +47,18 @@ class ProviderRepository extends Model 'default' => '', 'example' => 'main', ]) + ->addRule('providerInstallationId', [ + 'type' => self::TYPE_STRING, + 'description' => 'VCS (Version Control System) installation ID.', + 'default' => '', + 'example' => '108104697', + ]) + ->addRule('authorized', [ + 'type' => self::TYPE_BOOLEAN, + 'description' => 'Is VCS (Version Control System) repository authorized for the installation?', + 'default' => false, + 'example' => true, + ]) ->addRule('pushedAt', [ 'type' => self::TYPE_DATETIME, 'description' => 'Last commit date in ISO 8601 format.',