mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Add authorized field to VCS repository model
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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.',
|
||||
|
||||
Reference in New Issue
Block a user