Merge branch 'feat-mailgun-provider' into feat-topics-controller
This commit is contained in:
commit
9567bf3943
3 changed files with 14 additions and 58 deletions
|
@ -1673,7 +1673,7 @@ $commonCollections = [
|
|||
'required' => false,
|
||||
'default' => null,
|
||||
'array' => true,
|
||||
'filters' => ['subQueryTargets'],
|
||||
'filters' => ['subQueryTopicTargets'],
|
||||
]
|
||||
],
|
||||
'indexes' => [
|
||||
|
@ -1861,17 +1861,6 @@ $commonCollections = [
|
|||
'array' => false,
|
||||
'filters' => [],
|
||||
],
|
||||
[
|
||||
'$id' => ID::custom('topics'),
|
||||
'type' => Database::VAR_STRING,
|
||||
'format' => '',
|
||||
'size' => 16384,
|
||||
'signed' => true,
|
||||
'required' => false,
|
||||
'default' => null,
|
||||
'array' => true,
|
||||
'filters' => ['subQueryTopics'],
|
||||
]
|
||||
],
|
||||
'indexes' => [
|
||||
[
|
||||
|
@ -1901,14 +1890,7 @@ $commonCollections = [
|
|||
'attributes' => ['providerInternalId'],
|
||||
'lengths' => [],
|
||||
'orders' => [],
|
||||
],
|
||||
[
|
||||
'$id' => ID::custom('_key_providerType'),
|
||||
'type' => Database::INDEX_KEY,
|
||||
'attributes' => ['providerType'],
|
||||
'lengths' => [],
|
||||
'orders' => [],
|
||||
],
|
||||
]
|
||||
],
|
||||
],
|
||||
];
|
||||
|
|
22
app/init.php
22
app/init.php
|
@ -555,29 +555,9 @@ Database::addFilter(
|
|||
}
|
||||
);
|
||||
|
||||
Database::addFilter(
|
||||
'subQueryTopics',
|
||||
function (mixed $value) {
|
||||
return null;
|
||||
},
|
||||
function (mixed $value, Document $document, Database $database) {
|
||||
$topicIds = Authorization::skip(fn () => \array_map(
|
||||
fn ($document) => $document->getAttribute('topicId'),
|
||||
$database
|
||||
->find('subscribers', [
|
||||
Query::equal('targetInternalId', [$document->getInternalId()]),
|
||||
Query::limit(APP_LIMIT_SUBQUERY),
|
||||
])
|
||||
));
|
||||
if (\count($topicIds) > 0) {
|
||||
return $database->find('topics', [Query::equal('$id', $topicIds)]);
|
||||
}
|
||||
return [];
|
||||
}
|
||||
);
|
||||
|
||||
Database::addFilter(
|
||||
'subQueryTargets',
|
||||
'subQueryTopicTargets',
|
||||
function (mixed $value) {
|
||||
return null;
|
||||
},
|
||||
|
|
|
@ -1216,11 +1216,11 @@ trait UsersBase
|
|||
*/
|
||||
public function testCreateUserTarget(array $data): array
|
||||
{
|
||||
$provider = $this->client->call(Client::METHOD_POST, '/messaging/providers/sendgrid', [
|
||||
$provider = $this->client->call(Client::METHOD_POST, '/messaging/providers/sendgrid', \array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey'],
|
||||
], [
|
||||
], $this->getHeaders()), [
|
||||
'providerId' => 'unique()',
|
||||
'name' => 'Sengrid1',
|
||||
'apiKey' => 'my-apikey'
|
||||
]);
|
||||
|
@ -1228,8 +1228,7 @@ trait UsersBase
|
|||
$response = $this->client->call(Client::METHOD_POST, '/users/' . $data['userId'] . '/targets', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey'],
|
||||
]), [
|
||||
], $this->getHeaders()), [
|
||||
'targetId' => ID::unique(),
|
||||
'providerId' => $provider['body']['$id'],
|
||||
'identifier' => 'my-token',
|
||||
|
@ -1248,8 +1247,7 @@ trait UsersBase
|
|||
$response = $this->client->call(Client::METHOD_PATCH, '/users/' . $data['userId'] . '/targets/' . $data['$id'] . '/identifier', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey'],
|
||||
]), [
|
||||
], $this->getHeaders()), [
|
||||
'identifier' => 'my-updated-token',
|
||||
]);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
|
@ -1258,17 +1256,16 @@ trait UsersBase
|
|||
}
|
||||
|
||||
/**
|
||||
* @depends testGetUser
|
||||
* @depends testUpdateUserTarget
|
||||
*/
|
||||
public function testListUserTarget(array $data)
|
||||
{
|
||||
$response = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'] . '/targets', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey'],
|
||||
]));
|
||||
], $this->getHeaders()));
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals(1, $response['body']['total']);
|
||||
$this->assertEquals(1, \count($response['body']['targets']));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1279,8 +1276,7 @@ trait UsersBase
|
|||
$response = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'] . '/targets/' . $data['$id'], array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey'],
|
||||
]));
|
||||
], $this->getHeaders()));
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals($data['$id'], $response['body']['$id']);
|
||||
}
|
||||
|
@ -1293,14 +1289,12 @@ trait UsersBase
|
|||
$response = $this->client->call(Client::METHOD_DELETE, '/users/' . $data['userId'] . '/targets/' . $data['$id'], array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey'],
|
||||
]));
|
||||
], $this->getHeaders()));
|
||||
$this->assertEquals(204, $response['headers']['status-code']);
|
||||
$response = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'] . '/targets', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey'],
|
||||
]));
|
||||
], $this->getHeaders()));
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals(0, $response['body']['total']);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue