Skip to content

Commit fb09ec0

Browse files
gumuzAnatoly Rugalev
andauthored
[CHAT-2191] Async delete_users (#62)
Co-authored-by: Anatoly Rugalev <[email protected]>
1 parent e680c7b commit fb09ec0

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

lib/GetStream/StreamChat/Channel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ public function rejectInvite($options=null)
432432
/**
433433
* @param string $url
434434
* @param string $name
435-
* @param string $user
435+
* @param string|array $user
436436
* @param string $contentType
437437
* @return mixed
438438
* @throws StreamException
@@ -445,7 +445,7 @@ public function sendFile($url, $name, $user, $contentType=null)
445445
/**
446446
* @param string $url
447447
* @param string $name
448-
* @param string $user
448+
* @param string|array $user
449449
* @param string $contentType
450450
* @return mixed
451451
* @throws StreamException

lib/GetStream/StreamChat/Client.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,21 @@ public function deleteUser($userId, $options=null)
378378
return $this->delete("users/" . $userId, $options);
379379
}
380380

381+
/**
382+
* @param array $userIds
383+
* @param array $options
384+
* @return mixed
385+
* @throws StreamException
386+
*/
387+
public function deleteUsers($userIds, $options=null)
388+
{
389+
if ($options === null) {
390+
$options = (object)[];
391+
}
392+
$options["user_ids"] = $userIds;
393+
return $this->post("users/delete", $options);
394+
}
395+
381396
/**
382397
* @param string $userId
383398
* @param array $options

tests/integration/IntegrationTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,22 @@ public function testDeleteUser()
102102
$this->assertSame($user["id"], $response["user"]["id"]);
103103
}
104104

105+
public function testDeleteUsers()
106+
{
107+
$user = $this->getUser();
108+
$response = $this->client->deleteUsers([$user["id"]], ["user" => "hard"]);
109+
$this->assertTrue(array_key_exists("task_id", $response));
110+
$taskId = $response["task_id"];
111+
for ($i=0;$i<10;$i++) {
112+
$response = $this->client->getTask($taskId);
113+
if ($response["status"] == "completed") {
114+
return;
115+
}
116+
sleep(1);
117+
}
118+
$this->assertSame($response["status"], "completed");
119+
}
120+
105121
public function testDeactivateUser()
106122
{
107123
$user = $this->getUser();

0 commit comments

Comments
 (0)