Update the content in the subscriber's search attribute
This commit is contained in:
parent
5827c52372
commit
96de1617ed
2 changed files with 50 additions and 7 deletions
|
@ -1991,20 +1991,27 @@ App::post('/v1/messaging/topics/:topicId/subscribers')
|
||||||
|
|
||||||
$user = Authorization::skip(fn () => $dbForProject->getDocument('users', $target->getAttribute('userId')));
|
$user = Authorization::skip(fn () => $dbForProject->getDocument('users', $target->getAttribute('userId')));
|
||||||
|
|
||||||
|
$userId = $user->getId();
|
||||||
|
|
||||||
$subscriber = new Document([
|
$subscriber = new Document([
|
||||||
'$id' => $subscriberId,
|
'$id' => $subscriberId,
|
||||||
'$permissions' => [
|
'$permissions' => [
|
||||||
Permission::read(Role::user($user->getId())),
|
Permission::read(Role::user($userId)),
|
||||||
Permission::delete(Role::user($user->getId())),
|
Permission::delete(Role::user($userId)),
|
||||||
],
|
],
|
||||||
'topicId' => $topicId,
|
'topicId' => $topicId,
|
||||||
'topicInternalId' => $topic->getInternalId(),
|
'topicInternalId' => $topic->getInternalId(),
|
||||||
'targetId' => $targetId,
|
'targetId' => $targetId,
|
||||||
'targetInternalId' => $target->getInternalId(),
|
'targetInternalId' => $target->getInternalId(),
|
||||||
'userId' => $user->getId(),
|
'userId' => $userId,
|
||||||
'userInternalId' => $user->getInternalId(),
|
'userInternalId' => $user->getInternalId(),
|
||||||
'providerType' => $target->getAttribute('providerType'),
|
'providerType' => $target->getAttribute('providerType'),
|
||||||
'search' => "{$target->getAttribute('providerType')} "
|
'search' => implode(' ', [
|
||||||
|
$subscriberId,
|
||||||
|
$targetId,
|
||||||
|
$userId,
|
||||||
|
$target->getAttribute('providerType'),
|
||||||
|
]),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -419,6 +419,12 @@ trait MessagingBase
|
||||||
*/
|
*/
|
||||||
public function testListSubscribers(array $data)
|
public function testListSubscribers(array $data)
|
||||||
{
|
{
|
||||||
|
$subscriberId = $data['subscriberId'];
|
||||||
|
$targetId = $data['targetId'];
|
||||||
|
$userId = $data['userId'];
|
||||||
|
$providerType = $data['providerType'];
|
||||||
|
$identifier = $data['identifier'];
|
||||||
|
|
||||||
$response = $this->client->call(Client::METHOD_GET, '/messaging/topics/' . $data['topicId'] . '/subscribers', \array_merge([
|
$response = $this->client->call(Client::METHOD_GET, '/messaging/topics/' . $data['topicId'] . '/subscribers', \array_merge([
|
||||||
'content-type' => 'application/json',
|
'content-type' => 'application/json',
|
||||||
'x-appwrite-project' => $this->getProject()['$id'],
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
|
@ -427,11 +433,41 @@ trait MessagingBase
|
||||||
|
|
||||||
$this->assertEquals(200, $response['headers']['status-code']);
|
$this->assertEquals(200, $response['headers']['status-code']);
|
||||||
$this->assertEquals(1, $response['body']['total']);
|
$this->assertEquals(1, $response['body']['total']);
|
||||||
$this->assertEquals($data['userId'], $response['body']['subscribers'][0]['target']['userId']);
|
$this->assertEquals($userId, $response['body']['subscribers'][0]['target']['userId']);
|
||||||
$this->assertEquals($data['providerType'], $response['body']['subscribers'][0]['target']['providerType']);
|
$this->assertEquals($providerType, $response['body']['subscribers'][0]['target']['providerType']);
|
||||||
$this->assertEquals($data['identifier'], $response['body']['subscribers'][0]['target']['identifier']);
|
$this->assertEquals($identifier, $response['body']['subscribers'][0]['target']['identifier']);
|
||||||
$this->assertEquals(\count($response['body']['subscribers']), $response['body']['total']);
|
$this->assertEquals(\count($response['body']['subscribers']), $response['body']['total']);
|
||||||
|
|
||||||
|
$response = $this->client->call(Client::METHOD_GET, '/messaging/topics/' . $data['topicId'] . '/subscribers', \array_merge([
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
|
'x-appwrite-key' => $this->getProject()['apiKey'],
|
||||||
|
]), [
|
||||||
|
'search' => 'DOES_NOT_EXIST',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertEquals(200, $response['headers']['status-code']);
|
||||||
|
$this->assertEquals(0, $response['body']['total']);
|
||||||
|
|
||||||
|
$searches = [
|
||||||
|
$subscriberId,
|
||||||
|
$targetId,
|
||||||
|
$userId,
|
||||||
|
$providerType
|
||||||
|
];
|
||||||
|
foreach ($searches as $search) {
|
||||||
|
$response = $this->client->call(Client::METHOD_GET, '/messaging/topics/' . $data['topicId'] . '/subscribers', \array_merge([
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
|
'x-appwrite-key' => $this->getProject()['apiKey'],
|
||||||
|
]), [
|
||||||
|
'search' => $search,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertEquals(200, $response['headers']['status-code']);
|
||||||
|
$this->assertEquals(1, $response['body']['total']);
|
||||||
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue