Skip to content

Commit 496839b

Browse files
merge "master" into 'feature/snooze_message_reminder'
1 parent 0af4c8e commit 496839b

File tree

11 files changed

+860
-12
lines changed

11 files changed

+860
-12
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @totalimmersion @akupila @guerinoni @JimmyPettersson85 @shaljam @vishalnarkhede
1+
* @totalimmersion @akupila @guerinoni @JimmyPettersson85 @shaljam @vishalnarkhede @nijeesh-stream

.rubocop.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,5 @@ Style/FrozenStringLiteralComment:
3535

3636
Gemspec/RequireMFA:
3737
Enabled: false
38+
Naming/PredicateMethod:
39+
Enabled: false

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,30 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
## [3.15.0](https://github.com/GetStream/stream-chat-ruby/compare/v3.14.0...v3.15.0) (2025-06-06)
6+
7+
## [3.14.0](https://github.com/GetStream/stream-chat-ruby/compare/v3.13.0...v3.14.0) (2025-04-07)
8+
9+
## [3.13.0](https://github.com/GetStream/stream-chat-ruby/compare/v3.12.0...v3.13.0) (2025-04-04)
10+
11+
12+
### Features
13+
14+
* deactivate users ([#162](https://github.com/GetStream/stream-chat-ruby/issues/162)) ([12bf4d1](https://github.com/GetStream/stream-chat-ruby/commit/12bf4d19846b5100f1886929b74c7ad05d753be4))
15+
* draft messages ([#161](https://github.com/GetStream/stream-chat-ruby/pull/161)) ([1719104](https://github.com/GetStream/stream-chat-ruby/commit/c7bccb3ad30721a20f32fd60eb13ab6d97a08208))
16+
17+
### Other
18+
19+
* added nijeesh to code owners ([#156](https://github.com/GetStream/stream-chat-ruby/issues/156)) ([7cd4e54](https://github.com/GetStream/stream-chat-ruby/commit/7cd4e5443a8f283596b8eadc873030d737cd621c))
20+
* **release:** v3.12.0 ([#157](https://github.com/GetStream/stream-chat-ruby/issues/157)) ([993b7a3](https://github.com/GetStream/stream-chat-ruby/commit/993b7a30bd2222ee328ca7a862384c7baf7d53e1))
21+
22+
## [3.11.0](https://github.com/GetStream/stream-chat-ruby/compare/v3.9.0...v3.11.0) (2025-03-21)
23+
24+
25+
### Other
26+
27+
* **release:** 3.10.0 ([#151](https://github.com/GetStream/stream-chat-ruby/issues/151)) ([ac11fc1](https://github.com/GetStream/stream-chat-ruby/commit/ac11fc122ec97ffd1b2bce820efe55925e96277f))
28+
529
## [Unreleased]
630

731
### Features

lib/stream-chat/channel.rb

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,41 @@ def delete_image(url)
360360
@client.delete("#{self.url}/image", params: { url: url })
361361
end
362362

363+
# Creates or updates a draft message for this channel.
364+
#
365+
# @param [StringKeyHash] message The draft message content
366+
# @param [String] user_id The ID of the user creating/updating the draft
367+
# @return [StreamChat::StreamResponse]
368+
sig { params(message: StringKeyHash, user_id: String).returns(StreamChat::StreamResponse) }
369+
def create_draft(message, user_id)
370+
payload = { message: add_user_id(message, user_id) }
371+
@client.post("#{url}/draft", data: payload)
372+
end
373+
374+
# Deletes a draft message for this channel.
375+
#
376+
# @param [String] user_id The ID of the user deleting the draft
377+
# @param [String] parent_id Optional parent message ID for thread drafts
378+
# @return [StreamChat::StreamResponse]
379+
sig { params(user_id: String, parent_id: T.nilable(String)).returns(StreamChat::StreamResponse) }
380+
def delete_draft(user_id, parent_id: nil)
381+
params = { user_id: user_id }
382+
params[:parent_id] = parent_id if parent_id
383+
@client.delete("#{url}/draft", params: params)
384+
end
385+
386+
# Gets a draft message for this channel.
387+
#
388+
# @param [String] user_id The ID of the user getting the draft
389+
# @param [String] parent_id Optional parent message ID for thread drafts
390+
# @return [StreamChat::StreamResponse]
391+
sig { params(user_id: String, parent_id: T.nilable(String)).returns(StreamChat::StreamResponse) }
392+
def get_draft(user_id, parent_id: nil)
393+
params = { user_id: user_id }
394+
params[:parent_id] = parent_id if parent_id
395+
@client.get("#{url}/draft", params: params)
396+
end
397+
363398
private
364399

365400
sig { params(payload: StringKeyHash, user_id: String).returns(StringKeyHash) }

lib/stream-chat/client.rb

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
require 'stream-chat/version'
1616
require 'stream-chat/util'
1717
require 'stream-chat/types'
18+
require 'stream-chat/moderation'
1819

1920
module StreamChat
2021
DEFAULT_BLOCKLIST = 'profanity_en_2020_v1'
@@ -36,6 +37,9 @@ class Client
3637
sig { returns(Faraday::Connection) }
3738
attr_reader :conn
3839

40+
sig { returns(Moderation) }
41+
attr_reader :moderation
42+
3943
# initializes a Stream Chat API Client
4044
#
4145
# @param [string] api_key your application api_key
@@ -65,6 +69,7 @@ def initialize(api_key, api_secret, timeout = nil, **options)
6569
end
6670
end
6771
@conn = T.let(conn, Faraday::Connection)
72+
@moderation = T.let(Moderation.new(self), Moderation)
6873
end
6974

7075
# initializes a Stream Chat API Client from STREAM_KEY and STREAM_SECRET
@@ -178,9 +183,9 @@ def review_flag_report(report_id, review_result, user_id, **details)
178183
end
179184

180185
# Returns a message.
181-
sig { params(id: String).returns(StreamChat::StreamResponse) }
182-
def get_message(id)
183-
get("messages/#{id}")
186+
sig { params(id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
187+
def get_message(id, **options)
188+
get("messages/#{id}", params: options)
184189
end
185190

186191
# Searches for messages.
@@ -276,6 +281,14 @@ def deactivate_user(user_id, **options)
276281
post("users/#{user_id}/deactivate", params: options)
277282
end
278283

284+
# Deactivates a users
285+
sig { params(user_ids: T::Array[String], options: T.untyped).returns(StreamChat::StreamResponse) }
286+
def deactivate_users(user_ids, **options)
287+
raise ArgumentError, 'user_ids should not be empty' if user_ids.empty?
288+
289+
post('users/deactivate', data: { user_ids: user_ids, **options })
290+
end
291+
279292
# Reactivates a deactivated user. Use deactivate_user to deactivate a user.
280293
sig { params(user_id: String, options: T.untyped).returns(StreamChat::StreamResponse) }
281294
def reactivate_user(user_id, **options)
@@ -779,6 +792,22 @@ def create_command(command)
779792
post('commands', data: command)
780793
end
781794

795+
# Queries draft messages for the current user.
796+
#
797+
# @param [String] user_id The ID of the user to query drafts for
798+
# @param [StringKeyHash] filter Optional filter conditions for the query
799+
# @param [Array] sort Optional sort parameters
800+
# @param [Hash] options Additional query options
801+
# @return [StreamChat::StreamResponse]
802+
sig { params(user_id: String, filter: T.nilable(StringKeyHash), sort: T.nilable(T::Array[StringKeyHash]), options: T.untyped).returns(StreamChat::StreamResponse) }
803+
def query_drafts(user_id, filter: nil, sort: nil, **options)
804+
data = { user_id: user_id }
805+
data['filter'] = filter if filter
806+
data['sort'] = sort if sort
807+
data.merge!(options) if options
808+
post('drafts/query', data: data)
809+
end
810+
782811
# Gets a comamnd.
783812
sig { params(name: String).returns(StreamChat::StreamResponse) }
784813
def get_command(name)
@@ -901,6 +930,16 @@ def list_imports(options)
901930
get('imports', params: options)
902931
end
903932

933+
sig { params(filter: StringKeyHash, sort: T.nilable(T::Hash[String, Integer]), options: T.untyped).returns(StreamChat::StreamResponse) }
934+
def query_threads(filter, sort: nil, **options)
935+
params = {}.merge(options).merge({
936+
filter: filter,
937+
sort: StreamChat.get_sort_fields(sort)
938+
})
939+
940+
post('threads', data: params)
941+
end
942+
904943
# Creates a reminder for a message.
905944
# @param message_id [String] The ID of the message to create a reminder for
906945
# @param user_id [String] The ID of the user creating the reminder

0 commit comments

Comments
 (0)