public fun buildNewMessage( message: String, attachments: List<Attachment> = emptyList(), ): Message { val activeAction = activeAction  val trimmedMessage = message.trim() val activeMessage = activeAction?.message ?: Message() val replyMessageId = (activeAction as? Reply)?.message?.id val mentions = filterMentions(selectedMentions, trimmedMessage)  return if (isInEditMode && !activeMessage.isModerationFailed(chatClient)) { activeMessage.copy( text = trimmedMessage, attachments = attachments.toMutableList(), mentionedUsersIds = mentions ) } else { Message( cid = channelId, text = trimmedMessage, parentId = parentMessageId, replyMessageId = replyMessageId, attachments = attachments.toMutableList(), mentionedUsersIds = mentions ) } }
Builds a new [Message] to send to our API. If [isInEditMode] is true, we use the current action's message and apply the given changes.