From 1bfb0b115c2b09ba3230c465f858c216af3f2dd8 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 3 Jun 2026 03:20:17 +1200 Subject: [PATCH] fix(messaging): require non-empty SES fromEmail and credentials to enable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The enable-guard used array_key_exists, which is true even for empty-string values — options['fromEmail'] is always stored on create, so a provider could be enabled with an empty sender address. Use !empty() on the values in both the create and update guards. Also corrects a misleading test comment. Co-Authored-By: Claude Opus 4.8 (1M context) --- app/controllers/api/messaging.php | 14 +++++++------- tests/e2e/Services/Messaging/MessagingBase.php | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/controllers/api/messaging.php b/app/controllers/api/messaging.php index b1adf60c33..8665fbf24c 100644 --- a/app/controllers/api/messaging.php +++ b/app/controllers/api/messaging.php @@ -297,9 +297,9 @@ Http::post('/v1/messaging/providers/ses') if ( $enabled === true && !empty($fromEmail) - && \array_key_exists('accessKey', $credentials) - && \array_key_exists('secretKey', $credentials) - && \array_key_exists('region', $credentials) + && !empty($credentials['accessKey']) + && !empty($credentials['secretKey']) + && !empty($credentials['region']) ) { $enabled = true; } else { @@ -1642,10 +1642,10 @@ Http::patch('/v1/messaging/providers/ses/:providerId') if (!\is_null($enabled)) { if ($enabled) { if ( - \array_key_exists('accessKey', $credentials) && - \array_key_exists('secretKey', $credentials) && - \array_key_exists('region', $credentials) && - \array_key_exists('fromEmail', $options) + !empty($credentials['accessKey']) && + !empty($credentials['secretKey']) && + !empty($credentials['region']) && + !empty($options['fromEmail']) ) { $provider->setAttribute('enabled', true); } else { diff --git a/tests/e2e/Services/Messaging/MessagingBase.php b/tests/e2e/Services/Messaging/MessagingBase.php index a18fecf5d2..163f11ff21 100644 --- a/tests/e2e/Services/Messaging/MessagingBase.php +++ b/tests/e2e/Services/Messaging/MessagingBase.php @@ -1055,7 +1055,7 @@ trait MessagingBase 'x-appwrite-key' => $this->getProject()['apiKey'], ]; - // Create disabled: missing fromEmail and partial credentials. + // Create with full credentials but no fromEmail, so the provider stays disabled. $response = $this->client->call(Client::METHOD_POST, '/messaging/providers/ses', $headers, [ 'providerId' => ID::unique(), 'name' => 'SES1',