Skip to content

Commit

Permalink
feat: add truncate options
Browse files Browse the repository at this point in the history
Part of CHAT-2622
  • Loading branch information
peterdeme committed Dec 7, 2021
1 parent 4889972 commit 558d428
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/GetStream/StreamChat/Channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,12 @@ public function delete()
}

/**
* @param array $options
* @return mixed
* @throws StreamException
*/
public function truncate()
public function truncate($options=null)
{
// need to post 'some' json?
$options = (object)[];
return $this->client->post($this->getUrl() . "/truncate", $options);
}

Expand Down
11 changes: 11 additions & 0 deletions tests/integration/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,17 @@ public function testChannelTruncate()
$this->assertTrue(array_key_exists("channel", $response));
}

public function testChannelTruncateWithOptions()
{
$channel = $this->getChannel();
$truncateOpts = [
"message" => ["text" => "Truncating channel", "user_id": $this->getUser()["id"]],
"skip_push" => true
];
$response = $channel->truncate($truncateOpts);
$this->assertTrue(array_key_exists("channel", $response));
}

public function testChannelAddMembers()
{
$user = $this->getUser();
Expand Down

0 comments on commit 558d428

Please sign in to comment.