acceptFriendApplication static method

Future<V2TimValueCallback<V2TimFriendOperationResult>> acceptFriendApplication({
  1. required int responseType,
  2. required int type,
  3. required String userID,
})

Implementation

static Future<V2TimValueCallback<V2TimFriendOperationResult>> acceptFriendApplication({
  required int responseType,
  required int type,
  required String userID,
}) async {
  String param = json.encode({
    "friend_response_identifier": userID,
    "friend_response_action": 1,
    "friend_response_remark": "",
    "friend_response_group_name": "",
  });
  String userData = Tools.generateUserData();
  Pointer<Uint8> user_data = Tools.string2PointerInt8(userData);
  Pointer<Uint8> json_handle_friend_add_param = Tools.string2PointerInt8(param);
  int res = desktopSDK.D_TIMFriendshipHandleFriendAddRequest(json_handle_friend_add_param, user_data);
  if (res != TIMResult.TIM_SUCC) {
    return V2TimValueCallback<V2TimFriendOperationResult>.fromJson({
      "code": res,
      "desc": "",
    });
  } else {
    Map<String, dynamic> data = await getAsyncData(apiKey: userData);
    Map<String, dynamic> nativeJson = Map<String, dynamic>.from(json.decode(data["json_param"].isEmpty ? json.encode({}) : data["json_param"]));
    Map<String, dynamic> dartJson = Map<String, dynamic>.from({
      "resultCode": nativeJson["friend_result_code"],
      "resultInfo": nativeJson["friend_result_desc"],
      "userID": nativeJson["friend_result_identifier"],
    });

    return V2TimValueCallback<V2TimFriendOperationResult>.fromJson({"code": data["code"], "desc": data["desc"], "data": dartJson});
  }
}