From c3cef56e3937e075d74413d559025f0220da579f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Sun, 30 Jul 2023 15:12:55 +0200 Subject: [PATCH] Bug fixing after QA --- app/config/collections.php | 4 ++-- app/controllers/general.php | 11 ++++++----- app/workers/builds.php | 9 +++++++-- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/app/config/collections.php b/app/config/collections.php index 927011a474..81ed52dfa8 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -3615,7 +3615,7 @@ $collections = [ 'required' => false, 'default' => null, 'array' => false, - 'filters' => [], + 'filters' => ['json'], ], [ '$id' => ID::custom('responseStatusCode'), @@ -3637,7 +3637,7 @@ $collections = [ 'required' => false, 'default' => null, 'array' => false, - 'filters' => [], + 'filters' => ['json'], ], [ '$id' => ID::custom('search'), diff --git a/app/controllers/general.php b/app/controllers/general.php index 706e9d878d..98f5a14ffa 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -130,17 +130,17 @@ function router(App $utopia, Database $dbForConsole, SwooleRequest $swooleReques $execution = \json_decode($executionResponse, true); - foreach ($execution['headers'] as $header => $value) { - $response->setHeader($header, $value); + foreach ($execution['responseHeaders'] as $header) { + $response->setHeader($header['key'], $header['value']); } - $body = $execution['body'] ?? ''; + $body = $execution['responseBody'] ?? ''; - if (($execution['headers']['x-open-runtimes-encoding'] ?? '') === 'base64') { + if (($execution['responseHeaders']['x-open-runtimes-encoding'] ?? '') === 'base64') { $body = \base64_decode($body); } - $response->setStatusCode($execution['statusCode'] ?? 200)->send($body); + $response->setStatusCode($execution['responseStatusCode'] ?? 200)->send($body); return true; } elseif ($type === 'api') { return false; @@ -172,6 +172,7 @@ App::init() $host = $request->getHostname() ?? ''; $mainDomain = App::getEnv('_APP_DOMAIN', ''); + \var_dump($host); // Only run Router when external domain if ($host !== $mainDomain && $host !== 'localhost') { if (router($utopia, $dbForConsole, $swooleRequest, $request, $response)) { diff --git a/app/workers/builds.php b/app/workers/builds.php index 3a05bd8e8c..bae2b3cab7 100644 --- a/app/workers/builds.php +++ b/app/workers/builds.php @@ -153,6 +153,11 @@ class BuildsV1 extends Worker try { if ($isNewBuild) { if ($isVcsEnabled) { + $installation = $dbForConsole->getDocument('vcsInstallations', $installationId, [ + Query::equal('projectInternalId', [$project->getInternalId()]) + ]); + $providerInstallationId = $installation->getAttribute('providerInstallationId'); + $privateKey = App::getEnv('_APP_VCS_GITHUB_PRIVATE_KEY'); $githubAppId = App::getEnv('_APP_VCS_GITHUB_APP_ID'); @@ -162,9 +167,9 @@ class BuildsV1 extends Worker $rootDirectory = \ltrim($rootDirectory, '.'); $rootDirectory = \ltrim($rootDirectory, '/'); - $github->initialiseVariables($installationId, $privateKey, $githubAppId); + $github->initialiseVariables($providerInstallationId, $privateKey, $githubAppId); - $owner = $github->getOwnerName($installationId); + $owner = $github->getOwnerName($providerInstallationId); $repositoryName = $github->getRepositoryName($providerRepositoryId); $cloneOwner = !empty($providerContribution) ? $providerContribution->getAttribute('owner', $owner) : $owner;