updateUserMessage method

Future<UserMessage> updateUserMessage(
  1. int messageId,
  2. UserMessageUpdateParams params
)

Updates a UserMessage that was previously sent in the channel.

Implementation

Future<UserMessage> updateUserMessage(
    int messageId, UserMessageUpdateParams params) async {
  sbLog.i(StackTrace.current, 'message: ${params.message}');
  checkUnsupportedAction();

  if (messageId <= 0) {
    throw InvalidParameterException();
  }

  final cmd = Command.buildUpdateUserMessage(
    channelUrl,
    messageId,
    params,
  );

  final result = await chat.commandManager.sendCommand(cmd);
  if (result != null) {
    final baseMessage = BaseMessage.getMessageFromJsonWithChat<UserMessage>(
      chat,
      result.payload,
      commandType: cmd.cmd,
    );
    return baseMessage;
  } else {
    throw WebSocketFailedException();
  }
}