mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
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:
1 parent
b28633086b
commit
1bfb0b115c
2 files changed
+8
-8
No files matched your search
@@ -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',
|
||||
|
||||
Reference in new issue
Block a user