Merge pull request #8742 from appwrite/messaging-adapter-default-values

Messaging adapter default values
This commit is contained in:
Christy Jacob 2024-10-01 23:54:38 +04:00 committed by GitHub
commit 5ec88389d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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
};
}