fetchReactionList method
~english Gets the list of Reactions.
Param messageIds
The message IDs.
Param chatType
The chat type. Only one-to-one chat ChatType.Chat and group chat ChatType.GroupChat are allowed.
Param groupId
The group ID. This parameter is valid only when the chat type is group chat.
Return The Reaction list under the specified message ID(ChatMessageReaction.userList is the summary data, which only contains the information of the first three users).
Throws A description of the exception. See ChatError. ~end
~chinese 获取 Reaction 列表。
Param messageIds
消息 ID 列表。
Param chatType
会话类型。
Param groupId
群组 ID,该参数仅在会话类型为群聊时有效。
Return 若调用成功,返回 Reaction 列表;失败则抛出异常。
Throws 如果有异常会在此抛出,包括错误码和错误信息,详见 ChatError。 ~end
Implementation
Future<Map<String, List<ChatMessageReaction>>> 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 {
ChatError.hasErrorFromResult(result);
Map<String, List<ChatMessageReaction>> ret = {};
for (var info in result[ChatMethodKeys.fetchReactionList].entries) {
List<ChatMessageReaction> reactions = [];
for (var item in info.value) {
reactions.add(ChatMessageReaction.fromJson(item));
}
ret[info.key] = reactions;
}
return ret;
} on ChatError catch (e) {
throw e;
}
}