Skip to content

Commit bc44b0d

Browse files
author
Rafael Marinho
committed
[CHA-1226]: support delivery receipts
1 parent e65ed3b commit bc44b0d

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

lib/GetStream/StreamChat/Channel.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,38 @@ public function markRead(string $userId, ?array $data = null): StreamResponse
354354
return $this->client->post($this->getUrl() . "/read", $payload);
355355
}
356356

357+
/** Send the mark delivered event for this user, only works if
358+
* the `delivery_receipts` setting is enabled.
359+
*
360+
* @param string $userId The user ID sending the delivery receipt
361+
* @param array|null $data Optional data for the mark delivered request. Expected structure:
362+
* [
363+
* 'channel_delivered_message' => [
364+
* 'channel_id' => 'message_id'
365+
* ],
366+
* 'client_id' => 'optional_client_id',
367+
* 'connection_id' => 'optional_connection_id',
368+
* 'user' => [/* user data */],
369+
* 'user_id' => 'optional_user_id'
370+
* ]
371+
* @return StreamResponse
372+
* @throws StreamException
373+
* @link https://getstream.io/chat/docs/php/send_message/?language=php
374+
*/
375+
public function markDelivered(string $userId, ?array $data = null): StreamResponse
376+
{
377+
if ($data === null) {
378+
$data = [];
379+
}
380+
381+
// Note: In PHP, we don't have access to the current user's privacy settings
382+
// through the client like in JavaScript. The delivery receipts check should
383+
// be handled on the client side before calling this method.
384+
385+
$payload = Channel::addUser($data, $userId);
386+
return $this->client->post("channels/delivered", $payload);
387+
}
388+
357389
/** List the message replies for a parent message.
358390
* @link https://getstream.io/chat/docs/php/threads/?language=php
359391
* @throws StreamException

0 commit comments

Comments
 (0)