getGroupMessageReadInfo method

Future<SyImGroupReadInfo> getGroupMessageReadInfo({
  1. required String conversationId,
  2. required String clientMsgId,
  3. ImControlPlane? controlPlane,
})

群消息已读概况,三端同名同义。OpenIM Flutter 绑定只给人数;传入带 userJwt 的 controlPlane 时, 再查控制面 who-read 花名册补已读成员(SyImGroupReadInfo.source == controlPlane)。 花名册只含调用过 reportGroupMessagesRead 的成员;查询失败时退回只有人数。

Implementation

Future<SyImGroupReadInfo> getGroupMessageReadInfo({
  required String conversationId,
  required String clientMsgId,
  ImControlPlane? controlPlane,
}) async {
  final a = _requireLoggedIn();
  final info = await a.getGroupMessageReadInfo(
    conversationId: conversationId,
    clientMsgId: clientMsgId,
  );
  final seq = a.lastGroupReadSeq;
  final cp = controlPlane;
  if (cp == null ||
      (cp.userJwt ?? '').isEmpty ||
      seq < 0 ||
      info.readUserIds.isNotEmpty) {
    return info;
  }
  List<String>? roster;
  try {
    roster = await cp.whoRead(conversationId: conversationId, seq: seq);
  } catch (_) {
    roster = null;
  }
  return SyImReadReceipts.merge(
    clientMsgId: clientMsgId,
    hasReadCount: info.hasReadCount,
    unreadCount: info.unreadCount,
    roster: roster,
  );
}