Implementation
Future<UserMessage> sendUserMessage({
required ChannelType channelType,
required String channelUrl,
required UserMessageParams params,
String? senderId,
List<String>? additionalMentionedUserIds,
bool markAsRead = false,
}) async {
final url = endpoint.Channels.channelurl_messages.format([
channelType.urlString,
channelUrl,
]);
final body = <String, dynamic>{
'message_type': CommandType.userMessage,
'user_id': senderId ?? currentUserId,
'mark_as_read': markAsRead,
if (additionalMentionedUserIds != null)
'mentioned_user_ids': additionalMentionedUserIds,
};
body.addAll(params.toJson());
body.removeWhere((key, value) => value == null);
final res = await client.post(url: url, body: body);
return BaseMessage.msgFromJson<UserMessage>(res,
channelType: channelType)!; //mark!
}