fetchReactionList method

Future<Map<String, List<EMMessageReaction>>> fetchReactionList(
  1. {required List<String> messageIds,
  2. required ChatType chatType,
  3. String? groupId}
)

获取 Reaction 列表。

Param messageIds 消息 ID 列表。

Param chatType 会话类型。

Param groupId 群组 ID,该参数仅在会话类型为群聊时有效。

Return 若调用成功,返回 Reaction 列表;失败则抛出异常。

Throws 如果有异常会在此抛出,包括错误码和错误信息,详见 EMError

Implementation

Future<Map<String, List<EMMessageReaction>>> fetchReactionList({
  required List<String> messageIds,
  required ChatType chatType,
  String? groupId,
}) async {
  Map req = {
    "msgIds": messageIds,
    "chatType": chatTypeToInt(chatType),
  };
  req.putIfNotNull("groupId", groupId);
  Map result = await ChatChannel.invokeMethod(
    ChatMethodKeys.fetchReactionList,
    req,
  );

  try {
    EMError.hasErrorFromResult(result);
    Map<String, List<EMMessageReaction>> ret = {};
    for (var info in result[ChatMethodKeys.fetchReactionList].entries) {
      List<EMMessageReaction> reactions = [];
      for (var item in info.value) {
        reactions.add(EMMessageReaction.fromJson(item));
      }
      ret[info.key] = reactions;
    }
    return ret;
  } on EMError catch (e) {
    throw e;
  }
}