copyMessage method
BaseMessage
copyMessage(
- BaseMessage message,
- BaseChannel targetChannel, {
- BaseMessageHandler? handler,
Copies a message from this channel to the target channel.
Implementation
BaseMessage copyMessage(
BaseMessage message,
BaseChannel targetChannel, {
BaseMessageHandler? handler,
}) {
sbLog.i(StackTrace.current, 'message: ${message.message}');
checkUnsupportedAction();
if (message.channelUrl != channelUrl) {
throw InvalidParameterException();
}
// Do not copy [extendedMessage] in message.
message.extendedMessage.clear();
if (message is UserMessage) {
final params = UserMessageCreateParams.withMessage(message);
if (params.pollId != null) {
throw InvalidParameterException();
}
return targetChannel.sendUserMessage(
params,
handler: handler,
);
} else if (message is FileMessage) {
final params = FileMessageCreateParams.withMessage(message);
return targetChannel.sendFileMessage(
params,
handler: handler,
);
} else {
throw InvalidParameterException();
}
}