From 690a23fe89a91466ae9b05aac11edea6afb658e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 28 Oct 2024 11:17:44 +0100 Subject: [PATCH 1/2] Fix deployments showing wrong domains --- .../Modules/Sites/Http/Deployments/GetDeployment.php | 9 ++++++--- .../Modules/Sites/Http/Deployments/ListDeployments.php | 6 ++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/GetDeployment.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/GetDeployment.php index b70bddb842..c70c36a2ec 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/GetDeployment.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/GetDeployment.php @@ -3,9 +3,10 @@ namespace Appwrite\Platform\Modules\Sites\Http\Deployments; use Appwrite\Extend\Exception; -use Appwrite\Query; use Appwrite\Utopia\Response; use Utopia\Database\Database; +use Utopia\Database\Document; +use Utopia\Database\Query; use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\UID; use Utopia\Platform\Action; @@ -38,12 +39,13 @@ class GetDeployment extends Action ->param('siteId', '', new UID(), 'Site ID.') ->param('deploymentId', '', new UID(), 'Deployment ID.') ->inject('response') + ->inject('project') ->inject('dbForProject') ->inject('dbForConsole') ->callback([$this, 'action']); } - public function action(string $siteId, string $deploymentId, Response $response, Database $dbForProject, Database $dbForConsole) + public function action(string $siteId, string $deploymentId, Response $response, Document $project, Database $dbForProject, Database $dbForConsole) { $site = $dbForProject->getDocument('sites', $siteId); @@ -69,8 +71,9 @@ class GetDeployment extends Action $deployment->setAttribute('size', $deployment->getAttribute('size', 0)); $rule = Authorization::skip(fn () => $dbForConsole->findOne('rules', [ + Query::equal("projectInternalId", [$project->getInternalId()]), Query::equal("resourceType", ["deployment"]), - Query::equal("resourceId", [$deployment->getId()]) + Query::equal("resourceInternalId", [$deployment->getInternalId()]) ])); if (!empty($rule)) { diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/ListDeployments.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/ListDeployments.php index b1642852dc..4bae69898e 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/ListDeployments.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/ListDeployments.php @@ -44,12 +44,13 @@ class ListDeployments extends Action ->param('queries', [], new Deployments(), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' queries are allowed, each ' . APP_LIMIT_ARRAY_ELEMENT_SIZE . ' characters long. You may filter on the following attributes: ' . implode(', ', Deployments::ALLOWED_ATTRIBUTES), true) ->param('search', '', new Text(256), 'Search term to filter your list results. Max length: 256 chars.', true) ->inject('response') + ->inject('project') ->inject('dbForProject') ->inject('dbForConsole') ->callback([$this, 'action']); } - public function action(string $siteId, array $queries, string $search, Response $response, Database $dbForProject, Database $dbForConsole) + public function action(string $siteId, array $queries, string $search, Response $response, Document $project, Database $dbForProject, Database $dbForConsole) { $site = $dbForProject->getDocument('sites', $siteId); @@ -110,8 +111,9 @@ class ListDeployments extends Action $result->setAttribute('size', $result->getAttribute('size', 0)); $rule = Authorization::skip(fn () => $dbForConsole->findOne('rules', [ + Query::equal("projectInternalId", [$project->getInternalId()]), Query::equal("resourceType", ["deployment"]), - Query::equal("resourceId", [$result->getId()]) + Query::equal("resourceInternalId", [$result->getInternalId()]) ])); if (!empty($rule)) { From febd5294f4bf90c68330965407424bc0937702ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 28 Oct 2024 11:18:15 +0100 Subject: [PATCH 2/2] Ensure function executor is ready --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7c53b03b52..cdd2fa670e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -142,7 +142,7 @@ jobs: run: | docker load --input /tmp/${{ env.IMAGE }}.tar docker compose up -d - sleep 30 + sleep 60 - name: Run ${{matrix.service}} Tests run: docker compose exec -T appwrite test /usr/src/code/tests/e2e/Services/${{matrix.service}} --debug