From 3db9cd06d5e8aae55f912fa05e6f677a7adf51d6 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Tue, 29 Jul 2025 15:21:15 +0530 Subject: [PATCH 1/3] chore: filter certificates renewal task in maintenance by region --- src/Appwrite/Platform/Tasks/Maintenance.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Appwrite/Platform/Tasks/Maintenance.php b/src/Appwrite/Platform/Tasks/Maintenance.php index e6def793b5..4ffbcbbe8e 100644 --- a/src/Appwrite/Platform/Tasks/Maintenance.php +++ b/src/Appwrite/Platform/Tasks/Maintenance.php @@ -122,6 +122,15 @@ class Maintenance extends Action Console::info("[{$time}] Found " . \count($certificates) . " certificates for renewal, scheduling jobs."); foreach ($certificates as $certificate) { + $rule = $dbForPlatform->find('rules', [ + Query::equal('domain', [$certificate->getAttribute('domain')]), + Query::limit(1), + ]); + + if (!$rule[0] || $rule[0]->getAttribute('region') !== System::getEnv('_APP_REGION', 'default')) { + continue; + } + $queueForCertificate ->setDomain(new Document([ 'domain' => $certificate->getAttribute('domain') From 1731212ebbf1b69d753050f47538e4b177590a9c Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Tue, 29 Jul 2025 15:26:37 +0530 Subject: [PATCH 2/3] chore: improve check --- src/Appwrite/Platform/Tasks/Maintenance.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Appwrite/Platform/Tasks/Maintenance.php b/src/Appwrite/Platform/Tasks/Maintenance.php index 4ffbcbbe8e..aec6e78a6f 100644 --- a/src/Appwrite/Platform/Tasks/Maintenance.php +++ b/src/Appwrite/Platform/Tasks/Maintenance.php @@ -122,12 +122,11 @@ class Maintenance extends Action Console::info("[{$time}] Found " . \count($certificates) . " certificates for renewal, scheduling jobs."); foreach ($certificates as $certificate) { - $rule = $dbForPlatform->find('rules', [ + $rule = $dbForPlatform->findOne('rules', [ Query::equal('domain', [$certificate->getAttribute('domain')]), - Query::limit(1), ]); - if (!$rule[0] || $rule[0]->getAttribute('region') !== System::getEnv('_APP_REGION', 'default')) { + if ($rule->isEmpty() || $rule->getAttribute('region') !== System::getEnv('_APP_REGION', 'default')) { continue; } From 66786f20f0d6b4ddb58be775f6c86f9596f0d2f9 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Tue, 29 Jul 2025 16:53:55 +0530 Subject: [PATCH 3/3] chore: use md5 if enabled --- src/Appwrite/Platform/Tasks/Maintenance.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Appwrite/Platform/Tasks/Maintenance.php b/src/Appwrite/Platform/Tasks/Maintenance.php index aec6e78a6f..036e8783d4 100644 --- a/src/Appwrite/Platform/Tasks/Maintenance.php +++ b/src/Appwrite/Platform/Tasks/Maintenance.php @@ -122,9 +122,14 @@ class Maintenance extends Action Console::info("[{$time}] Found " . \count($certificates) . " certificates for renewal, scheduling jobs."); foreach ($certificates as $certificate) { - $rule = $dbForPlatform->findOne('rules', [ - Query::equal('domain', [$certificate->getAttribute('domain')]), - ]); + $domain = $certificate->getAttribute('domain'); + if (System::getEnv('_APP_RULES_FORMAT') === 'md5') { + $rule = $dbForPlatform->getDocument('rules', md5($domain)); + } else { + $rule = $dbForPlatform->findOne('rules', [ + Query::equal('domain', [$domain]), + ]); + } if ($rule->isEmpty() || $rule->getAttribute('region') !== System::getEnv('_APP_REGION', 'default')) { continue;