Skip to content

Commit 69d60f4

Browse files
author
Rafael Marinho
committed
feat[cha-1225]: support delivery receipts
1 parent bae463b commit 69d60f4

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

‎lib/stream-chat/client.rb‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,17 @@ def query_reminders(user_id, filter_conditions = {}, sort: nil, **options)
10651065
post('reminders/query', data: params)
10661066
end
10671067

1068+
# Send the mark delivered event for this user, only works if the `delivery_receipts` setting is enabled
1069+
#
1070+
# @param [StringKeyHash, nil] data The delivery confirmation data
1071+
# @return [StreamChat::StreamResponse] API response
1072+
sig { params(data: T.nilable(StringKeyHash)).returns(StreamChat::StreamResponse) }
1073+
def mark_channels_delivered(data = nil)
1074+
# Note: In the Ruby SDK, we don't have access to user privacy settings from the client
1075+
# The server will handle the delivery_receipts check and return appropriate response
1076+
post('channels/delivered', data: data || {})
1077+
end
1078+
10681079
private
10691080

10701081
sig { returns(T::Hash[String, String]) }

‎spec/client_spec.rb‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,4 +1435,38 @@ def loop_times(times)
14351435
expect(response['active_live_locations'].length).to be >= 1
14361436
end
14371437
end
1438+
1439+
describe '#mark_channels_delivered' do
1440+
it 'should mark channels as delivered' do
1441+
# Create some test messages first
1442+
message1 = @channel.send_message({ text: 'Test message 1' }, @frodo)
1443+
message2 = @channel.send_message({ text: 'Test message 2' }, @sam)
1444+
1445+
# Create delivery confirmation data
1446+
delivery_data = {
1447+
latest_delivered_messages: [
1448+
{
1449+
cid: @channel.cid,
1450+
id: message1['message']['id']
1451+
},
1452+
{
1453+
cid: @channel.cid,
1454+
id: message2['message']['id']
1455+
}
1456+
],
1457+
user_id: @gandalf
1458+
}
1459+
1460+
# Call the method
1461+
response = @client.mark_channels_delivered(delivery_data)
1462+
1463+
# The response should be successful (status 200)
1464+
expect(response.status_code).to eq(200)
1465+
end
1466+
1467+
it 'should handle empty data' do
1468+
response = @client.mark_channels_delivered
1469+
expect(response.status_code).to eq(200)
1470+
end
1471+
end
14381472
end

0 commit comments

Comments
 (0)