update validation

This commit is contained in:
shimon 2024-10-01 21:01:48 +03:00
parent 2af4ef705d
commit 3cb27d7b2c

View file

@ -489,11 +489,29 @@ class Messaging extends Action
return match ($provider->getAttribute('provider')) { return match ($provider->getAttribute('provider')) {
'mock' => new Mock('username', 'password'), 'mock' => new Mock('username', 'password'),
'twilio' => new Twilio($credentials['accountSid'] ?? 'accountSid', $credentials['authToken'] ?? 'authToken', null, $credentials['messagingServiceSid'] ?? null), 'twilio' => new Twilio(
'textmagic' => new TextMagic($credentials['username'] ?? 'username', $credentials['apiKey'] ?? 'apiKey'), !empty($credentials['accountSid']) ? $credentials['accountSid'] : 'accountSid',
'telesign' => new Telesign($credentials['customerId'] ?? 'customerId', $credentials['apiKey'] ?? 'apiKey'), !empty($credentials['authToken']) ? $credentials['authToken'] : 'authToken',
'msg91' => new Msg91($credentials['senderId'] ?? 'senderId', $credentials['authKey'] ?? 'authKey', $credentials['templateId'] ?? 'templateId'), null,
'vonage' => new Vonage($credentials['apiKey'] ?? 'apiKey', $credentials['apiSecret'] ?? 'apiSecret'), !empty($credentials['messagingServiceSid']) ? $credentials['messagingServiceSid'] : null
),
'textmagic' => new TextMagic(
!empty($credentials['username']) ? $credentials['username'] : 'username',
!empty($credentials['apiKey']) ? $credentials['apiKey'] : 'apiKey'
),
'telesign' => new Telesign(
!empty($credentials['customerId']) ? $credentials['customerId'] : 'customerId',
!empty($credentials['apiKey']) ? $credentials['apiKey'] : 'apiKey'
),
'msg91' => new Msg91(
!empty($credentials['senderId']) ? $credentials['senderId'] : 'senderId',
!empty($credentials['authKey']) ? $credentials['authKey'] : 'authKey',
!empty($credentials['templateId']) ? $credentials['templateId'] : 'templateId'
),
'vonage' => new Vonage(
!empty($credentials['apiKey']) ? $credentials['apiKey'] : 'apiKey',
!empty($credentials['apiSecret']) ? $credentials['apiSecret'] : 'apiSecret'
),
default => null default => null
}; };
} }
@ -521,24 +539,25 @@ class Messaging extends Action
{ {
$credentials = $provider->getAttribute('credentials', []); $credentials = $provider->getAttribute('credentials', []);
$options = $provider->getAttribute('options', []); $options = $provider->getAttribute('options', []);
$apiKey = !empty($credentials['apiKey']) ? $credentials['apiKey'] : 'apiKey';
return match ($provider->getAttribute('provider')) { return match ($provider->getAttribute('provider')) {
'mock' => new Mock('username', 'password'), 'mock' => new Mock('username', 'password'),
'smtp' => new SMTP( 'smtp' => new SMTP(
$credentials['host'] ?? 'host', !empty($credentials['host']) ? $credentials['host'] : 'host',
$credentials['port'] ?? 25, !empty($credentials['port']) ? $credentials['port'] : 25,
$credentials['username'] ?? 'username', !empty($credentials['username']) ? $credentials['username'] : 'username',
$credentials['password'] ?? 'password', !empty($credentials['password']) ? $credentials['password'] : 'password',
$options['encryption'] ?? 'encryption', !empty($options['encryption']) ? $options['encryption'] : 'encryption',
$options['autoTLS'] ?? false, !empty($options['autoTLS']) ? $options['autoTLS'] : false,
$options['mailer'] ?? 'mailer', !empty($options['mailer']) ? $options['mailer'] : 'mailer',
), ),
'mailgun' => new Mailgun( 'mailgun' => new Mailgun(
$credentials['apiKey'] ?? 'apiKey', $apiKey,
$credentials['domain'] ?? 'domain', !empty($credentials['domain']) ? $credentials['domain'] : 'domain',
$credentials['isEuRegion'] ?? false !empty($credentials['isEuRegion']) ?? false
), ),
'sendgrid' => new Sendgrid($credentials['apiKey']), 'sendgrid' => new Sendgrid($apiKey),
default => null default => null
}; };
} }