diff --git a/src/Appwrite/Platform/Workers/Messaging.php b/src/Appwrite/Platform/Workers/Messaging.php index b0f05522fa..510fec0431 100644 --- a/src/Appwrite/Platform/Workers/Messaging.php +++ b/src/Appwrite/Platform/Workers/Messaging.php @@ -489,11 +489,29 @@ class Messaging extends Action return match ($provider->getAttribute('provider')) { 'mock' => new Mock('username', 'password'), - 'twilio' => new Twilio($credentials['accountSid'], $credentials['authToken'], null, isset($credentials['messagingServiceSid']) ? $credentials['messagingServiceSid'] : null), - 'textmagic' => new TextMagic($credentials['username'], $credentials['apiKey']), - 'telesign' => new Telesign($credentials['customerId'], $credentials['apiKey']), - 'msg91' => new Msg91($credentials['senderId'], $credentials['authKey'], $credentials['templateId']), - 'vonage' => new Vonage($credentials['apiKey'], $credentials['apiSecret']), + 'twilio' => new Twilio( + $credentials['accountSid'] ?? '', + $credentials['authToken'] ?? '', + null, + $credentials['messagingServiceSid'] ?? null + ), + 'textmagic' => new TextMagic( + $credentials['username'] ?? '', + $credentials['apiKey'] ?? '' + ), + 'telesign' => new Telesign( + $credentials['customerId'] ?? '', + $credentials['apiKey'] ?? '' + ), + 'msg91' => new Msg91( + $credentials['senderId'] ?? '', + $credentials['authKey'] ?? '', + $credentials['templateId'] ?? '' + ), + 'vonage' => new Vonage( + $credentials['apiKey'] ?? '', + $credentials['apiSecret'] ?? '' + ), default => null }; } @@ -506,11 +524,11 @@ class Messaging extends Action return match ($provider->getAttribute('provider')) { 'mock' => new Mock('username', 'password'), 'apns' => new APNS( - $credentials['authKey'], - $credentials['authKeyId'], - $credentials['teamId'], - $credentials['bundleId'], - $options['sandbox'] + $credentials['authKey'] ?? '', + $credentials['authKeyId'] ?? '', + $credentials['teamId'] ?? '', + $credentials['bundleId'] ?? '', + $options['sandbox'] ?? false ), 'fcm' => new FCM(\json_encode($credentials['serviceAccountJSON'])), default => null @@ -521,24 +539,25 @@ class Messaging extends Action { $credentials = $provider->getAttribute('credentials', []); $options = $provider->getAttribute('options', []); + $apiKey = $credentials['apiKey'] ?? ''; return match ($provider->getAttribute('provider')) { 'mock' => new Mock('username', 'password'), 'smtp' => new SMTP( - $credentials['host'], - $credentials['port'], - $credentials['username'], - $credentials['password'], - $options['encryption'], - $options['autoTLS'], - $options['mailer'], + $credentials['host'] ?? '', + $credentials['port'] ?? 25, + $credentials['username'] ?? '', + $credentials['password'] ?? '', + $options['encryption'] ?? '', + $options['autoTLS'] ?? false, + $options['mailer'] ?? '', ), 'mailgun' => new Mailgun( - $credentials['apiKey'], - $credentials['domain'], - $credentials['isEuRegion'] + $apiKey, + $credentials['domain'] ?? '', + $credentials['isEuRegion'] ?? false ), - 'sendgrid' => new Sendgrid($credentials['apiKey']), + 'sendgrid' => new Sendgrid($apiKey), default => null }; }