mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Merge remote-tracking branch 'origin/main' into 1.5.x
This commit is contained in:
@@ -2994,7 +2994,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)
|
||||
|
||||
@@ -3090,6 +3090,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,
|
||||
|
||||
@@ -4532,6 +4532,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]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4551,6 +4553,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',
|
||||
@@ -4563,6 +4567,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',
|
||||
|
||||
Reference in New Issue
Block a user