From 06e60b8b39ecadbf64910882f2f5a47e5d3d4c79 Mon Sep 17 00:00:00 2001 From: Aditya Agarwal Date: Thu, 2 Jan 2025 18:09:18 +0530 Subject: [PATCH] feat: undelete message --- lib/GetStream/StreamChat/Client.php | 10 ++++++++++ tests/integration/IntegrationTest.php | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/lib/GetStream/StreamChat/Client.php b/lib/GetStream/StreamChat/Client.php index 95f61a6..ed588d5 100644 --- a/lib/GetStream/StreamChat/Client.php +++ b/lib/GetStream/StreamChat/Client.php @@ -819,6 +819,16 @@ public function deleteMessage(string $messageId, array $options = []): StreamRes return $this->delete("messages/" . $messageId, $options); } + /** + * Undeletes a message. + * @link https://getstream.io/chat/docs/php/send_message/?language=php + * @throws StreamException + */ + public function undeleteMessage(string $messageId, string $userId): StreamResponse + { + return $this->post("messages/" . urlencode($messageId) . "/undelete", ["undeleted_by" => $userId]); + } + /** Allows you to search for users and see if they are online/offline. * 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. * @link https://getstream.io/chat/docs/php/query_users/?language=php diff --git a/tests/integration/IntegrationTest.php b/tests/integration/IntegrationTest.php index 18cac47..ee6aa20 100644 --- a/tests/integration/IntegrationTest.php +++ b/tests/integration/IntegrationTest.php @@ -563,6 +563,15 @@ public function testDeleteMessage() $this->client->deleteMessage($msgId); } + public function testUnDeleteMessage() + { + $msgId = $this->generateGuid(); + $msg = ["id" => $msgId, "text" => "helloworld"]; + $this->channel->sendMessage($msg, $this->user1["id"]); + $this->client->deleteMessage($msgId); + $this->client->undeleteMessage($msgId, $this->user1["id"]); + } + public function testManyMessages() { $msgId = $this->generateGuid();