Skip to content

Commit

Permalink
feat: add truncate options (#67)
Browse files Browse the repository at this point in the history
Part of CHAT-2622

Co-authored-by: peterdeme <peter.deme@getstream.io>
  • Loading branch information
peterdeme and peterdeme authored Dec 7, 2021
1 parent 4889972 commit d45ad02
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ composer.lock
.envrc
.php_cs.cache
.idea
.vscode
8 changes: 5 additions & 3 deletions lib/GetStream/StreamChat/Channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,15 @@ 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)[];
if ($options === null) {
$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 d45ad02

Please sign in to comment.