From afdf34c45c091a810e71e071a4e9dfdbd96f00e5 Mon Sep 17 00:00:00 2001 From: Steven Nguyen <1477010+stnguyen90@users.noreply.github.com> Date: Wed, 4 Sep 2024 00:18:59 +0000 Subject: [PATCH 1/8] fix: update console redirect to include query params Use `$request->getParams()` because `$request->getURI()` does not include the query string. --- app/controllers/web/console.php | 5 +++-- tests/e2e/General/HTTPTest.php | 13 +++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/controllers/web/console.php b/app/controllers/web/console.php index a4c76a9a35..c02e140270 100644 --- a/app/controllers/web/console.php +++ b/app/controllers/web/console.php @@ -32,8 +32,9 @@ App::get('/') ->action(function (Request $request, Response $response) { $url = parse_url($request->getURI()); $target = "/console{$url['path']}"; - if ($url['query'] ?? false) { - $target .= "?{$url['query']}"; + $params = $request->getParams(); + if (!empty($params)) { + $target .= "?" . \http_build_query($params); } if ($url['fragment'] ?? false) { $target .= "#{$url['fragment']}"; diff --git a/tests/e2e/General/HTTPTest.php b/tests/e2e/General/HTTPTest.php index b6dd3543c6..0881966365 100644 --- a/tests/e2e/General/HTTPTest.php +++ b/tests/e2e/General/HTTPTest.php @@ -216,4 +216,17 @@ class HTTPTest extends Scope $this->assertEquals('http://localhost', $response['headers']['access-control-allow-origin']); } + + public function testConsoleRedirect() + { + /** + * Test for SUCCESS + */ + + $endpoint = '/invite?membershipId=123&userId=asdf'; + + $response = $this->client->call(Client::METHOD_GET, $endpoint); + + $this->assertEquals('/console' . $endpoint, $response['headers']['location']); + } } From 0fcaaf99da074c7d1c077d8d11bdfce92fe89a6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Wed, 4 Sep 2024 18:12:11 +0000 Subject: [PATCH 2/8] Add async dynamic key template test --- .../Functions/FunctionsCustomServerTest.php | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 0607f40924..3c5aa44bca 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -568,6 +568,36 @@ class FunctionsCustomServerTest extends Scope $this->assertStringContainsString("Total users: " . $totalusers, $execution['body']['logs']); + // Execute function again but async + $execution = $this->client->call(Client::METHOD_POST, '/functions/' . $functionId . '/executions', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'path' => '/ping', + 'async' => true + ]); + + $this->assertEquals(202, $execution['headers']['status-code']); + $this->assertNotEmpty($execution['body']['$id']); + $this->assertEquals('waiting', $execution['body']['status']); + $executionId = $execution['body']['$id']; + + // Wait for async execuntion to finish + sleep(5); + + // Ensure execution was successful + $execution = $this->client->call(Client::METHOD_GET, '/functions/' . $functionId . '/executions/' . $executionId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), []); + + $this->assertEquals(200, $execution['headers']['status-code']); + $this->assertEquals("completed", $execution['body']['status']); + $this->assertEquals(200, $execution['body']['responseStatusCode']); + $this->assertEmpty($execution['body']['responseBody']); + $this->assertEmpty($execution['body']['errors']); + $this->assertStringContainsString("Total users: " . $totalusers, $execution['body']['logs']); + // Cleanup : Delete function $response = $this->client->call(Client::METHOD_DELETE, '/functions/' . $functionId, [ 'content-type' => 'application/json', From c58fa78962a1356d5dec11de326dc011bda59357 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 5 Sep 2024 14:25:11 +1200 Subject: [PATCH 3/8] Remove tenant in filter --- app/controllers/api/account.php | 2 +- app/controllers/api/functions.php | 12 ++++++------ app/controllers/api/users.php | 6 +++--- app/controllers/api/vcs.php | 2 +- app/controllers/shared/api.php | 6 +++--- app/init.php | 4 ++-- src/Appwrite/Extend/Exception.php | 2 +- src/Appwrite/Functions/Validator/Headers.php | 4 ++-- src/Appwrite/Platform/Workers/Builds.php | 6 +++--- src/Appwrite/Platform/Workers/Messaging.php | 2 +- src/Appwrite/Specification/Format/Swagger2.php | 2 +- src/Appwrite/Utopia/Response/Filters/V16.php | 4 ++-- src/Appwrite/Utopia/Response/Filters/V18.php | 4 ++-- src/Appwrite/Utopia/Response/Model/Document.php | 3 ++- src/Executor/Executor.php | 2 +- tests/e2e/Services/Functions/FunctionsBase.php | 2 +- .../Services/Functions/FunctionsCustomServerTest.php | 2 +- tests/e2e/Services/Webhooks/WebhooksBase.php | 2 +- tests/unit/Functions/Validator/HeadersBench.php | 8 ++++---- tests/unit/Functions/Validator/HeadersTest.php | 2 +- 20 files changed, 39 insertions(+), 38 deletions(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index b74b0c3adc..15c0ff9e97 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -392,7 +392,7 @@ App::post('/v1/account') $existingTarget = $dbForProject->findOne('targets', [ Query::equal('identifier', [$email]), ]); - if($existingTarget) { + if ($existingTarget) { $user->setAttribute('targets', $existingTarget, Document::SET_TYPE_APPEND); } } diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 77e70972ad..ada3b785d7 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -296,7 +296,7 @@ App::post('/v1/functions') if (!empty($providerRepositoryId)) { // Deploy VCS $redeployVcs($request, $function, $project, $installation, $dbForProject, $queueForBuilds, $template, $github); - } elseif(!$template->isEmpty()) { + } elseif (!$template->isEmpty()) { // Deploy non-VCS from template $deploymentId = ID::unique(); $deployment = $dbForProject->createDocument('deployments', new Document([ @@ -1581,7 +1581,7 @@ App::post('/v1/functions/:functionId/deployments/:deploymentId/build') } $path = $deployment->getAttribute('path'); - if(empty($path) || !$deviceForFunctions->exists($path)) { + if (empty($path) || !$deviceForFunctions->exists($path)) { throw new Exception(Exception::DEPLOYMENT_NOT_FOUND); } @@ -1735,7 +1735,7 @@ App::post('/v1/functions/:functionId/executions') ->inject('geodb') ->action(function (string $functionId, string $body, bool $async, string $path, string $method, mixed $headers, ?string $scheduledAt, Response $response, Request $request, Document $project, Database $dbForProject, Database $dbForConsole, Document $user, Event $queueForEvents, Usage $queueForUsage, Func $queueForFunctions, Reader $geodb) { - if(!$async && !is_null($scheduledAt)) { + if (!$async && !is_null($scheduledAt)) { throw new Exception(Exception::GENERAL_BAD_REQUEST, 'Scheduled executions must run asynchronously. Set scheduledAt to a future date, or set async to true.'); } @@ -1868,7 +1868,7 @@ App::post('/v1/functions/:functionId/executions') $status = $async ? 'waiting' : 'processing'; - if(!is_null($scheduledAt)) { + if (!is_null($scheduledAt)) { $status = 'scheduled'; } @@ -1898,7 +1898,7 @@ App::post('/v1/functions/:functionId/executions') ->setContext('function', $function); if ($async) { - if(is_null($scheduledAt)) { + if (is_null($scheduledAt)) { $execution = Authorization::skip(fn () => $dbForProject->createDocument('executions', $execution)); $queueForFunctions ->setType('http') @@ -2077,7 +2077,7 @@ App::post('/v1/functions/:functionId/executions') $acceptTypes = \explode(', ', $request->getHeader('accept')); foreach ($acceptTypes as $acceptType) { - if(\str_starts_with($acceptType, 'application/json') || \str_starts_with($acceptType, 'application/*')) { + if (\str_starts_with($acceptType, 'application/json') || \str_starts_with($acceptType, 'application/*')) { $response->setContentType(Response::CONTENT_TYPE_JSON); break; } elseif (\str_starts_with($acceptType, 'multipart/form-data') || \str_starts_with($acceptType, 'multipart/*')) { diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index 78988f525b..081e6a85bd 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -140,7 +140,7 @@ function createUser(string $hash, mixed $hashOptions, string $userId, ?string $e $existingTarget = $dbForProject->findOne('targets', [ Query::equal('identifier', [$email]), ]); - if($existingTarget) { + if ($existingTarget) { $user->setAttribute('targets', $existingTarget, Document::SET_TYPE_APPEND); } } @@ -164,7 +164,7 @@ function createUser(string $hash, mixed $hashOptions, string $userId, ?string $e $existingTarget = $dbForProject->findOne('targets', [ Query::equal('identifier', [$phone]), ]); - if($existingTarget) { + if ($existingTarget) { $user->setAttribute('targets', $existingTarget, Document::SET_TYPE_APPEND); } } @@ -2124,7 +2124,7 @@ App::post('/v1/users/:userId/jwts') $sessions = $user->getAttribute('sessions', []); $session = new Document(); - if($sessionId === 'recent') { + if ($sessionId === 'recent') { // Get most recent $session = \count($sessions) > 0 ? $sessions[\count($sessions) - 1] : new Document(); } else { diff --git a/app/controllers/api/vcs.php b/app/controllers/api/vcs.php index 299e2836f7..9610f44ace 100644 --- a/app/controllers/api/vcs.php +++ b/app/controllers/api/vcs.php @@ -509,7 +509,7 @@ App::get('/v1/vcs/github/installations/:installationId/providerRepositories/:pro $vcsContents = []; foreach ($contents as $content) { $isDirectory = false; - if($content['type'] === GitHub::CONTENTS_DIRECTORY) { + if ($content['type'] === GitHub::CONTENTS_DIRECTORY) { $isDirectory = true; } diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index eacea06de0..0cb88d31fa 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -207,14 +207,14 @@ App::init() } // Remove after migration - if(!\str_contains($apiKey, '_')) { + if (!\str_contains($apiKey, '_')) { $keyType = API_KEY_STANDARD; $authKey = $apiKey; } else { [ $keyType, $authKey ] = \explode('_', $apiKey, 2); } - if($keyType === API_KEY_DYNAMIC) { + if ($keyType === API_KEY_DYNAMIC) { // Dynamic key $jwtObj = new JWT(System::getEnv('_APP_OPENSSL_KEY_V1'), 'HS256', 3600, 0); @@ -244,7 +244,7 @@ App::init() Authorization::setRole(Auth::USER_ROLE_APPS); Authorization::setDefaultStatus(false); // Cancel security segmentation for API keys. } - } elseif($keyType === API_KEY_STANDARD) { + } elseif ($keyType === API_KEY_STANDARD) { // No underline means no prefix. Backwards compatibility. // Regular key diff --git a/app/init.php b/app/init.php index 08cb09b68b..2a5e29803c 100644 --- a/app/init.php +++ b/app/init.php @@ -791,7 +791,7 @@ $register->set('logger', function () { $adapter = null; } - if($adapter === null) { + if ($adapter === null) { Console::error("Logging provider not supported. Logging is disabled"); return; } @@ -1267,7 +1267,7 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons } $jwtSessionId = $payload['sessionId'] ?? ''; - if(!empty($jwtSessionId)) { + if (!empty($jwtSessionId)) { if (empty($user->find('$id', $jwtSessionId, 'sessions'))) { // Match JWT to active token $user = new Document([]); } diff --git a/src/Appwrite/Extend/Exception.php b/src/Appwrite/Extend/Exception.php index 884296ff67..e0cf8058c9 100644 --- a/src/Appwrite/Extend/Exception.php +++ b/src/Appwrite/Extend/Exception.php @@ -313,7 +313,7 @@ class Exception extends \Exception $this->code = $code ?? $this->errors[$type]['code']; // Mark string errors like HY001 from PDO as 500 errors - if(\is_string($this->code)) { + if (\is_string($this->code)) { if (\is_numeric($this->code)) { $this->code = (int) $this->code; } else { diff --git a/src/Appwrite/Functions/Validator/Headers.php b/src/Appwrite/Functions/Validator/Headers.php index 6d5b2da5df..04003d535b 100644 --- a/src/Appwrite/Functions/Validator/Headers.php +++ b/src/Appwrite/Functions/Validator/Headers.php @@ -44,7 +44,7 @@ class Headers extends Validator return false; } - if(\count($value) > $this->maxKeys) { + if (\count($value) > $this->maxKeys) { return false; } @@ -57,7 +57,7 @@ class Headers extends Validator } $size += $length + \strlen($val); - if($size >= $this->maxSize) { + if ($size >= $this->maxSize) { return false; } diff --git a/src/Appwrite/Platform/Workers/Builds.php b/src/Appwrite/Platform/Workers/Builds.php index d8359f5f65..2b8acf8177 100644 --- a/src/Appwrite/Platform/Workers/Builds.php +++ b/src/Appwrite/Platform/Workers/Builds.php @@ -208,7 +208,7 @@ class Builds extends Action } try { - if($isNewBuild && !$isVcsEnabled) { + if ($isNewBuild && !$isVcsEnabled) { // Non-vcs+Template $templateRepositoryName = $template->getAttribute('repositoryName', ''); @@ -279,7 +279,7 @@ class Builds extends Action $cloneVersion = $branchName; $cloneType = GitHub::CLONE_TYPE_BRANCH; - if(!empty($commitHash)) { + if (!empty($commitHash)) { $cloneVersion = $commitHash; $cloneType = GitHub::CLONE_TYPE_COMMIT; } @@ -543,7 +543,7 @@ class Builds extends Action deploymentId: $deployment->getId(), projectId: $project->getId(), callback: function ($logs) use (&$response, &$err, &$build, $dbForProject, $allEvents, $project, &$isCanceled) { - if($isCanceled) { + if ($isCanceled) { return; } diff --git a/src/Appwrite/Platform/Workers/Messaging.php b/src/Appwrite/Platform/Workers/Messaging.php index 6f642fabb7..0f0d298e3b 100644 --- a/src/Appwrite/Platform/Workers/Messaging.php +++ b/src/Appwrite/Platform/Workers/Messaging.php @@ -669,7 +669,7 @@ class Messaging extends Action private function getLocalDevice($project): Local { - if($this->localDevice === null) { + if ($this->localDevice === null) { $this->localDevice = new Local(APP_STORAGE_UPLOADS . '/app-' . $project->getId()); } diff --git a/src/Appwrite/Specification/Format/Swagger2.php b/src/Appwrite/Specification/Format/Swagger2.php index 4595a4cb6c..2eab7807b3 100644 --- a/src/Appwrite/Specification/Format/Swagger2.php +++ b/src/Appwrite/Specification/Format/Swagger2.php @@ -287,7 +287,7 @@ class Swagger2 extends Format } $validatorClass = (!empty($validator)) ? \get_class($validator) : ''; - if($validatorClass === 'Utopia\Validator\AnyOf') { + if ($validatorClass === 'Utopia\Validator\AnyOf') { $validator = $param['validator']->getValidators()[0]; $validatorClass = \get_class($validator); } diff --git a/src/Appwrite/Utopia/Response/Filters/V16.php b/src/Appwrite/Utopia/Response/Filters/V16.php index 2a27715d5e..7eb3ec6eb3 100644 --- a/src/Appwrite/Utopia/Response/Filters/V16.php +++ b/src/Appwrite/Utopia/Response/Filters/V16.php @@ -33,13 +33,13 @@ class V16 extends Filter protected function parseDeployment(array $content) { - if(isset($content['buildLogs'])) { + if (isset($content['buildLogs'])) { $content['buildStderr'] = ''; $content['buildStdout'] = $content['buildLogs']; unset($content['buildLogs']); } - if(isset($content['buildSize'])) { + if (isset($content['buildSize'])) { $content['size'] += + $content['buildSize'] ?? 0; unset($content['buildSize']); } diff --git a/src/Appwrite/Utopia/Response/Filters/V18.php b/src/Appwrite/Utopia/Response/Filters/V18.php index 0a74a2afed..fc1624a289 100644 --- a/src/Appwrite/Utopia/Response/Filters/V18.php +++ b/src/Appwrite/Utopia/Response/Filters/V18.php @@ -25,8 +25,8 @@ class V18 extends Filter protected function parseExecution(array $content) { - if(!empty($content['status']) && !empty($content['statusCode'])) { - if($content['status'] === 'completed' && $content['statusCode'] >= 400 && $content['statusCode'] < 500) { + if (!empty($content['status']) && !empty($content['statusCode'])) { + if ($content['status'] === 'completed' && $content['statusCode'] >= 400 && $content['statusCode'] < 500) { $content['status'] = 'failed'; } } diff --git a/src/Appwrite/Utopia/Response/Model/Document.php b/src/Appwrite/Utopia/Response/Model/Document.php index 242af6926f..41a10cee89 100644 --- a/src/Appwrite/Utopia/Response/Model/Document.php +++ b/src/Appwrite/Utopia/Response/Model/Document.php @@ -72,7 +72,8 @@ class Document extends Any public function filter(DatabaseDocument $document): DatabaseDocument { $document->removeAttribute('$internalId'); - $document->removeAttribute('$collection'); // $collection is the internal collection ID + $document->removeAttribute('$collection'); + $document->removeAttribute('$tenant'); foreach ($document->getAttributes() as $attribute) { if (\is_array($attribute)) { diff --git a/src/Executor/Executor.php b/src/Executor/Executor.php index 7cd239623c..c230cfb664 100644 --- a/src/Executor/Executor.php +++ b/src/Executor/Executor.php @@ -217,7 +217,7 @@ class Executor 'restartPolicy' => 'always' // Once utopia/orchestration has it, use DockerAPI::ALWAYS (0.13+) ]; - if(!empty($body)) { + if (!empty($body)) { $params['body'] = $body; } diff --git a/tests/e2e/Services/Functions/FunctionsBase.php b/tests/e2e/Services/Functions/FunctionsBase.php index abefb5c9a3..2d94b9f0e3 100644 --- a/tests/e2e/Services/Functions/FunctionsBase.php +++ b/tests/e2e/Services/Functions/FunctionsBase.php @@ -34,7 +34,7 @@ trait FunctionsBase \sleep(1); } - if($checkForSuccess) { + if ($checkForSuccess) { $this->assertEquals(200, $deployment['headers']['status-code']); $this->assertEquals('ready', $deployment['body']['status'], \json_encode($deployment['body'])); } diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 0607f40924..912a7a3f2c 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -1072,7 +1072,7 @@ class FunctionsCustomServerTest extends Scope $found = false; foreach ($response['body']['deployments'] as $deployment) { - if($deployment['$id'] === $deploymentId) { + if ($deployment['$id'] === $deploymentId) { $found = true; $this->assertEquals($deploymentSize, $deployment['size']); break; diff --git a/tests/e2e/Services/Webhooks/WebhooksBase.php b/tests/e2e/Services/Webhooks/WebhooksBase.php index 6f6b36c520..6be3e16c1f 100644 --- a/tests/e2e/Services/Webhooks/WebhooksBase.php +++ b/tests/e2e/Services/Webhooks/WebhooksBase.php @@ -31,7 +31,7 @@ trait WebhooksBase \sleep(1); } - if($checkForSuccess) { + if ($checkForSuccess) { $this->assertEquals(200, $deployment['headers']['status-code']); $this->assertEquals('ready', $deployment['body']['status'], \json_encode($deployment['body'])); } diff --git a/tests/unit/Functions/Validator/HeadersBench.php b/tests/unit/Functions/Validator/HeadersBench.php index e1f9fcc5ff..f95fa65f9b 100644 --- a/tests/unit/Functions/Validator/HeadersBench.php +++ b/tests/unit/Functions/Validator/HeadersBench.php @@ -27,19 +27,19 @@ final class HeadersBench yield 'empty' => [ 'value' => [] ]; $value = []; - for($i = 0; $i < 10; $i++) { + for ($i = 0; $i < 10; $i++) { $value[bin2hex(random_bytes(8))] = bin2hex(random_bytes(8)); } yield 'items_10-size_320' => [ 'value' => $value ]; $value = []; - for($i = 0; $i < 100; $i++) { + for ($i = 0; $i < 100; $i++) { $value[bin2hex(random_bytes(8))] = bin2hex(random_bytes(8)); } yield 'items_100-size_3200' => [ 'value' => $value ]; $value = []; - for($i = 0; $i < 100; $i++) { + for ($i = 0; $i < 100; $i++) { $value[bin2hex(random_bytes(32))] = bin2hex(random_bytes(32)); } yield 'items_100-size_12800' => [ 'value' => $value ]; @@ -53,7 +53,7 @@ final class HeadersBench public function benchHeadersValidator(array $data): void { $assertion = $this->validator->isValid($data['value']); - if(!$assertion) { + if (!$assertion) { exit(1); } } diff --git a/tests/unit/Functions/Validator/HeadersTest.php b/tests/unit/Functions/Validator/HeadersTest.php index c9373c5991..4a45f57427 100644 --- a/tests/unit/Functions/Validator/HeadersTest.php +++ b/tests/unit/Functions/Validator/HeadersTest.php @@ -109,7 +109,7 @@ class HeadersTest extends TestCase $this->assertTrue($this->object->isValid($headers)); $headers = []; - for($i = 0; $i < 100; $i++) { + for ($i = 0; $i < 100; $i++) { $headers['key-' . $i] = 'value_' . $i; } $this->assertTrue($this->object->isValid($headers)); From 501e7c2fa057a09d16e1831ca6e73760e7d3140a Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 5 Sep 2024 14:28:15 +1200 Subject: [PATCH 4/8] Add assertion --- tests/e2e/Services/Databases/DatabasesBase.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/e2e/Services/Databases/DatabasesBase.php b/tests/e2e/Services/Databases/DatabasesBase.php index 6ebd95aa5d..04f2dbd8c8 100644 --- a/tests/e2e/Services/Databases/DatabasesBase.php +++ b/tests/e2e/Services/Databases/DatabasesBase.php @@ -1593,6 +1593,7 @@ trait DatabasesBase $this->assertEquals($response['body']['$permissions'], $document['$permissions']); $this->assertEquals($response['body']['birthDay'], $document['birthDay']); $this->assertFalse(array_key_exists('$internalId', $response['body'])); + $this->assertFalse(array_key_exists('$tenant', $response['body'])); } } From fbe824af108f44c84065e704e5ea8b662ee12e62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Thu, 5 Sep 2024 10:17:30 +0000 Subject: [PATCH 5/8] Fix router function execution logging --- app/controllers/general.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/controllers/general.php b/app/controllers/general.php index ff670c68ca..b79e3554db 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -97,6 +97,9 @@ function router(App $utopia, Database $dbForConsole, callable $getProjectDB, Swo $type = $route->getAttribute('resourceType'); if ($type === 'function') { + $utopia->getRoute()?->label('sdk.namespace', 'functions'); + $utopia->getRoute()?->label('sdk.method', 'createExecution'); + if (System::getEnv('_APP_OPTIONS_FUNCTIONS_FORCE_HTTPS', 'disabled') === 'enabled') { // Force HTTPS if ($request->getProtocol() !== 'https') { if ($request->getMethod() !== Request::METHOD_GET) { From 9891f616108104173ca640b18c3aecacb4b90b90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Thu, 5 Sep 2024 16:33:16 +0200 Subject: [PATCH 6/8] Improve mail datetime format --- app/config/locale/translations/en.json | 2 +- app/controllers/api/account.php | 4 +- composer.lock | 76 +++++++++++++------------- 3 files changed, 42 insertions(+), 40 deletions(-) diff --git a/app/config/locale/translations/en.json b/app/config/locale/translations/en.json index b16b50196f..937ab298de 100644 --- a/app/config/locale/translations/en.json +++ b/app/config/locale/translations/en.json @@ -20,7 +20,7 @@ "emails.magicSession.signature": "{{project}} team", "emails.sessionAlert.subject": "Security alert: new session on your {{project}} account", "emails.sessionAlert.hello":"Hello {{user}}", - "emails.sessionAlert.body": "A new session has been created on your {{b}}{{project}}{{/b}} account, on {{b}}{{dateTime}}{{/b}}.\nHere are the details of the new session: ", + "emails.sessionAlert.body": "A new session has been created on your {{b}}{{project}}{{/b}} account, {{b}}on {{date}}, {{year}} at {{time}} UTC{{/b}}.\nHere are the details of the new session: ", "emails.sessionAlert.listDevice": "Device: {{b}}{{device}}{{/b}}", "emails.sessionAlert.listIpAddress": "IP Address: {{b}}{{ipAddress}}{{/b}}", "emails.sessionAlert.listCountry": "Country: {{b}}{{country}}{{/b}}", diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 15c0ff9e97..17f3af4364 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -124,7 +124,9 @@ function sendSessionAlert(Locale $locale, Document $user, Document $project, Doc $emailVariables = [ 'direction' => $locale->getText('settings.direction'), - 'dateTime' => DateTime::format(new \DateTime(), 'h:ia MMMM dS'), + 'date' => (new \DateTime())->format('F j'), + 'year' => (new \DateTime())->format('YYYY'), + 'time' => (new \DateTime())->format('H:i:s'), 'user' => $user->getAttribute('name'), 'project' => $project->getAttribute('name'), 'device' => $session->getAttribute('clientName'), diff --git a/composer.lock b/composer.lock index 78e256efee..469eb531c1 100644 --- a/composer.lock +++ b/composer.lock @@ -2599,16 +2599,16 @@ }, { "name": "utopia-php/storage", - "version": "0.18.4", + "version": "0.18.5", "source": { "type": "git", "url": "https://github.com/utopia-php/storage.git", - "reference": "94ab8758fabcefee5c5fa723616e45719833f922" + "reference": "7d355c5e3ccc8ecebc0266f8ddd30088a43be919" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/storage/zipball/94ab8758fabcefee5c5fa723616e45719833f922", - "reference": "94ab8758fabcefee5c5fa723616e45719833f922", + "url": "https://api.github.com/repos/utopia-php/storage/zipball/7d355c5e3ccc8ecebc0266f8ddd30088a43be919", + "reference": "7d355c5e3ccc8ecebc0266f8ddd30088a43be919", "shasum": "" }, "require": { @@ -2648,9 +2648,9 @@ ], "support": { "issues": "https://github.com/utopia-php/storage/issues", - "source": "https://github.com/utopia-php/storage/tree/0.18.4" + "source": "https://github.com/utopia-php/storage/tree/0.18.5" }, - "time": "2024-04-02T08:24:09+00:00" + "time": "2024-09-04T08:57:27+00:00" }, { "name": "utopia-php/swoole", @@ -3314,16 +3314,16 @@ }, { "name": "laravel/pint", - "version": "v1.17.2", + "version": "v1.17.3", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "e8a88130a25e3f9d4d5785e6a1afca98268ab110" + "reference": "9d77be916e145864f10788bb94531d03e1f7b482" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/e8a88130a25e3f9d4d5785e6a1afca98268ab110", - "reference": "e8a88130a25e3f9d4d5785e6a1afca98268ab110", + "url": "https://api.github.com/repos/laravel/pint/zipball/9d77be916e145864f10788bb94531d03e1f7b482", + "reference": "9d77be916e145864f10788bb94531d03e1f7b482", "shasum": "" }, "require": { @@ -3334,13 +3334,13 @@ "php": "^8.1.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.61.1", - "illuminate/view": "^10.48.18", + "friendsofphp/php-cs-fixer": "^3.64.0", + "illuminate/view": "^10.48.20", "larastan/larastan": "^2.9.8", "laravel-zero/framework": "^10.4.0", "mockery/mockery": "^1.6.12", "nunomaduro/termwind": "^1.15.1", - "pestphp/pest": "^2.35.0" + "pestphp/pest": "^2.35.1" }, "bin": [ "builds/pint" @@ -3376,7 +3376,7 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2024-08-06T15:11:54+00:00" + "time": "2024-09-03T15:00:28+00:00" }, { "name": "matthiasmullie/minify", @@ -4185,16 +4185,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.29.1", + "version": "1.30.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "fcaefacf2d5c417e928405b71b400d4ce10daaf4" + "reference": "5ceb0e384997db59f38774bf79c2a6134252c08f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/fcaefacf2d5c417e928405b71b400d4ce10daaf4", - "reference": "fcaefacf2d5c417e928405b71b400d4ce10daaf4", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/5ceb0e384997db59f38774bf79c2a6134252c08f", + "reference": "5ceb0e384997db59f38774bf79c2a6134252c08f", "shasum": "" }, "require": { @@ -4226,9 +4226,9 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.29.1" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.30.0" }, - "time": "2024-05-31T08:52:43+00:00" + "time": "2024-08-29T09:54:52+00:00" }, { "name": "phpunit/php-code-coverage", @@ -5865,16 +5865,16 @@ }, { "name": "symfony/console", - "version": "v7.1.3", + "version": "v7.1.4", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "cb1dcb30ebc7005c29864ee78adb47b5fb7c3cd9" + "reference": "1eed7af6961d763e7832e874d7f9b21c3ea9c111" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/cb1dcb30ebc7005c29864ee78adb47b5fb7c3cd9", - "reference": "cb1dcb30ebc7005c29864ee78adb47b5fb7c3cd9", + "url": "https://api.github.com/repos/symfony/console/zipball/1eed7af6961d763e7832e874d7f9b21c3ea9c111", + "reference": "1eed7af6961d763e7832e874d7f9b21c3ea9c111", "shasum": "" }, "require": { @@ -5938,7 +5938,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v7.1.3" + "source": "https://github.com/symfony/console/tree/v7.1.4" }, "funding": [ { @@ -5954,7 +5954,7 @@ "type": "tidelift" } ], - "time": "2024-07-26T12:41:01+00:00" + "time": "2024-08-15T22:48:53+00:00" }, { "name": "symfony/deprecation-contracts", @@ -6091,16 +6091,16 @@ }, { "name": "symfony/finder", - "version": "v7.1.3", + "version": "v7.1.4", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "717c6329886f32dc65e27461f80f2a465412fdca" + "reference": "d95bbf319f7d052082fb7af147e0f835a695e823" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/717c6329886f32dc65e27461f80f2a465412fdca", - "reference": "717c6329886f32dc65e27461f80f2a465412fdca", + "url": "https://api.github.com/repos/symfony/finder/zipball/d95bbf319f7d052082fb7af147e0f835a695e823", + "reference": "d95bbf319f7d052082fb7af147e0f835a695e823", "shasum": "" }, "require": { @@ -6135,7 +6135,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v7.1.3" + "source": "https://github.com/symfony/finder/tree/v7.1.4" }, "funding": [ { @@ -6151,7 +6151,7 @@ "type": "tidelift" } ], - "time": "2024-07-24T07:08:44+00:00" + "time": "2024-08-13T14:28:19+00:00" }, { "name": "symfony/options-resolver", @@ -6604,16 +6604,16 @@ }, { "name": "symfony/string", - "version": "v7.1.3", + "version": "v7.1.4", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "ea272a882be7f20cad58d5d78c215001617b7f07" + "reference": "6cd670a6d968eaeb1c77c2e76091c45c56bc367b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/ea272a882be7f20cad58d5d78c215001617b7f07", - "reference": "ea272a882be7f20cad58d5d78c215001617b7f07", + "url": "https://api.github.com/repos/symfony/string/zipball/6cd670a6d968eaeb1c77c2e76091c45c56bc367b", + "reference": "6cd670a6d968eaeb1c77c2e76091c45c56bc367b", "shasum": "" }, "require": { @@ -6671,7 +6671,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v7.1.3" + "source": "https://github.com/symfony/string/tree/v7.1.4" }, "funding": [ { @@ -6687,7 +6687,7 @@ "type": "tidelift" } ], - "time": "2024-07-22T10:25:37+00:00" + "time": "2024-08-12T09:59:40+00:00" }, { "name": "textalk/websocket", From d8c15079b68d33c2d764844b83682736649918f4 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Fri, 6 Sep 2024 00:08:22 +0400 Subject: [PATCH 7/8] chore: update console --- .cursorignore | 9 +++++++++ app/views/install/compose.phtml | 2 +- docker-compose.yml | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 .cursorignore diff --git a/.cursorignore b/.cursorignore new file mode 100644 index 0000000000..6c79722b64 --- /dev/null +++ b/.cursorignore @@ -0,0 +1,9 @@ +# Add directories or file patterns to ignore during indexing (e.g. foo/ or *.csv) +docs/* +logs/* +public/* +tests/* +bin/* +vendor/* +app/sdks/* +app/assets/* \ No newline at end of file diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index d03fe7bbb2..eda5fa1af2 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -166,7 +166,7 @@ $image = $this->getParam('image', ''); appwrite-console: <<: *x-logging container_name: appwrite-console - image: /console:5.0.4 + image: /console:5.0.10 restart: unless-stopped networks: - appwrite diff --git a/docker-compose.yml b/docker-compose.yml index 3d3ac5c167..502c9dcd5c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -196,7 +196,7 @@ services: appwrite-console: <<: *x-logging container_name: appwrite-console - image: appwrite/console:5.0.4 + image: appwrite/console:5.0.10 restart: unless-stopped networks: - appwrite From 730cb5280d2be212fa1cef7886db96dd1b0d54b0 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Fri, 6 Sep 2024 00:15:48 +0400 Subject: [PATCH 8/8] chore: update console --- .cursorignore | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 .cursorignore diff --git a/.cursorignore b/.cursorignore deleted file mode 100644 index 6c79722b64..0000000000 --- a/.cursorignore +++ /dev/null @@ -1,9 +0,0 @@ -# Add directories or file patterns to ignore during indexing (e.g. foo/ or *.csv) -docs/* -logs/* -public/* -tests/* -bin/* -vendor/* -app/sdks/* -app/assets/* \ No newline at end of file