1
0
Fork 0
mirror of synced 2024-09-29 08:51:28 +13:00

Merge branch '1.5.x' of github.com:appwrite/appwrite into twoWayKey-2

This commit is contained in:
fogelito 2024-02-14 16:53:58 +02:00
commit 84acf990ec
4 changed files with 33 additions and 18 deletions

View file

@ -12,7 +12,7 @@ RUN composer install --ignore-platform-reqs --optimize-autoloader \
--no-plugins --no-scripts --prefer-dist \
`if [ "$TESTING" != "true" ]; then echo "--no-dev"; fi`
FROM --platform=$BUILDPLATFORM node:16.14.2-alpine3.15 as node
FROM --platform=$BUILDPLATFORM node:20.11.0-alpine3.19 as node
COPY app/console /usr/local/src/console

@ -1 +1 @@
Subproject commit 8c8f0b7ccb0d98e9561f03a6486de1e59f3b3b9d
Subproject commit 74f09e341a9e8b10f66e1cfc5d990158b2f952b6

View file

@ -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)) {

View file

@ -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']);