getAllUserListOfMessageReaction method

Future<V2TimValueCallback<V2TimMessageReactionUserResult>> getAllUserListOfMessageReaction({
  1. required String msgID,
  2. required String reactionID,
  3. required int nextSeq,
  4. required int count,
})

Implementation

Future<V2TimValueCallback<V2TimMessageReactionUserResult>> getAllUserListOfMessageReaction({
  required String msgID,
  required String reactionID,
  required int nextSeq,
  required int count,
}) async {
  String userData = Tools.generateUserData();
  Pointer<Uint8> user_data = Tools.string2PointerInt8(userData);

  String userDataFindMsg = Tools.generateUserData(methodName: "findMessage");
  Pointer<Uint8> user_data_find_msg = Tools.string2PointerInt8(userDataFindMsg);

  var msgIDListPtr = Tools.string2PointerInt8(json.encode([msgID]));

  List<Map<String, dynamic>> message_c_list = [];
  int res1 = desktopSDK.D_TIMMsgFindMessages(msgIDListPtr, user_data_find_msg);
  if (res1 != TIMResult.TIM_SUCC) {
    return V2TimValueCallback<V2TimMessageReactionUserResult>.fromJson({
      "code": res1,
      "desc": "find message error",
      "data": Map<String, dynamic>.from({
        "userInfoList": [],
        "nextSeq": 0,
        "isFinished": true,
      }),
    });
  } else {
    Map<String, dynamic> msgListData = await getAsyncData(apiKey: userDataFindMsg);
    List<Map<String, dynamic>> dataList = List<Map<String, dynamic>>.from(json.decode(msgListData["json_param"].isEmpty ? json.encode([]) : msgListData["json_param"]));

    for (var element in dataList) {
      message_c_list.add(element);
    }
  }
  if (message_c_list.isEmpty) {
    return V2TimValueCallback<V2TimMessageReactionUserResult>.fromJson({
      "code": -2,
      "desc": "find message error",
      "data": Map<String, dynamic>.from({
        "userInfoList": [],
        "nextSeq": 0,
        "isFinished": true,
      }),
    });
  }

  Pointer<Uint8> msgJsonPtr = Tools.string2PointerInt8(json.encode(message_c_list[0]));
  Pointer<Uint8> reactionIDPtr = Tools.string2PointerInt8(reactionID);
  int res = desktopSDK.D_TIMMsgGetAllUserListOfMessageReaction(msgJsonPtr, reactionIDPtr, nextSeq, count, user_data);
  if (res != TIMResult.TIM_SUCC) {
    return V2TimValueCallback<V2TimMessageReactionUserResult>.fromJson({
      "code": res,
      "desc": "",
      "data": Map<String, dynamic>.from({
        "userInfoList": [],
        "nextSeq": 0,
        "isFinished": true,
      }),
    });
  } else {
    Map<String, dynamic> data = await getAsyncData(apiKey: userData);
    Map<String, dynamic> dataMap = Map<String, dynamic>.from(
      json.decode(data["json_param"].isEmpty ? json.encode({}) : data["json_param"]),
    );
    List<Map<String, dynamic>> userInfoList = List.from(dataMap["message_reaction_user_result_user_info_array"] ?? []);
    List<Map<String, dynamic>> userInfoListDart = [];
    for (var i = 0; i < userInfoList.length; i++) {
      var item = userInfoList[i];
      userInfoListDart.add(
        Map<String, dynamic>.from(
          {
            "userID": item["user_profile_identifier"],
            "nickName": item["user_profile_nick_name"],
            "faceUrl": item["user_profile_face_url"],
          },
        ),
      );
    }
    return V2TimValueCallback<V2TimMessageReactionUserResult>.fromJson({
      "code": data["code"],
      "desc": data["desc"],
      "data": Map<String, dynamic>.from({
        "userInfoList": userInfoListDart,
        "nextSeq": dataMap["message_reaction_user_result_next_seq"],
        "isFinished": dataMap["message_reaction_user_result_is_finished"],
      }),
    });
  }
}