diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 0210d938..f95791d8 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -873,9 +873,11 @@ passportElementTypeEmailAddress = PassportElementType; //@description Represents a date according to the Gregorian calendar @day Day of the month, 1-31 @month Month, 1-12 @year Year, 1-9999 date day:int32 month:int32 year:int32 = Date; -//@description Contains the user's personal details @first_name First name of the user; 1-255 characters @middle_name Middle name of the user; 0-255 characters @last_name Last name of the user; 1-255 characters @birthdate Birthdate of the user -//@gender Gender of the user, "male" or "female" @country_code A two-letter ISO 3166-1 alpha-2 country code for the user's country @residence_country_code A two-letter ISO 3166-1 alpha-2 country code for the user's residence country -personalDetails first_name:string middle_name:string last_name:string birthdate:date gender:string country_code:string residence_country_code:string = PersonalDetails; +//@description Contains the user's personal details +//@first_name First name of the user written in English; 1-255 characters @middle_name Middle name of the user written in English; 0-255 characters @last_name Last name of the user written in English; 1-255 characters +//@native_first_name Native first name of the user; 1-255 characters @native_middle_name Native middle name of the user; 0-255 characters @native_last_name Native last name of the user; 1-255 characters +//@birthdate Birthdate of the user @gender Gender of the user, "male" or "female" @country_code A two-letter ISO 3166-1 alpha-2 country code for the user's country @residence_country_code A two-letter ISO 3166-1 alpha-2 country code for the user's residence country +personalDetails first_name:string middle_name:string last_name:string native_first_name:string native_middle_name:string native_last_name:string birthdate:date gender:string country_code:string residence_country_code:string = PersonalDetails; //@description An identity document @number Document number; 1-24 characters @expiry_date Document expiry date; may be null @front_side Front side of the document //@reverse_side Reverse side of the document; only for driver license and identity card @selfie Selfie with the document; may be null @translation List of files with the document translation diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index 0b3fe784..4fa95560 100644 Binary files a/td/generate/scheme/td_api.tlo and b/td/generate/scheme/td_api.tlo differ diff --git a/td/telegram/SecureValue.cpp b/td/telegram/SecureValue.cpp index 3514b9f8..1d2a53dd 100644 --- a/td/telegram/SecureValue.cpp +++ b/td/telegram/SecureValue.cpp @@ -272,6 +272,15 @@ string get_secure_value_data_field_name(SecureValueType type, string field_name) field_name == "gender" || field_name == "country_code" || field_name == "residence_country_code") { return field_name; } + if (field_name == "first_name_native") { + return "native_first_name"; + } + if (field_name == "middle_name_native") { + return "native_middle_name"; + } + if (field_name == "last_name_native") { + return "native_last_name"; + } if (field_name == "birth_date") { return "birthdate"; } @@ -726,38 +735,12 @@ static Result> get_date_object(Slice date) { return td_api::make_object(day, month, year); } -static Status check_first_name(string &first_name) { - if (!clean_input_string(first_name)) { - return Status::Error(400, "First name must be encoded in UTF-8"); +static Status check_name(string &name) { + if (!clean_input_string(name)) { + return Status::Error(400, "Name must be encoded in UTF-8"); } - if (first_name.empty()) { - return Status::Error(400, "First name must not be empty"); - } - if (utf8_length(first_name) > 255) { - return Status::Error(400, "First name is too long"); - } - return Status::OK(); -} - -static Status check_middle_name(string &middle_name) { - if (!clean_input_string(middle_name)) { - return Status::Error(400, "Middle name must be encoded in UTF-8"); - } - if (utf8_length(middle_name) > 255) { - return Status::Error(400, "Middle name is too long"); - } - return Status::OK(); -} - -static Status check_last_name(string &last_name) { - if (!clean_input_string(last_name)) { - return Status::Error(400, "Last name must be encoded in UTF-8"); - } - if (last_name.empty()) { - return Status::Error(400, "Last name must not be empty"); - } - if (utf8_length(last_name) > 255) { - return Status::Error(400, "Last name is too long"); + if (utf8_length(name) > 255) { + return Status::Error(400, "Name is too long"); } return Status::OK(); } @@ -773,9 +756,12 @@ static Result get_personal_details(td_api::object_ptrfirst_name_)); - TRY_STATUS(check_middle_name(personal_details->middle_name_)); - TRY_STATUS(check_last_name(personal_details->last_name_)); + TRY_STATUS(check_name(personal_details->first_name_)); + TRY_STATUS(check_name(personal_details->middle_name_)); + TRY_STATUS(check_name(personal_details->last_name_)); + TRY_STATUS(check_name(personal_details->native_first_name_)); + TRY_STATUS(check_name(personal_details->native_middle_name_)); + TRY_STATUS(check_name(personal_details->native_last_name_)); TRY_RESULT(birthdate, get_date(std::move(personal_details->birthdate_))); if (birthdate.empty()) { return Status::Error(400, "Birthdate must not be empty"); @@ -788,6 +774,9 @@ static Result get_personal_details(td_api::object_ptrfirst_name_); o("middle_name", personal_details->middle_name_); o("last_name", personal_details->last_name_); + o("first_name_native", personal_details->native_first_name_); + o("middle_name_native", personal_details->native_middle_name_); + o("last_name_native", personal_details->native_last_name_); o("birth_date", birthdate); o("gender", personal_details->gender_); o("country_code", personal_details->country_code_); @@ -811,6 +800,9 @@ static Result> get_personal_details_ TRY_RESULT(first_name, get_json_object_string_field(object, "first_name", true)); TRY_RESULT(middle_name, get_json_object_string_field(object, "middle_name", true)); TRY_RESULT(last_name, get_json_object_string_field(object, "last_name", true)); + TRY_RESULT(native_first_name, get_json_object_string_field(object, "first_name_native", true)); + TRY_RESULT(native_middle_name, get_json_object_string_field(object, "middle_name_native", true)); + TRY_RESULT(native_last_name, get_json_object_string_field(object, "last_name_native", true)); TRY_RESULT(birthdate, get_json_object_string_field(object, "birth_date", true)); if (birthdate.empty()) { return Status::Error(400, "Birthdate must not be empty"); @@ -819,17 +811,21 @@ static Result> get_personal_details_ TRY_RESULT(country_code, get_json_object_string_field(object, "country_code", true)); TRY_RESULT(residence_country_code, get_json_object_string_field(object, "residence_country_code", true)); - TRY_STATUS(check_first_name(first_name)); - TRY_STATUS(check_middle_name(middle_name)); - TRY_STATUS(check_last_name(last_name)); + TRY_STATUS(check_name(first_name)); + TRY_STATUS(check_name(middle_name)); + TRY_STATUS(check_name(last_name)); + TRY_STATUS(check_name(native_first_name)); + TRY_STATUS(check_name(native_middle_name)); + TRY_STATUS(check_name(native_last_name)); TRY_RESULT(date, get_date_object(birthdate)); TRY_STATUS(check_gender(gender)); TRY_STATUS(check_country_code(country_code)); TRY_STATUS(check_country_code(residence_country_code)); - return td_api::make_object(std::move(first_name), std::move(middle_name), - std::move(last_name), std::move(date), std::move(gender), - std::move(country_code), std::move(residence_country_code)); + return td_api::make_object( + std::move(first_name), std::move(middle_name), std::move(last_name), std::move(native_first_name), + std::move(native_middle_name), std::move(native_last_name), std::move(date), std::move(gender), + std::move(country_code), std::move(residence_country_code)); } static Status check_document_number(string &number) { diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 0232fc61..4aadcc17 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -1093,7 +1093,8 @@ class CliClient final : public Actor { return make_tl_object(arg); } else if (passport_element_type == "pd") { return make_tl_object(make_tl_object( - "Mike", "Jr", "Towers", make_tl_object(29, 2, 2000), "male", "US", "GB")); + "Mike", "Jr", "Towers", u8"Mike\u2708", u8"Jr\u26fd", u8"Towers\u2757", + make_tl_object(29, 2, 2000), "male", "US", "GB")); } else if (passport_element_type == "driver_license" || passport_element_type == "dl") { if (input_files.size() >= 2) { auto front_side = std::move(input_files[0]);