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')));
|
||||
|
||||
$userId = $user->getId();
|
||||
|
||||
$subscriber = new Document([
|
||||
'$id' => $subscriberId,
|
||||
'$permissions' => [
|
||||
Permission::read(Role::user($user->getId())),
|
||||
Permission::delete(Role::user($user->getId())),
|
||||
Permission::read(Role::user($userId)),
|
||||
Permission::delete(Role::user($userId)),
|
||||
],
|
||||
'topicId' => $topicId,
|
||||
'topicInternalId' => $topic->getInternalId(),
|
||||
'targetId' => $targetId,
|
||||
'targetInternalId' => $target->getInternalId(),
|
||||
'userId' => $user->getId(),
|
||||
'userId' => $userId,
|
||||
'userInternalId' => $user->getInternalId(),
|
||||
'providerType' => $target->getAttribute('providerType'),
|
||||
'search' => "{$target->getAttribute('providerType')} "
|
||||
'search' => implode(' ', [
|
||||
$subscriberId,
|
||||
$targetId,
|
||||
$userId,
|
||||
$target->getAttribute('providerType'),
|
||||
]),
|
||||
]);
|
||||
|
||||
try {
|
||||
|
|
|
@ -419,6 +419,12 @@ trait MessagingBase
|
|||
*/
|
||||
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([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
|
@ -427,11 +433,41 @@ trait MessagingBase
|
|||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals(1, $response['body']['total']);
|
||||
$this->assertEquals($data['userId'], $response['body']['subscribers'][0]['target']['userId']);
|
||||
$this->assertEquals($data['providerType'], $response['body']['subscribers'][0]['target']['providerType']);
|
||||
$this->assertEquals($data['identifier'], $response['body']['subscribers'][0]['target']['identifier']);
|
||||
$this->assertEquals($userId, $response['body']['subscribers'][0]['target']['userId']);
|
||||
$this->assertEquals($providerType, $response['body']['subscribers'][0]['target']['providerType']);
|
||||
$this->assertEquals($identifier, $response['body']['subscribers'][0]['target']['identifier']);
|
||||
$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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue