forwardMessage static method

Future<NIMResult<void>> forwardMessage(
  1. NIMMessage message,
  2. String sessionId,
  3. NIMSessionType sessionType
)

消息转发

Implementation

static Future<NIMResult<void>> forwardMessage(
    NIMMessage message, String sessionId, NIMSessionType sessionType) {
  //删除回复
  var replay = message.remoteExtension?.remove(ChatMessage.keyReplyMsgKey);
  //删除@信息
  var ait = message.remoteExtension?.remove(ChatMessage.keyAitMsg);
  return NimCore.instance.messageService
      .forwardMessage(message, sessionId, sessionType)
      .then((value) {
    var removedInfo = <String, dynamic>{};
    if (replay != null) {
      removedInfo[ChatMessage.keyReplyMsgKey] = replay;
    }
    if (ait != null) {
      removedInfo[ChatMessage.keyAitMsg] = ait;
    }
    if (removedInfo.isNotEmpty) {
      if (message.remoteExtension != null) {
        message.remoteExtension!.addAll(removedInfo);
      } else {
        message.remoteExtension = removedInfo;
      }
    }
    return value;
  });
}