From 68b2706797319ea8e394fc70492584e18047ef22 Mon Sep 17 00:00:00 2001 From: Steven Nguyen Date: Fri, 15 Sep 2023 17:04:56 -0700 Subject: [PATCH 01/11] Fix project deletion The project deletion failed because old code for deleting domain was still present. By removing the old code and replacing it with the new delete rule code, the project deletion is now working. --- app/workers/deletes.php | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/app/workers/deletes.php b/app/workers/deletes.php index f3968c07f2..4ef3bdde2c 100644 --- a/app/workers/deletes.php +++ b/app/workers/deletes.php @@ -71,7 +71,7 @@ class DeletesV1 extends Worker $this->deleteInstallation($document, $project); break; case DELETE_TYPE_RULES: - $this->deleteRule($document, $project); + $this->deleteRule($document); break; default: if (\str_starts_with($document->getCollection(), 'database_')) { @@ -369,14 +369,6 @@ class DeletesV1 extends Worker // Delete project certificates $dbForConsole = $this->getConsoleDB(); - $domains = $dbForConsole->find('domains', [ - Query::equal('projectInternalId', [$projectInternalId]) - ]); - - foreach ($domains as $domain) { - $this->deleteCertificates($domain); - } - // Delete project tables $dbForProject = $this->getProjectDB($document); @@ -397,10 +389,12 @@ class DeletesV1 extends Worker Query::equal('projectInternalId', [$projectInternalId]) ], $dbForConsole); - // Delete Domains - $this->deleteByGroup('domains', [ + // Delete project and function rules + $this->deleteByGroup('rules', [ Query::equal('projectInternalId', [$projectInternalId]) - ], $dbForConsole); + ], $dbForConsole, function (Document $document) { + $this->deleteRule($document); + }); // Delete Keys $this->deleteByGroup('keys', [ @@ -861,7 +855,7 @@ class DeletesV1 extends Worker * @param Document $document rule document * @param Document $project project document */ - protected function deleteRule(Document $document, Document $project): void + protected function deleteRule(Document $document): void { $consoleDB = $this->getConsoleDB(); From c5e059c118e414d14c877e729dae308612594df9 Mon Sep 17 00:00:00 2001 From: Steven Nguyen Date: Wed, 20 Sep 2023 18:58:11 -0700 Subject: [PATCH 02/11] Fix delete function deployment Prior to this, deleting a VCS deployment would fail because the deployment path for VCS deployments are empty. Because an error gets thrown, the delete function would stop and not delete the build files. This change updates the worker to only delete the storage files if the path is set. --- app/workers/deletes.php | 45 ++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/app/workers/deletes.php b/app/workers/deletes.php index f3968c07f2..51573a0267 100644 --- a/app/workers/deletes.php +++ b/app/workers/deletes.php @@ -679,12 +679,25 @@ class DeletesV1 extends Worker /** * Delete deployment files */ - Console::info("Deleting deployment files for deployment " . $deploymentId); - $storageFunctions = $this->getFunctionsDevice($projectId); - if ($storageFunctions->delete($document->getAttribute('path', ''), true)) { - Console::success('Deleted deployment files: ' . $document->getAttribute('path', '')); + $deploymentPath = $document->getAttribute('path', ''); + if (empty($deploymentPath)) { + Console::info("No deployment files for deployment " . $deploymentId); } else { - Console::error('Failed to delete deployment files: ' . $document->getAttribute('path', '')); + Console::info("Deleting deployment files for deployment " . $deploymentId); + $storageFunctions = $this->getFunctionsDevice($projectId); + try { + if ($storageFunctions->delete($deploymentPath, true)) { + Console::success('Deleted deployment files: ' . $deploymentPath); + } else { + Console::error('Failed to delete deployment files: ' . $deploymentPath); + } + } catch (\Throwable $th) { + Console::error('Failed to delete deployment files: ' . $deploymentPath); + Console::error('[Error] Type: ' . get_class($th)); + Console::error('[Error] Message: ' . $th->getMessage()); + Console::error('[Error] File: ' . $th->getFile()); + Console::error('[Error] Line: ' . $th->getLine()); + } } /** @@ -695,10 +708,24 @@ class DeletesV1 extends Worker $this->deleteByGroup('builds', [ Query::equal('deploymentInternalId', [$deploymentInternalId]) ], $dbForProject, function (Document $document) use ($storageBuilds) { - if ($storageBuilds->delete($document->getAttribute('path', ''), true)) { - Console::success('Deleted build files: ' . $document->getAttribute('path', '')); - } else { - Console::error('Failed to delete build files: ' . $document->getAttribute('path', '')); + $buildPath = $document->getAttribute('path', ''); + if (empty($buildPath)) { + Console::info("No build files for build " . $document->getId()); + return; + } + + try { + if ($storageBuilds->delete($buildPath, true)) { + Console::success('Deleted build files: ' . $buildPath); + } else { + Console::error('Failed to delete build files: ' . $buildPath); + } + } catch (\Throwable $th) { + Console::error('Failed to delete deployment files: ' . $buildPath); + Console::error('[Error] Type: ' . get_class($th)); + Console::error('[Error] Message: ' . $th->getMessage()); + Console::error('[Error] File: ' . $th->getFile()); + Console::error('[Error] Line: ' . $th->getLine()); } }); From 9ca82b76627013b3e91de890142072778e2ee52e Mon Sep 17 00:00:00 2001 From: Steven Nguyen Date: Wed, 20 Sep 2023 19:26:23 -0700 Subject: [PATCH 03/11] Fix missing resourceInternalId on deployments --- app/controllers/api/functions.php | 1 + app/controllers/api/vcs.php | 2 ++ 2 files changed, 3 insertions(+) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 7c51d5377e..6f342df214 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -84,6 +84,7 @@ $redeployVcs = function (Request $request, Document $function, Document $project Permission::delete(Role::any()), ], 'resourceId' => $function->getId(), + 'resourceInternalId' => $function->getInternalId(), 'resourceType' => 'functions', 'entrypoint' => $entrypoint, 'commands' => $function->getAttribute('commands', ''), diff --git a/app/controllers/api/vcs.php b/app/controllers/api/vcs.php index 2abf4ef30c..b0050c61d4 100644 --- a/app/controllers/api/vcs.php +++ b/app/controllers/api/vcs.php @@ -50,6 +50,7 @@ $createGitDeployments = function (GitHub $github, string $providerInstallationId $functionId = $resource->getAttribute('resourceId'); $function = Authorization::skip(fn () => $dbForProject->getDocument('functions', $functionId)); + $functionInternalId = $function->getInternalId(); $deploymentId = ID::unique(); $repositoryId = $resource->getId(); @@ -173,6 +174,7 @@ $createGitDeployments = function (GitHub $github, string $providerInstallationId Permission::delete(Role::any()), ], 'resourceId' => $functionId, + 'resourceInternalId' => $functionInternalId, 'resourceType' => 'functions', 'entrypoint' => $function->getAttribute('entrypoint'), 'commands' => $function->getAttribute('commands'), From bb70860b921ef2e02d9381bdfb07121ac41dcc44 Mon Sep 17 00:00:00 2001 From: Steven Nguyen Date: Wed, 20 Sep 2023 19:31:06 -0700 Subject: [PATCH 04/11] Fix deployment and build files deletion on function delete Make sure deployment and build paths exist before deleting fiels. --- app/workers/deletes.php | 119 +++++++++++++++++++++------------------- 1 file changed, 64 insertions(+), 55 deletions(-) diff --git a/app/workers/deletes.php b/app/workers/deletes.php index 51573a0267..118015ed28 100644 --- a/app/workers/deletes.php +++ b/app/workers/deletes.php @@ -14,6 +14,7 @@ use Utopia\Abuse\Adapters\TimeLimit; use Utopia\CLI\Console; use Utopia\Audit\Audit; use Utopia\Database\DateTime; +use Utopia\Storage\Device; require_once __DIR__ . '/../init.php'; @@ -620,33 +621,25 @@ class DeletesV1 extends Worker * Delete Deployments */ Console::info("Deleting deployments for function " . $functionId); - $storageFunctions = $this->getFunctionsDevice($projectId); + $deviceFunctions = $this->getFunctionsDevice($projectId); $deploymentInternalIds = []; $this->deleteByGroup('deployments', [ Query::equal('resourceInternalId', [$functionInternalId]) - ], $dbForProject, function (Document $document) use ($storageFunctions, &$deploymentInternalIds) { + ], $dbForProject, function (Document $document) use ($deviceFunctions, &$deploymentInternalIds) { $deploymentInternalIds[] = $document->getInternalId(); - if ($storageFunctions->delete($document->getAttribute('path', ''), true)) { - Console::success('Deleted deployment files: ' . $document->getAttribute('path', '')); - } else { - Console::error('Failed to delete deployment files: ' . $document->getAttribute('path', '')); - } + $this->deleteDeploymentFiles($deviceFunctions, $document); }); /** * Delete builds */ Console::info("Deleting builds for function " . $functionId); - $storageBuilds = $this->getBuildsDevice($projectId); + $deviceBuilds = $this->getBuildsDevice($projectId); foreach ($deploymentInternalIds as $deploymentInternalId) { $this->deleteByGroup('builds', [ Query::equal('deploymentInternalId', [$deploymentInternalId]) - ], $dbForProject, function (Document $document) use ($storageBuilds) { - if ($storageBuilds->delete($document->getAttribute('path', ''), true)) { - Console::success('Deleted build files: ' . $document->getAttribute('path', '')); - } else { - Console::error('Failed to delete build files: ' . $document->getAttribute('path', '')); - } + ], $dbForProject, function (Document $document) use ($deviceBuilds) { + $this->deleteBuildFiles($deviceBuilds, $document); }); } @@ -665,6 +658,58 @@ class DeletesV1 extends Worker $this->deleteRuntimes($document, $project); } + protected function deleteDeploymentFiles(Device $device, Document $deployment) + { + $deploymentId = $deployment->getId(); + $deploymentPath = $deployment->getAttribute('path', ''); + + if (empty($deploymentPath)) { + Console::info("No deployment files for deployment " . $deploymentId); + return; + } + + Console::info("Deleting deployment files for deployment " . $deploymentId); + + try { + if ($device->delete($deploymentPath, true)) { + Console::success('Deleted deployment files: ' . $deploymentPath); + } else { + Console::error('Failed to delete deployment files: ' . $deploymentPath); + } + } catch (\Throwable $th) { + Console::error('Failed to delete deployment files: ' . $deploymentPath); + Console::error('[Error] Type: ' . get_class($th)); + Console::error('[Error] Message: ' . $th->getMessage()); + Console::error('[Error] File: ' . $th->getFile()); + Console::error('[Error] Line: ' . $th->getLine()); + } + } + + protected function deleteBuildFiles(Device $device, Document $build) + { + $buildId = $build->getId(); + $buildPath = $build->getAttribute('path', ''); + + if (empty($buildPath)) { + Console::info("No build files for build " . $buildId); + return; + } + + try { + if ($device->delete($buildPath, true)) { + Console::success('Deleted build files: ' . $buildPath); + } else { + Console::error('Failed to delete build files: ' . $buildPath); + } + } catch (\Throwable $th) { + Console::error('Failed to delete deployment files: ' . $buildPath); + Console::error('[Error] Type: ' . get_class($th)); + Console::error('[Error] Message: ' . $th->getMessage()); + Console::error('[Error] File: ' . $th->getFile()); + Console::error('[Error] Line: ' . $th->getLine()); + } + } + /** * @param Document $document deployment document * @param Document $project @@ -679,54 +724,18 @@ class DeletesV1 extends Worker /** * Delete deployment files */ - $deploymentPath = $document->getAttribute('path', ''); - if (empty($deploymentPath)) { - Console::info("No deployment files for deployment " . $deploymentId); - } else { - Console::info("Deleting deployment files for deployment " . $deploymentId); - $storageFunctions = $this->getFunctionsDevice($projectId); - try { - if ($storageFunctions->delete($deploymentPath, true)) { - Console::success('Deleted deployment files: ' . $deploymentPath); - } else { - Console::error('Failed to delete deployment files: ' . $deploymentPath); - } - } catch (\Throwable $th) { - Console::error('Failed to delete deployment files: ' . $deploymentPath); - Console::error('[Error] Type: ' . get_class($th)); - Console::error('[Error] Message: ' . $th->getMessage()); - Console::error('[Error] File: ' . $th->getFile()); - Console::error('[Error] Line: ' . $th->getLine()); - } - } + $deviceFunctions = $this->getFunctionsDevice($projectId); + $this->deleteDeploymentFiles($deviceFunctions, $document); /** * Delete builds */ Console::info("Deleting builds for deployment " . $deploymentId); - $storageBuilds = $this->getBuildsDevice($projectId); + $deviceBuilds = $this->getBuildsDevice($projectId); $this->deleteByGroup('builds', [ Query::equal('deploymentInternalId', [$deploymentInternalId]) - ], $dbForProject, function (Document $document) use ($storageBuilds) { - $buildPath = $document->getAttribute('path', ''); - if (empty($buildPath)) { - Console::info("No build files for build " . $document->getId()); - return; - } - - try { - if ($storageBuilds->delete($buildPath, true)) { - Console::success('Deleted build files: ' . $buildPath); - } else { - Console::error('Failed to delete build files: ' . $buildPath); - } - } catch (\Throwable $th) { - Console::error('Failed to delete deployment files: ' . $buildPath); - Console::error('[Error] Type: ' . get_class($th)); - Console::error('[Error] Message: ' . $th->getMessage()); - Console::error('[Error] File: ' . $th->getFile()); - Console::error('[Error] Line: ' . $th->getLine()); - } + ], $dbForProject, function (Document $document) use ($deviceBuilds) { + $this->deleteBuildFiles($deviceBuilds, $document); }); From d731d2b619be83fb2feb5f30693df91224232753 Mon Sep 17 00:00:00 2001 From: Steven Nguyen Date: Thu, 21 Sep 2023 15:35:40 -0700 Subject: [PATCH 05/11] Remove legacy comment --- app/workers/deletes.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/workers/deletes.php b/app/workers/deletes.php index 4ef3bdde2c..93df4e0a3a 100644 --- a/app/workers/deletes.php +++ b/app/workers/deletes.php @@ -366,7 +366,6 @@ class DeletesV1 extends Worker $projectId = $document->getId(); $projectInternalId = $document->getInternalId(); - // Delete project certificates $dbForConsole = $this->getConsoleDB(); // Delete project tables From 310517fd2951bb60b5ca4c2fa0e864493e745017 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Sun, 24 Sep 2023 13:19:31 +0200 Subject: [PATCH 06/11] Auto-parse event bodies + test --- app/workers/functions.php | 3 +- .../Functions/FunctionsCustomServerTest.php | 112 ++++++++++++++++++ tests/resources/functions/php-event/index.php | 8 ++ 3 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 tests/resources/functions/php-event/index.php diff --git a/app/workers/functions.php b/app/workers/functions.php index 619d33387a..20eda492bd 100644 --- a/app/workers/functions.php +++ b/app/workers/functions.php @@ -363,7 +363,8 @@ $server->job() path: '/', method: 'POST', headers: [ - 'user-agent' => 'Appwrite/' . APP_VERSION_STABLE + 'user-agent' => 'Appwrite/' . APP_VERSION_STABLE, + 'content-type' => 'application/json' ], ); Console::success('Triggered function: ' . $events[0]); diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 60b7f7542e..553db47960 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -1231,4 +1231,116 @@ class FunctionsCustomServerTest extends Scope $this->assertArrayHasKey('base', $runtime); $this->assertArrayHasKey('supports', $runtime); } + + + public function testEventTrigger() + { + $timeout = 5; + $code = realpath(__DIR__ . '/../../../resources/functions') . "/php-event/code.tar.gz"; + $this->packageCode('php-event'); + + $function = $this->client->call(Client::METHOD_POST, '/functions', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'functionId' => ID::unique(), + 'name' => 'Test PHP Event executions', + 'runtime' => 'php-8.0', + 'entrypoint' => 'index.php', + 'events' => [ + 'users.*.create', + ], + 'timeout' => $timeout, + ]); + + $functionId = $function['body']['$id'] ?? ''; + + $this->assertEquals(201, $function['headers']['status-code']); + + $deployment = $this->client->call(Client::METHOD_POST, '/functions/' . $functionId . '/deployments', array_merge([ + 'content-type' => 'multipart/form-data', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'entrypoint' => 'index.php', + 'code' => new CURLFile($code, 'application/x-gzip', basename($code)), + 'activate' => true + ]); + + $deploymentId = $deployment['body']['$id'] ?? ''; + $this->assertEquals(202, $deployment['headers']['status-code']); + + // Poll until deployment is built + while (true) { + $deployment = $this->client->call(Client::METHOD_GET, '/functions/' . $function['body']['$id'] . '/deployments/' . $deploymentId, [ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'], + ]); + + if ( + $deployment['headers']['status-code'] >= 400 + || \in_array($deployment['body']['status'], ['ready', 'failed']) + ) { + break; + } + + \sleep(1); + } + + $deployment = $this->client->call(Client::METHOD_PATCH, '/functions/' . $functionId . '/deployments/' . $deploymentId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), []); + + $this->assertEquals(200, $deployment['headers']['status-code']); + + // Create user to trigger event + $user = $this->client->call(Client::METHOD_POST, '/users', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'userId' => 'unique()', + 'name' => 'Event User' + ]); + + $userId = $user['body']['$id']; + + $this->assertEquals(201, $user['headers']['status-code']); + + // Wait for execution to occur + sleep(15); + + $executions = $this->client->call(Client::METHOD_GET, '/functions/' . $functionId . '/executions', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'async' => false + ]); + + $execution = $executions['body']['executions'][0]; + + $this->assertEquals(200, $executions['headers']['status-code']); + $this->assertEquals('completed', $execution['status']); + $this->assertEquals(204, $execution['responseStatusCode']); + $this->assertStringContainsString($userId, $execution['logs']); + $this->assertStringContainsString('Event User', $execution['logs']); + + // Cleanup : Delete function + $response = $this->client->call(Client::METHOD_DELETE, '/functions/' . $functionId, [ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'], + ], []); + + $this->assertEquals(204, $response['headers']['status-code']); + + // Cleanup : Delete user + $response = $this->client->call(Client::METHOD_DELETE, '/users/' . $userId, [ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'], + ], []); + + $this->assertEquals(204, $response['headers']['status-code']); + } } diff --git a/tests/resources/functions/php-event/index.php b/tests/resources/functions/php-event/index.php new file mode 100644 index 0000000000..550fd57729 --- /dev/null +++ b/tests/resources/functions/php-event/index.php @@ -0,0 +1,8 @@ +log($context->req->body['$id']); + $context->log($context->req->body['name']); + + return $context->res->empty(); +}; From fee30e0239f9b8ec5dfcf931018cc8f212834c67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Sun, 24 Sep 2023 14:34:27 +0200 Subject: [PATCH 07/11] Remove unnessessary test code --- tests/e2e/Services/Functions/FunctionsCustomServerTest.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 553db47960..0ca55f3929 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -1313,9 +1313,7 @@ class FunctionsCustomServerTest extends Scope $executions = $this->client->call(Client::METHOD_GET, '/functions/' . $functionId . '/executions', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders()), [ - 'async' => false - ]); + ], $this->getHeaders())); $execution = $executions['body']['executions'][0]; From 303c8a16ca6ab219d9e54437e08cb35256bd7dca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Sun, 24 Sep 2023 14:38:33 +0200 Subject: [PATCH 08/11] Fix test --- tests/e2e/Services/Functions/FunctionsCustomServerTest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 0ca55f3929..fd66f94025 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -1294,6 +1294,9 @@ class FunctionsCustomServerTest extends Scope $this->assertEquals(200, $deployment['headers']['status-code']); + // Wait a little for activation to finish + sleep(5); + // Create user to trigger event $user = $this->client->call(Client::METHOD_POST, '/users', array_merge([ 'content-type' => 'application/json', From a6aa38f1d829361530affca498cabbdf45a62068 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 25 Sep 2023 09:55:55 +0200 Subject: [PATCH 09/11] Fix test --- .../Services/Functions/FunctionsCustomServerTest.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index fd66f94025..cdc9ec846f 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -32,8 +32,8 @@ class FunctionsCustomServerTest extends Scope 'runtime' => 'php-8.0', 'entrypoint' => 'index.php', 'events' => [ - 'users.*.create', - 'users.*.delete', + 'buckets.*.create', + 'buckets.*.delete', ], 'schedule' => '0 0 1 1 *', 'timeout' => 10, @@ -50,8 +50,8 @@ class FunctionsCustomServerTest extends Scope $this->assertEquals(true, $dateValidator->isValid($response1['body']['$updatedAt'])); $this->assertEquals('', $response1['body']['deployment']); $this->assertEquals([ - 'users.*.create', - 'users.*.delete', + 'buckets.*.create', + 'buckets.*.delete', ], $response1['body']['events']); $this->assertEquals('0 0 1 1 *', $response1['body']['schedule']); $this->assertEquals(10, $response1['body']['timeout']); @@ -191,8 +191,8 @@ class FunctionsCustomServerTest extends Scope 'runtime' => 'php-8.0', 'entrypoint' => 'index.php', 'events' => [ - 'users.*.create', - 'users.*.delete', + 'buckets.*.create', + 'buckets.*.delete', ], 'schedule' => '0 0 1 1 *', 'timeout' => 10, From c35f05f495c9129699b989a180a6e795f37d283b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 25 Sep 2023 11:12:41 +0200 Subject: [PATCH 10/11] Increase max body size --- app/controllers/api/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 15c489164b..ddc75b8c7e 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -1496,7 +1496,7 @@ App::post('/v1/functions/:functionId/executions') ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_EXECUTION) ->param('functionId', '', new UID(), 'Function ID.') - ->param('body', '', new Text(8192, 0), 'HTTP body of execution. Default value is empty string.', true) + ->param('body', '', new Text(0, 0), 'HTTP body of execution. Default value is empty string.', true) ->param('async', false, new Boolean(), 'Execute code in the background. Default value is false.', true) ->param('path', '/', new Text(2048), 'HTTP path of execution. Path can include query params. Default value is /', true) ->param('method', 'POST', new Whitelist(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'], true), 'HTTP method of execution. Default value is GET.', true) From 420d2a9c369d47ac217819b5dcd93ef05a177027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 25 Sep 2023 15:05:51 +0200 Subject: [PATCH 11/11] @Meldiron Disable console endpoint protection --- app/controllers/web/console.php | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/app/controllers/web/console.php b/app/controllers/web/console.php index 01e985fc16..dcf9c80a51 100644 --- a/app/controllers/web/console.php +++ b/app/controllers/web/console.php @@ -1,6 +1,5 @@ groups(['web']) ->label('permission', 'public') ->label('scope', 'home') - ->inject('utopia') ->inject('request') ->inject('response') - ->action(function (App $utopia, Request $request, Response $response) { - $host = $request->getHostname() ?? ''; - $mainDomain = App::getEnv('_APP_DOMAIN', ''); - if (App::getEnv('_APP_OPTIONS_ROUTER_PROTECTION', 'disabled') === 'enabled' && $host !== $mainDomain) { - $utopia->getRoute()?->label('error', __DIR__ . '/../../views/general/error.phtml'); - throw new Exception(Exception::GENERAL_ACCESS_FORBIDDEN, 'Router protection does not allow accessing Appwrite Console over custom domain. Please disable _APP_OPTIONS_ROUTER_PROTECTION environment variable.'); - } - + ->action(function (Request $request, Response $response) { $fallback = file_get_contents(__DIR__ . '/../../../console/index.html'); // Card SSR