Skip to content

Commit

Permalink
feat: add options to send message (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
ferhatelmas authored Dec 22, 2022
1 parent a4e4893 commit a433144
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions lib/GetStream/StreamChat/Channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,16 @@ private static function addUser(array $payload, string $userId)
* @link https://getstream.io/chat/docs/php/send_message/?language=php
* @throws StreamException
*/
public function sendMessage(array $message, string $userId, string $parentId = null): StreamResponse
public function sendMessage(array $message, string $userId, string $parentId = null, $options = null): StreamResponse
{
if ($options === null) {
$options = [];
}
if ($parentId !== null) {
$message['parent_id'] = $parentId;
}
$payload = [
"message" => Channel::addUser($message, $userId)
];
return $this->client->post($this->getUrl() . "/message", $payload);
$options["message"] = Channel::addUser($message, $userId);
return $this->client->post($this->getUrl() . "/message", $options);
}

/** Returns multiple messages.
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ public function testUpdateMessage()
{
$msgId = $this->generateGuid();
$msg = ["id" => $msgId, "text" => "hello world"];
$response = $this->channel->sendMessage($msg, $this->user1["id"]);
$response = $this->channel->sendMessage($msg, $this->user1["id"], null, ["skip_push" => true]);
$this->assertSame("hello world", $response["message"]["text"]);
$msg = [
"id" => $msgId,
Expand Down

0 comments on commit a433144

Please sign in to comment.