Merge branch '1.5.x' of https://github.com/appwrite/appwrite into 1.5.x
This commit is contained in:
commit
c6c8e7a092
2 changed files with 31 additions and 16 deletions
|
@ -1204,6 +1204,7 @@ App::patch('/v1/messaging/providers/smtp/:providerId')
|
|||
->param('password', '', new Text(0), 'Authentication password.', true)
|
||||
->param('encryption', '', new WhiteList(['none', 'ssl', 'tls']), 'Encryption type. Can be \'ssl\' or \'tls\'', true)
|
||||
->param('autoTLS', null, new Boolean(), 'Enable SMTP AutoTLS feature.', true)
|
||||
->param('mailer', '', new Text(0), 'The value to use for the X-Mailer header.', true)
|
||||
->param('fromName', '', new Text(128), 'Sender Name.', true)
|
||||
->param('fromEmail', '', new Email(), 'Sender email address.', true)
|
||||
->param('replyToName', '', new Text(128), 'Name set in the Reply To field for the mail. Default value is Sender Name.', true)
|
||||
|
@ -1212,16 +1213,14 @@ App::patch('/v1/messaging/providers/smtp/:providerId')
|
|||
->inject('queueForEvents')
|
||||
->inject('dbForProject')
|
||||
->inject('response')
|
||||
->action(function (string $providerId, string $name, string $host, ?int $port, string $username, string $password, string $encryption, ?bool $autoTLS, string $fromName, string $fromEmail, string $replyToName, string $replyToEmail, ?bool $enabled, Event $queueForEvents, Database $dbForProject, Response $response) {
|
||||
->action(function (string $providerId, string $name, string $host, ?int $port, string $username, string $password, string $encryption, ?bool $autoTLS, string $mailer, string $fromName, string $fromEmail, string $replyToName, string $replyToEmail, ?bool $enabled, Event $queueForEvents, Database $dbForProject, Response $response) {
|
||||
$provider = $dbForProject->getDocument('providers', $providerId);
|
||||
|
||||
if ($provider->isEmpty()) {
|
||||
throw new Exception(Exception::PROVIDER_NOT_FOUND);
|
||||
}
|
||||
|
||||
$providerAttr = $provider->getAttribute('provider');
|
||||
|
||||
if ($providerAttr !== 'smtp') {
|
||||
if ($provider->getAttribute('provider') !== 'smtp') {
|
||||
throw new Exception(Exception::PROVIDER_INCORRECT_TYPE);
|
||||
}
|
||||
|
||||
|
@ -1231,6 +1230,18 @@ App::patch('/v1/messaging/providers/smtp/:providerId')
|
|||
|
||||
$options = $provider->getAttribute('options');
|
||||
|
||||
if (!empty($encryption)) {
|
||||
$options['encryption'] = $encryption === 'none' ? '' : $encryption;
|
||||
}
|
||||
|
||||
if (!\is_null($autoTLS)) {
|
||||
$options['autoTLS'] = $autoTLS;
|
||||
}
|
||||
|
||||
if (!empty($mailer)) {
|
||||
$options['mailer'] = $mailer;
|
||||
}
|
||||
|
||||
if (!empty($fromName)) {
|
||||
$options['fromName'] = $fromName;
|
||||
}
|
||||
|
@ -1267,14 +1278,6 @@ App::patch('/v1/messaging/providers/smtp/:providerId')
|
|||
$credentials['password'] = $password;
|
||||
}
|
||||
|
||||
if (!empty($encryption)) {
|
||||
$credentials['encryption'] = $encryption === 'none' ? '' : $encryption;
|
||||
}
|
||||
|
||||
if (!\is_null($autoTLS)) {
|
||||
$credentials['autoTLS'] = $autoTLS;
|
||||
}
|
||||
|
||||
$provider->setAttribute('credentials', $credentials);
|
||||
|
||||
if (!\is_null($enabled)) {
|
||||
|
|
|
@ -178,14 +178,25 @@ trait MessagingBase
|
|||
],
|
||||
];
|
||||
|
||||
foreach (\array_keys($providersParams) as $index => $key) {
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/messaging/providers/' . $key . '/' . $providers[$index]['$id'], [
|
||||
foreach (\array_keys($providersParams) as $index => $name) {
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/messaging/providers/' . $name . '/' . $providers[$index]['$id'], [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey'],
|
||||
], $providersParams[$key]);
|
||||
], $providersParams[$name]);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals($providersParams[$key]['name'], $response['body']['name']);
|
||||
$this->assertEquals($providersParams[$name]['name'], $response['body']['name']);
|
||||
|
||||
if ($name === 'smtp') {
|
||||
$this->assertArrayHasKey('encryption', $response['body']['options']);
|
||||
$this->assertArrayHasKey('autoTLS', $response['body']['options']);
|
||||
$this->assertArrayHasKey('mailer', $response['body']['options']);
|
||||
$this->assertArrayNotHasKey('encryption', $response['body']['credentials']);
|
||||
$this->assertArrayNotHasKey('autoTLS', $response['body']['credentials']);
|
||||
$this->assertArrayNotHasKey('mailer', $response['body']['credentials']);
|
||||
}
|
||||
|
||||
$providers[$index] = $response['body'];
|
||||
}
|
||||
|
||||
|
@ -200,6 +211,7 @@ trait MessagingBase
|
|||
'isEuRegion' => true,
|
||||
'enabled' => false,
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('Mailgun2', $response['body']['name']);
|
||||
$this->assertEquals(false, $response['body']['enabled']);
|
||||
|
|
Loading…
Reference in a new issue