Skip to content

Commit 06e60b8

Browse files
committed
feat: undelete message
1 parent 83a710f commit 06e60b8

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

lib/GetStream/StreamChat/Client.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,16 @@ public function deleteMessage(string $messageId, array $options = []): StreamRes
819819
return $this->delete("messages/" . $messageId, $options);
820820
}
821821

822+
/**
823+
* Undeletes a message.
824+
* @link https://getstream.io/chat/docs/php/send_message/?language=php
825+
* @throws StreamException
826+
*/
827+
public function undeleteMessage(string $messageId, string $userId): StreamResponse
828+
{
829+
return $this->post("messages/" . urlencode($messageId) . "/undelete", ["undeleted_by" => $userId]);
830+
}
831+
822832
/** Allows you to search for users and see if they are online/offline.
823833
* You can filter and sort on the custom fields you've set for your user, the user id, and when the user was last active.
824834
* @link https://getstream.io/chat/docs/php/query_users/?language=php

tests/integration/IntegrationTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,15 @@ public function testDeleteMessage()
563563
$this->client->deleteMessage($msgId);
564564
}
565565

566+
public function testUnDeleteMessage()
567+
{
568+
$msgId = $this->generateGuid();
569+
$msg = ["id" => $msgId, "text" => "helloworld"];
570+
$this->channel->sendMessage($msg, $this->user1["id"]);
571+
$this->client->deleteMessage($msgId);
572+
$this->client->undeleteMessage($msgId, $this->user1["id"]);
573+
}
574+
566575
public function testManyMessages()
567576
{
568577
$msgId = $this->generateGuid();

0 commit comments

Comments
 (0)