From 48d20b2c676a51ec46de3f4cd89167d750f8f4d6 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 28 Nov 2024 14:18:37 +0400 Subject: [PATCH] feat: update proxy and certificates files --- app/controllers/api/functions.php | 2 +- app/controllers/api/proxy.php | 9 ++++----- src/Appwrite/Platform/Workers/Certificates.php | 6 +++--- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 5dc67677ac..3b4b7392b4 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -329,7 +329,7 @@ App::post('/v1/functions') $routeSubdomain = ID::unique(); $domain = "{$routeSubdomain}.{$functionsDomain}"; // TODO: @christyjacob remove once we migrate the rules in 1.7.x - $ruleId = version_compare(APP_VERSION_STABLE, '1.7.0', '<') ? ID::unique() : md5($domain); + $ruleId = System::getEnv('_APP_RULES_FORMAT', null) === 'md5' ? md5($domain) : ID::unique(); $rule = Authorization::skip( fn () => $dbForConsole->createDocument('rules', new Document([ diff --git a/app/controllers/api/proxy.php b/app/controllers/api/proxy.php index 029bc5e8b3..21f1f3ce38 100644 --- a/app/controllers/api/proxy.php +++ b/app/controllers/api/proxy.php @@ -61,13 +61,12 @@ App::post('/v1/proxy/rules') } // TODO: @christyjacob remove once we migrate the rules in 1.7.x - if (version_compare(APP_VERSION_STABLE, '1.7.0', '<')) { + if (System::getEnv('_APP_RULES_FORMAT', null) === 'md5') { + $document = $dbForConsole->getDocument('rules', md5($domain)); + } else { $document = $dbForConsole->findOne('rules', [ Query::equal('domain', [$domain]), ]); - } else { - $ruleId = md5($domain); - $document = $dbForConsole->getDocument('rules', $ruleId); } @@ -111,7 +110,7 @@ App::post('/v1/proxy/rules') } // TODO: @christyjacob remove once we migrate the rules in 1.7.x - $ruleId = version_compare(APP_VERSION_STABLE, '1.7.0', '<') ? ID::unique() : md5($domain->get()); + $ruleId = System::getEnv('_APP_RULES_FORMAT', null) === 'md5' ? md5($domain->get()) : ID::unique(); $rule = new Document([ '$id' => $ruleId, diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index db7c73dd0c..e44ab1522f 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -340,12 +340,12 @@ class Certificates extends Action private function updateDomainDocuments(string $certificateId, string $domain, bool $success, Database $dbForConsole, Event $queueForEvents, Func $queueForFunctions): void { // TODO: @christyjacob remove once we migrate the rules in 1.7.x - if (version_compare(APP_VERSION_STABLE, '1.7.0', '<')) { + if (System::getEnv('_APP_RULES_FORMAT', null) === 'md5') { + $rule = $dbForConsole->getDocument('rules', md5($domain)); + } else { $rule = $dbForConsole->findOne('rules', [ Query::equal('domain', [$domain]), ]); - } else { - $rule = $dbForConsole->getDocument('rules', md5($domain)); } if (!$rule->isEmpty()) {