fetchHistoryMessage static method

Future<NIMResult<List<ChatMessage>>> fetchHistoryMessage(
  1. NIMMessage anchor,
  2. int toTime,
  3. int limit,
  4. QueryDirection direction,
)

查询历史消息,从远端查询

Implementation

static Future<NIMResult<List<ChatMessage>>> fetchHistoryMessage(
    NIMMessage anchor,
    int toTime,
    int limit,
    QueryDirection direction) async {
  List<NIMMessageType> defaultTypes = [
    NIMMessageType.text,
    NIMMessageType.image,
    NIMMessageType.audio,
    NIMMessageType.video,
    NIMMessageType.location,
    NIMMessageType.notification,
    NIMMessageType.file,
    NIMMessageType.tip,
    NIMMessageType.custom
  ];
  var res = await NimCore.instance.messageService.pullMessageHistoryExType(
      anchor, toTime, limit, direction, defaultTypes, true);
  if (res.isSuccess && res.data != null) {
    var result = await fillUserInfo(res.data!);
    result = _fillPin(anchor.sessionId!, anchor.sessionType!, result);
    return NIMResult(res.code, result, res.errorDetails);
  }
  return NIMResult(res.code, null, res.errorDetails);
}