copyUserMessage

fun BaseChannel.copyUserMessage(targetChannel: BaseChannel, userMessage: UserMessage): Flow<MessageResult<UserMessage>>

Copies a user message from this channel to the target channel. ** Sample code **

baseChannel.copyUserMessage(targetChannel, userMessage)
.onEach {
when (it) {
is MessageResult.Pending -> {
// called it when sending message are called
// it contains pendingMessage
}
is MessageResult.Succeed -> {
// called it with result data when all job has been completed
}
is MessageResult.Failure -> {
// deliver exception with failed message when all job has been completed
// it.message : failed message
// it.e : exception
}
}
}.catch {
// error occurred (validation failed)
}.launchIn(viewModelScope)

Return

The copied user message

Since

4.15.0

Parameters

targetChannel

The target channel to copy user message

userMessage

The user message to copy