Skip to content

Commit e4844de

Browse files
authored
feat: add filter tags support for channels (#183)
* feat: add filter tags support for channels * Updated syntax
1 parent ccc2f94 commit e4844de

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

lib/stream-chat/channel.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,18 @@ def add_moderators(user_ids)
267267
update(nil, nil, add_moderators: user_ids)
268268
end
269269

270+
# Adds filter tags to the channel.
271+
sig { params(tags: T::Array[String]).returns(StreamChat::StreamResponse) }
272+
def add_filter_tags(tags)
273+
update(nil, nil, add_filter_tags: tags)
274+
end
275+
276+
# Removes filter tags from the channel.
277+
sig { params(tags: T::Array[String]).returns(StreamChat::StreamResponse) }
278+
def remove_filter_tags(tags)
279+
update(nil, nil, remove_filter_tags: tags)
280+
end
281+
270282
# Removes members from the channel.
271283
sig { params(user_ids: T::Array[String]).returns(StreamChat::StreamResponse) }
272284
def remove_members(user_ids)

spec/channel_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,4 +502,20 @@ def loop_times(times)
502502
# Verify it's deleted
503503
expect { @channel.get_draft(@random_user[:id], parent_id: parent_id) }.to raise_error(StreamChat::StreamAPIException)
504504
end
505+
506+
it 'can add and remove filter tags' do
507+
tags = %w[urgent bug]
508+
# Add tags
509+
response = @channel.add_filter_tags(tags)
510+
expect(response).to include 'channel'
511+
512+
# Ensure tags are set
513+
response = @channel.query
514+
expect(response['channel']['filter_tags']).to match_array(tags)
515+
516+
# Remove one tag
517+
@channel.remove_filter_tags(['urgent'])
518+
response = @channel.query
519+
expect(response['channel']['filter_tags']).to match_array(['bug'])
520+
end
505521
end

0 commit comments

Comments
 (0)