Skip to content

Commit 406c994

Browse files
authored
feat(truncate): add user id for truncation (#107)
1 parent bc2a164 commit 406c994

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

src/Clients/IChannelClient.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public interface IChannelClient
5656

5757
/// <summary>
5858
/// <para>Mutes a channel.</para>
59-
/// Messages added to a channel will not trigger push notifications, nor change the
59+
/// Messages added to a muted channel will not trigger push notifications, nor change the
6060
/// unread count for the users that muted it. By default, mutes stay in place indefinitely
6161
/// until the user removes it; however, you can optionally set an expiration time. The list
6262
/// of muted channels and their expiration time is returned when the user connects.
@@ -66,10 +66,11 @@ public interface IChannelClient
6666

6767
/// <summary>
6868
/// <para>Unmutes a channel.</para>
69-
/// Messages added to a channel will not trigger push notifications, nor change the
69+
/// Messages added to a muted channel will not trigger push notifications, nor change the
7070
/// unread count for the users that muted it. By default, mutes stay in place indefinitely
7171
/// until the user removes it; however, you can optionally set an expiration time. The list
7272
/// of muted channels and their expiration time is returned when the user connects.
73+
/// This method removes the mute which means the users will receive notifications again.
7374
/// </summary>
7475
/// <remarks>https://getstream.io/chat/docs/dotnet-csharp/muting_channels/?language=csharp</remarks>
7576
Task<ChannelUnmuteResponse> UnmuteChannelAsync(ChannelUnmuteRequest request);

src/Models/Channel.cs

+9
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ public class Channel : CustomDataBase
5050

5151
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "last_message_at")]
5252
public DateTimeOffset? LastMessageAt { get; set; }
53+
54+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "truncated_by")]
55+
public User TruncatedBy { get; set; }
5356
}
5457

5558
public class ChannelWithConfig : Channel
@@ -137,6 +140,12 @@ public class TruncateOptions
137140

138141
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "truncated_at")]
139142
public DateTimeOffset? TruncatedAt { get; set; }
143+
144+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "user_id")]
145+
public string UserId { get; set; }
146+
147+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore, PropertyName = "user")]
148+
public User User { get; set; }
140149
}
141150

142151
public class TruncateResponse : ApiResponse

tests/ChannelClientTests.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,13 @@ public async Task TestChannelTruncateAsync()
151151
var originalChannel = await _channelClient.GetOrCreateAsync(_channel.Type, _channel.Id, new ChannelGetRequest { State = true });
152152
originalChannel.Messages.Should().NotBeEmpty();
153153

154-
await _channelClient.TruncateAsync(_channel.Type, _channel.Id);
154+
await _channelClient.TruncateAsync(_channel.Type, _channel.Id, new TruncateOptions { UserId = _user2.Id });
155155

156156
var afterTruncateChannel = await _channelClient.GetOrCreateAsync(_channel.Type, _channel.Id, new ChannelGetRequest { State = true });
157157
afterTruncateChannel.Messages.Should().BeEmpty();
158+
159+
// this isn't deployed to the test environment, so uncomment it a bit later:
160+
// afterTruncateChannel.Channel.TruncatedBy.Id.Should().Be(_user2.Id);
158161
}
159162

160163
[Test]

0 commit comments

Comments
 (0)