searchMessage static method

Future<List<ChatMessage>?> searchMessage(
  1. String keyWord,
  2. String sessionId,
  3. NIMConversationType conversationType
)

根据关键字搜索消息

Implementation

static Future<List<ChatMessage>?> searchMessage(String keyWord,
    String sessionId, NIMConversationType conversationType) async {
  NIMMessageSearchParams params = NIMMessageSearchParams(
      keyword: keyWord, sortOrder: NIMSortOrder.sortOrderDesc);

  if (conversationType == NIMConversationType.team) {
    params.teamIds = [sessionId];
  } else if (conversationType == NIMConversationType.p2p) {
    params.p2pAccountIds = [sessionId];
  }
  var res = await NimCore.instance.messageService
      .searchCloudMessages(params: params);
  if (res.isSuccess && res.data != null) {
    List<ChatMessage> tmp = await fillUserInfo(res.data!);
    return tmp.toList();
  }
  return null;
}