deleteMessageMetaArrayKeys method

Future<BaseMessage> deleteMessageMetaArrayKeys(
  1. BaseMessage message,
  2. List<String> keys
)

Deletes message meta array keys.

Implementation

Future<BaseMessage> deleteMessageMetaArrayKeys(
  BaseMessage message,
  List<String> keys,
) async {
  sbLog.i(StackTrace.current, 'keys: $keys');
  checkUnsupportedAction();

  if (message.channelUrl != channelUrl) {
    throw InvalidParameterException();
  }

  if (keys.isEmpty) {
    throw InvalidParameterException();
  }

  final metaArrays =
      keys.map((e) => MessageMetaArray(key: e, value: [])).toList();
  final cmd = Command.buildUpdateMessageMetaArray(
      message, metaArrays, MetaArrayUpdateMode.remove, true);

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