feat(llc): add additional parameters to channel.truncate
This commit is contained in:
@@ -1033,10 +1033,23 @@ class Channel {
|
|||||||
return _client.deleteChannel(id!, type);
|
return _client.deleteChannel(id!, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Removes all messages from the channel.
|
/// Removes all messages from the channel up to [truncatedAt] or now if
|
||||||
Future<EmptyResponse> truncate() async {
|
/// [truncatedAt] is not provided.
|
||||||
|
/// If [skipPush] is true, no push notification will be sent.
|
||||||
|
/// [Message] is the system message that will be sent to the channel.
|
||||||
|
Future<EmptyResponse> truncate({
|
||||||
|
Message? message,
|
||||||
|
bool? skipPush,
|
||||||
|
DateTime? truncatedAt,
|
||||||
|
}) async {
|
||||||
_checkInitialized();
|
_checkInitialized();
|
||||||
return _client.truncateChannel(id!, type);
|
return _client.truncateChannel(
|
||||||
|
id!,
|
||||||
|
type,
|
||||||
|
message: message,
|
||||||
|
skipPush: skipPush,
|
||||||
|
truncatedAt: truncatedAt,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Accept invitation to the channel.
|
/// Accept invitation to the channel.
|
||||||
|
|||||||
@@ -938,14 +938,23 @@ class StreamChatClient {
|
|||||||
channelType,
|
channelType,
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Removes all messages from the channel
|
/// Removes all messages from the channel up to [truncatedAt] or now if
|
||||||
|
/// [truncatedAt] is not provided.
|
||||||
|
/// If [skipPush] is true, no push notification will be sent.
|
||||||
|
/// [Message] is the system message that will be sent to the channel.
|
||||||
Future<EmptyResponse> truncateChannel(
|
Future<EmptyResponse> truncateChannel(
|
||||||
String channelId,
|
String channelId,
|
||||||
String channelType,
|
String channelType, {
|
||||||
) =>
|
Message? message,
|
||||||
|
bool? skipPush,
|
||||||
|
DateTime? truncatedAt,
|
||||||
|
}) =>
|
||||||
_chatApi.channel.truncateChannel(
|
_chatApi.channel.truncateChannel(
|
||||||
channelId,
|
channelId,
|
||||||
channelType,
|
channelType,
|
||||||
|
message: message,
|
||||||
|
skipPush: skipPush,
|
||||||
|
truncatedAt: truncatedAt,
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Mutes the channel
|
/// Mutes the channel
|
||||||
|
|||||||
@@ -265,10 +265,18 @@ class ChannelApi {
|
|||||||
/// Removes all messages from the channel
|
/// Removes all messages from the channel
|
||||||
Future<EmptyResponse> truncateChannel(
|
Future<EmptyResponse> truncateChannel(
|
||||||
String channelId,
|
String channelId,
|
||||||
String channelType,
|
String channelType, {
|
||||||
) async {
|
Message? message,
|
||||||
|
bool? skipPush,
|
||||||
|
DateTime? truncatedAt,
|
||||||
|
}) async {
|
||||||
final response = await _client.post(
|
final response = await _client.post(
|
||||||
'${_getChannelUrl(channelId, channelType)}/truncate',
|
'${_getChannelUrl(channelId, channelType)}/truncate',
|
||||||
|
data: {
|
||||||
|
if (message != null) 'message': message,
|
||||||
|
if (skipPush != null) 'skip_push': skipPush,
|
||||||
|
if (truncatedAt != null) 'truncated_at': truncatedAt,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
return EmptyResponse.fromJson(response.data);
|
return EmptyResponse.fromJson(response.data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -481,14 +481,21 @@ void main() {
|
|||||||
|
|
||||||
final path = '${_getChannelUrl(channelId, channelType)}/truncate';
|
final path = '${_getChannelUrl(channelId, channelType)}/truncate';
|
||||||
|
|
||||||
when(() => client.post(path)).thenAnswer(
|
when(() => client.post(
|
||||||
(_) async => successResponse(path, data: <String, dynamic>{}));
|
path,
|
||||||
|
data: {},
|
||||||
|
))
|
||||||
|
.thenAnswer(
|
||||||
|
(_) async => successResponse(path, data: <String, dynamic>{}));
|
||||||
|
|
||||||
final res = await channelApi.truncateChannel(channelId, channelType);
|
final res = await channelApi.truncateChannel(channelId, channelType);
|
||||||
|
|
||||||
expect(res, isNotNull);
|
expect(res, isNotNull);
|
||||||
|
|
||||||
verify(() => client.post(path)).called(1);
|
verify(() => client.post(
|
||||||
|
path,
|
||||||
|
data: {},
|
||||||
|
)).called(1);
|
||||||
verifyNoMoreInteractions(client);
|
verifyNoMoreInteractions(client);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user