public fun sendMessage(message: Message) { val activeMessage = activeAction?.message ?: message val sendMessageCall = if (isInEditMode && !activeMessage.isModerationFailed(chatClient)) { getEditMessageCall(message) } else { message.showInChannel = isInThread && alsoSendToChannel.value val (channelType, channelId) = message.cid.cidToTypeAndId() if (activeMessage.isModerationFailed(chatClient)) { chatClient.deleteMessage(activeMessage.id, true).enqueue() }  chatClient.sendMessage(channelType, channelId, message) }  dismissMessageActions() clearData()  sendMessageCall.enqueueAndHandleSlowMode() }
Sends a given message using our Stream API. Based on [isInEditMode], we either edit an existing message, or we send a new message, using [ChatClient]. In case the message is a moderated message the old one is deleted before the replacing one is sent.