diff --git a/src/Clients/ChannelClient.FilterTags.cs b/src/Clients/ChannelClient.FilterTags.cs
new file mode 100644
index 0000000..ce1a5fc
--- /dev/null
+++ b/src/Clients/ChannelClient.FilterTags.cs
@@ -0,0 +1,54 @@
+using System.Collections.Generic;
+using System.Net;
+using System.Threading.Tasks;
+using StreamChat.Models;
+using StreamChat.Rest;
+
+namespace StreamChat.Clients
+{
+ ///
+ /// Convenience methods for updating a channel's filter tags.
+ ///
+ public partial class ChannelClient
+ {
+ ///
+ /// Adds one or more filter tags to the channel.
+ ///
+ public Task AddFilterTagsAsync(string channelType, string channelId,
+ params string[] filterTags) => AddFilterTagsAsync(channelType, channelId, (IEnumerable)filterTags);
+
+ ///
+ /// Adds filter tags to the channel.
+ ///
+ public async Task AddFilterTagsAsync(string channelType, string channelId,
+ IEnumerable filterTags, MessageRequest msg = null) => await ExecuteRequestAsync(
+ $"channels/{channelType}/{channelId}",
+ HttpMethod.POST,
+ HttpStatusCode.Created,
+ new ChannelUpdateRequest
+ {
+ AddFilterTags = filterTags,
+ Message = msg,
+ });
+
+ ///
+ /// Removes one or more filter tags from the channel.
+ ///
+ public Task RemoveFilterTagsAsync(string channelType, string channelId,
+ params string[] filterTags) => RemoveFilterTagsAsync(channelType, channelId, (IEnumerable)filterTags);
+
+ ///
+ /// Removes filter tags from the channel.
+ ///
+ public async Task RemoveFilterTagsAsync(string channelType, string channelId,
+ IEnumerable filterTags, MessageRequest msg = null) => await ExecuteRequestAsync(
+ $"channels/{channelType}/{channelId}",
+ HttpMethod.POST,
+ HttpStatusCode.Created,
+ new ChannelUpdateRequest
+ {
+ RemoveFilterTags = filterTags,
+ Message = msg,
+ });
+ }
+}
diff --git a/src/Clients/IChannelClient.cs b/src/Clients/IChannelClient.cs
index eeb55b8..53e5763 100644
--- a/src/Clients/IChannelClient.cs
+++ b/src/Clients/IChannelClient.cs
@@ -170,6 +170,20 @@ Task PartialUpdateAsync(string channelType, string
Task RemoveMembersAsync(string channelType, string channelId, IEnumerable userIds,
MessageRequest msg = null);
+ ///
+ /// Adds filter tags to a channel.
+ ///
+ Task AddFilterTagsAsync(string channelType, string channelId, IEnumerable filterTags, MessageRequest msg = null);
+
+ Task AddFilterTagsAsync(string channelType, string channelId, params string[] filterTags);
+
+ ///
+ /// Removes filter tags from a channel.
+ ///
+ Task RemoveFilterTagsAsync(string channelType, string channelId, IEnumerable filterTags, MessageRequest msg = null);
+
+ Task RemoveFilterTagsAsync(string channelType, string channelId, params string[] filterTags);
+
///
/// Update channel member partially.
///
diff --git a/src/Models/Channel.cs b/src/Models/Channel.cs
index 2e2f717..bfc34ab 100644
--- a/src/Models/Channel.cs
+++ b/src/Models/Channel.cs
@@ -93,6 +93,7 @@ public class ChannelRequest : CustomDataBase
public Language? AutoTranslationLanguage { get; set; }
public bool? Frozen { get; set; }
public IEnumerable Members { get; set; }
+ public IEnumerable FilterTags { get; set; }
public ConfigOverridesRequest ConfigOverrides { get; set; }
}
@@ -117,6 +118,8 @@ public class ChannelUpdateRequest
public IEnumerable RemoveMembers { get; set; }
public IEnumerable AddModerators { get; set; }
public IEnumerable DemoteModerators { get; set; }
+ public IEnumerable AddFilterTags { get; set; }
+ public IEnumerable RemoveFilterTags { get; set; }
public IEnumerable Invites { get; set; }
public int? Cooldown { get; set; }
public bool? AcceptInvite { get; set; }
diff --git a/tests/ChannelClientTests.cs b/tests/ChannelClientTests.cs
index b3ae802..11b9913 100644
--- a/tests/ChannelClientTests.cs
+++ b/tests/ChannelClientTests.cs
@@ -590,6 +590,36 @@ public async Task TestRemoveMembersAsync()
channel.Members.Should().NotContain(x => x.UserId == _user3.Id);
}
+ [Test]
+ public async Task TestAddFilterTagsAsync()
+ {
+ var channel = await CreateChannelAsync(createdByUserId: _user1.Id);
+
+ await _channelClient.AddFilterTagsAsync(channel.Type, channel.Id, "alpha", "beta");
+
+ var channelState = await _channelClient.GetOrCreateAsync(channel.Type, channel.Id,
+ ChannelGetRequest.WithoutWatching());
+
+ channelState.Channel.GetData("filter_tags").Should().Contain(new[] { "alpha", "beta" });
+ }
+
+ [Test]
+ public async Task TestRemoveFilterTagsAsync()
+ {
+ var channel = await CreateChannelAsync(createdByUserId: _user1.Id);
+
+ await _channelClient.AddFilterTagsAsync(channel.Type, channel.Id, "gamma", "delta");
+
+ await _channelClient.RemoveFilterTagsAsync(channel.Type, channel.Id, new[] { "gamma" });
+
+ var channelState = await _channelClient.GetOrCreateAsync(channel.Type, channel.Id,
+ ChannelGetRequest.WithoutWatching());
+
+ var tags = channelState.Channel.GetData("filter_tags");
+ tags.Should().NotContain("gamma");
+ tags.Should().Contain("delta");
+ }
+
[Test]
public async Task TestAddModeratorsAsync()
{
diff --git a/tests/MessageCountTests.cs b/tests/MessageCountTests.cs
index 16586ff..f6953c4 100644
--- a/tests/MessageCountTests.cs
+++ b/tests/MessageCountTests.cs
@@ -17,7 +17,7 @@ public class MessageCountTests : TestBase
public async Task SetUp()
{
_user = await UpsertNewUserAsync();
- _channel = await CreateChannelAsync(_user.Id, autoDelete: false);
+ _channel = await CreateChannelAsync(_user.Id, autoDelete: false, channelType: "team");
}
[TearDown]
diff --git a/tests/TestBase.cs b/tests/TestBase.cs
index ec84e79..3e96d44 100644
--- a/tests/TestBase.cs
+++ b/tests/TestBase.cs
@@ -106,9 +106,9 @@ protected async Task UpsertNewUserAsync()
return user;
}
- protected async Task CreateChannelAsync(string createdByUserId, IEnumerable members = null, bool autoDelete = true)
+ protected async Task CreateChannelAsync(string createdByUserId, IEnumerable members = null, bool autoDelete = true, string channelType = "messaging")
{
- var channelResp = await _channelClient.GetOrCreateAsync("messaging", Guid.NewGuid().ToString(), new ChannelGetRequest
+ var channelResp = await _channelClient.GetOrCreateAsync(channelType, Guid.NewGuid().ToString(), new ChannelGetRequest
{
Data = new ChannelRequest
{