fix(messaging): require non-empty SES fromEmail and credentials to enable

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) <noreply@anthropic.com>
This commit is contained in:
Jake BarnbyandClaude Opus 4.8 committed 2026-06-03 03:20:17 +12:00
1 parent b28633086b
commit 1bfb0b115c
2 files changed
+8 -8

No files matched your search

+7 -7
View File
@@ -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 {
@@ -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',