setConversationCustomData static method

Future<V2TimValueCallback<List<V2TimConversationOperationResult>>> setConversationCustomData({
  1. required String customData,
  2. required List<String> conversationIDList,
})

Implementation

static Future<V2TimValueCallback<List<V2TimConversationOperationResult>>> setConversationCustomData({
  required String customData,
  required List<String> conversationIDList,
}) async {
  String userData = Tools.generateUserData();
  Pointer<Uint8> user_data = Tools.string2PointerInt8(userData);
  Pointer<Uint8> conversation_id_array = Tools.string2PointerInt8(json.encode(conversationIDList));
  Pointer<Uint8> custom_data = Tools.string2PointerInt8(customData);
  int res = desktopSDK.D_TIMConvSetConversationCustomData(conversation_id_array, custom_data, user_data);
  if (res != TIMResult.TIM_SUCC) {
    return V2TimValueCallback<List<V2TimConversationOperationResult>>.fromJson({
      "code": res,
      "desc": "",
    });
  } else {
    Map<String, dynamic> data = await getAsyncData(apiKey: userData);
    List<Map<String, dynamic>> dataList = List<Map<String, dynamic>>.from(json.decode(data["json_param"].isEmpty ? json.encode([]) : data["json_param"]));
    List<Map<String, dynamic>> list = List<Map<String, dynamic>>.empty(growable: true);
    for (var element in dataList) {
      Map<String, dynamic> jso = element;
      list.add(Map<String, dynamic>.from(
          {"conversationID": jso["conversation_operation_result_conversation_id"], "resultCode": jso["conversation_operation_result_result_code"], "resultInfo": jso["conversation_operation_result_result_info"]}));
    }
    return V2TimValueCallback<List<V2TimConversationOperationResult>>.fromJson({
      "code": res,
      "desc": "",
      "data": list,
    });
  }
}