Skip to content

Commit 637c3e0

Browse files
merged "master" into "feature/snooze_message_reminder"
2 parents 496839b + 79aa72a commit 637c3e0

File tree

3 files changed

+71
-11
lines changed

3 files changed

+71
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,6 @@ All notable changes to this project will be documented in this file. See [standa
2626

2727
* **release:** 3.10.0 ([#151](https://github.com/GetStream/stream-chat-ruby/issues/151)) ([ac11fc1](https://github.com/GetStream/stream-chat-ruby/commit/ac11fc122ec97ffd1b2bce820efe55925e96277f))
2828

29-
## [Unreleased]
30-
31-
### Features
32-
33-
* Added support for message reminders:
34-
* `create_reminder`: Create a reminder for a message
35-
* `update_reminder`: Update an existing reminder
36-
* `delete_reminder`: Delete a reminder
37-
* `query_reminders`: Query reminders with filtering options
38-
3929
## [3.10.0](https://github.com/GetStream/stream-chat-ruby/compare/v3.9.0...v3.10.0) (2025-02-24)
4030

4131
## [3.9.0](https://github.com/GetStream/stream-chat-ruby/compare/v3.7.0...v3.9.0) (2025-02-11)
@@ -360,4 +350,4 @@ before continuing with v3.0.0 of this library.
360350
- Added `client.search`
361351
- Added `client.update_users_partial`
362352
- Added `client.update_user_partial`
363-
- Added `client.reactivate_user`
353+
- Added `client.reactivate_user`

lib/stream-chat/client.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,16 @@ def query_threads(filter, sort: nil, **options)
940940
post('threads', data: params)
941941
end
942942

943+
sig { params(filter: StringKeyHash, sort: T.nilable(T::Hash[String, Integer]), options: T.untyped).returns(StreamChat::StreamResponse) }
944+
def query_threads(filter, sort: nil, **options)
945+
params = {}.merge(options).merge({
946+
filter: filter,
947+
sort: StreamChat.get_sort_fields(sort)
948+
})
949+
950+
post('threads', data: params)
951+
end
952+
943953
# Creates a reminder for a message.
944954
# @param message_id [String] The ID of the message to create a reminder for
945955
# @param user_id [String] The ID of the user creating the reminder

spec/client_spec.rb

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,66 @@ def loop_times(times)
10211021
end
10221022
end
10231023

1024+
describe '#query_threads' do
1025+
before(:all) do
1026+
# Create a dedicated random user for this block
1027+
@thread_test_user = { id: SecureRandom.uuid }
1028+
@client.upsert_users([@thread_test_user])
1029+
1030+
# Create a channel and send a message to create a thread
1031+
@thread_channel = @client.channel('messaging', channel_id: SecureRandom.uuid, data: { test: true })
1032+
@thread_channel.create(@thread_test_user[:id])
1033+
1034+
# Send a message to create a thread
1035+
@thread_message = @thread_channel.send_message({ text: 'Thread parent message' }, @thread_test_user[:id])
1036+
1037+
# Send a reply to create a thread
1038+
@thread_channel.send_message({ text: 'Thread reply', parent_id: @thread_message['message']['id'] }, @thread_test_user[:id])
1039+
end
1040+
1041+
after(:all) do
1042+
@thread_channel.delete
1043+
@client.delete_user(@thread_test_user[:id])
1044+
end
1045+
1046+
it 'queries threads with filter' do
1047+
filter = {
1048+
'created_by_user_id' => { '$eq' => @thread_test_user[:id] }
1049+
}
1050+
1051+
response = @client.query_threads(filter, user_id: @thread_test_user[:id])
1052+
1053+
expect(response).to include 'threads'
1054+
expect(response['threads'].length).to be >= 1
1055+
end
1056+
1057+
it 'queries threads with sort' do
1058+
sort = {
1059+
'created_at' => -1
1060+
}
1061+
1062+
response = @client.query_threads({}, sort: sort, user_id: @thread_test_user[:id])
1063+
1064+
expect(response).to include 'threads'
1065+
expect(response['threads'].length).to be >= 1
1066+
end
1067+
1068+
it 'queries threads with both filter and sort' do
1069+
filter = {
1070+
'created_by_user_id' => { '$eq' => @thread_test_user[:id] }
1071+
}
1072+
1073+
sort = {
1074+
'created_at' => -1
1075+
}
1076+
1077+
response = @client.query_threads(filter, sort: sort, user_id: @thread_test_user[:id])
1078+
1079+
expect(response).to include 'threads'
1080+
expect(response['threads'].length).to be >= 1
1081+
end
1082+
end
1083+
10241084
describe 'reminders' do
10251085
before do
10261086
@client = StreamChat::Client.from_env

0 commit comments

Comments
 (0)