diff --git a/app/config/variables.php b/app/config/variables.php index ffc3cb998d..13bde2d04f 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -408,7 +408,7 @@ return [ ], [ 'name' => '_APP_SMTP_SECURE', - 'description' => 'SMTP secure connection protocol. Empty by default, change to \'tls\' if running on a secure connection.', + 'description' => 'SMTP secure connection protocol. Empty by default, change to \'tls\' or \'ssl\' if running on a secure connection.', 'introduction' => '', 'default' => '', 'required' => false, diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 17b2984471..b59ab40e0d 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -2526,7 +2526,7 @@ App::post('/v1/account/recovery') $queueForMails ->setRecipient($profile->getAttribute('email', '')) - ->setName($profile->getAttribute('name')) + ->setName($profile->getAttribute('name', '')) ->setBody($body) ->setVariables($emailVariables) ->setSubject($subject) diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 5fdb2edb2f..ef30d062f9 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -2997,6 +2997,33 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents') $processDocument($collection, $document); } + $select = \array_reduce($queries, function ($result, $query) { + return $result || ($query->getMethod() === Query::TYPE_SELECT); + }, false); + + // Check if the SELECT query includes $databaseId and $collectionId + $hasDatabaseId = false; + $hasCollectionId = false; + if ($select) { + $hasDatabaseId = \array_reduce($queries, function ($result, $query) { + return $result || ($query->getMethod() === Query::TYPE_SELECT && \in_array('$databaseId', $query->getValues())); + }, false); + $hasCollectionId = \array_reduce($queries, function ($result, $query) { + return $result || ($query->getMethod() === Query::TYPE_SELECT && \in_array('$collectionId', $query->getValues())); + }, false); + } + + if ($select) { + foreach ($documents as $document) { + if (!$hasDatabaseId) { + $document->removeAttribute('$databaseId'); + } + if (!$hasCollectionId) { + $document->removeAttribute('$collectionId'); + } + } + } + $response->dynamic(new Document([ 'total' => $total, 'documents' => $documents, diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 8314a21f30..9e08c3774a 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -1446,7 +1446,7 @@ App::patch('/v1/projects/:projectId/smtp') ->param('port', 587, new Integer(), 'SMTP server port', true) ->param('username', '', new Text(0, 0), 'SMTP server username', true) ->param('password', '', new Text(0, 0), 'SMTP server password', true) - ->param('secure', '', new WhiteList(['tls'], true), 'Does SMTP server use secure connection', true) + ->param('secure', '', new WhiteList(['tls', 'ssl'], true), 'Does SMTP server use secure connection', true) ->inject('response') ->inject('dbForConsole') ->action(function (string $projectId, bool $enabled, string $senderName, string $senderEmail, string $replyTo, string $host, int $port, string $username, string $password, string $secure, Response $response, Database $dbForConsole) { diff --git a/tests/e2e/Services/Databases/DatabasesBase.php b/tests/e2e/Services/Databases/DatabasesBase.php index 4d5eb4b803..dbb6d795c6 100644 --- a/tests/e2e/Services/Databases/DatabasesBase.php +++ b/tests/e2e/Services/Databases/DatabasesBase.php @@ -4068,6 +4068,8 @@ trait DatabasesBase $this->assertEquals(2, count($response['body']['documents'])); $this->assertEquals(null, $response['body']['documents'][0]['fullName']); $this->assertArrayNotHasKey("libraries", $response['body']['documents'][0]); + $this->assertArrayNotHasKey('$databaseId', $response['body']['documents'][0]); + $this->assertArrayNotHasKey('$collectionId', $response['body']['documents'][0]); } /** @@ -4087,6 +4089,8 @@ trait DatabasesBase $this->assertEquals(200, $response['headers']['status-code']); $this->assertArrayNotHasKey('libraries', $response['body']['documents'][0]); + $this->assertArrayNotHasKey('$databaseId', $response['body']['documents'][0]); + $this->assertArrayNotHasKey('$collectionId', $response['body']['documents'][0]); $response = $this->client->call(Client::METHOD_GET, '/databases/' . $data['databaseId'] . '/collections/' . $data['personCollection'] . '/documents', array_merge([ 'content-type' => 'application/json', @@ -4099,6 +4103,8 @@ trait DatabasesBase $document = $response['body']['documents'][0]; $this->assertEquals(200, $response['headers']['status-code']); $this->assertArrayHasKey('libraries', $document); + $this->assertArrayNotHasKey('$databaseId', $document); + $this->assertArrayNotHasKey('$collectionId', $document); $response = $this->client->call(Client::METHOD_GET, '/databases/' . $data['databaseId'] . '/collections/' . $data['personCollection'] . '/documents/' . $document['$id'], array_merge([ 'content-type' => 'application/json',