diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 441fe7a4..d1607adc 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -926,20 +926,23 @@ passportAuthorizationForm id:int32 required_types:vector data: encryptedCredentials data:bytes hash:bytes secret:bytes = EncryptedCredentials; -//@description Contains information about an encrypted Telegram Passport data @type Telegram Passport data type @data Encrypted data about the user @files List of attached files @value Unencrypted data, phone number or email address @selfie Selfie with the document +//@description Contains information about an encrypted Telegram Passport data @type Telegram Passport data type @data Encrypted JSON-encoded data about the user @files List of attached files @value Unencrypted data, phone number or email address @selfie Selfie with the document encryptedPassportData type:PassportDataType data:bytes files:vector value:string selfie:file = EncryptedPassportData; //@class PassportDataError @description Contains description of an error in a Telegram Passport data; for bots only -//@description Some field value contains an error @type Data type @field_name Field name @hash Current field value hash @message Error message -passportDataErrorField type:PassportDataType field_name:string hash:bytes message:string = PassportDataError; +//@description A field of data contains an error. The error is considered resolved when the field's value changes @type Telegram Passport data type @field_name Field name @data_hash Current data hash @message Error message +passportDataErrorDataField type:PassportDataType field_name:string data_hash:bytes message:string = PassportDataError; -//@description Some files contain an error @type Data type @hashes Hashes of files with an error @message Error message -passportDataErrorFiles type:PassportDataType hashes:vector message:string = PassportDataError; +//@description A file contains an error. The error is considered resolved when the file changes @type Telegram Passport data type @file_hash Hash of the file with an error @message Error message +passportDataErrorFile type:PassportDataType file_hash:bytes message:string = PassportDataError; -//@description Selfie contains an error @type Data type @hash Current selfie hash @message Error message -passportDataErrorSelfie type:PassportDataType hash:bytes message:string = PassportDataError; +//@description A list of attached files contains an error. The error is considered resolved when the file list changes @type Telegram Passport data type @file_hashes Hashes of all files @message Error message +passportDataErrorFiles type:PassportDataType file_hashes:vector message:string = PassportDataError; + +//@description A selfie contains an error. The error is considered resolved when the file with the selfie changes @type Telegram Passport data type @file_hash Current file with the selfie hash @message Error message +passportDataErrorSelfie type:PassportDataType file_hash:bytes message:string = PassportDataError; //@class MessageContent @description Contains the content of a message diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index 7ec64431..820b763c 100644 Binary files a/td/generate/scheme/td_api.tlo and b/td/generate/scheme/td_api.tlo differ diff --git a/td/telegram/SecureManager.cpp b/td/telegram/SecureManager.cpp index 00499e77..8b116e6a 100644 --- a/td/telegram/SecureManager.cpp +++ b/td/telegram/SecureManager.cpp @@ -524,8 +524,8 @@ void SecureManager::set_secure_value_errors(Td *td, tl_object_ptrget_id()) { - case td_api::passportDataErrorField::ID: { - auto error = td_api::move_object_as(error_ptr); + case td_api::passportDataErrorDataField::ID: { + auto error = td_api::move_object_as(error_ptr); if (error->type_ == nullptr) { return promise.set_error(Status::Error(400, "Type must be non-empty")); } @@ -538,7 +538,21 @@ void SecureManager::set_secure_value_errors(Td *td, tl_object_ptrtype_)); input_errors.push_back(make_tl_object( - std::move(type), BufferSlice(error->hash_), error->field_name_, error->message_)); + std::move(type), BufferSlice(error->data_hash_), error->field_name_, error->message_)); + break; + } + case td_api::passportDataErrorFile::ID: { + auto error = td_api::move_object_as(error_ptr); + if (error->type_ == nullptr) { + return promise.set_error(Status::Error(400, "Type must be non-empty")); + } + if (!clean_input_string(error->message_)) { + return promise.set_error(Status::Error(400, "Error message must be encoded in UTF-8")); + } + + auto type = get_secure_value_type_object(get_secure_value_type_td_api(error->type_)); + input_errors.push_back(make_tl_object( + std::move(type), BufferSlice(error->file_hash_), error->message_)); break; } case td_api::passportDataErrorFiles::ID: { @@ -549,14 +563,14 @@ void SecureManager::set_secure_value_errors(Td *td, tl_object_ptrmessage_)) { return promise.set_error(Status::Error(400, "Error message must be encoded in UTF-8")); } - if (error->hashes_.empty()) { + if (error->file_hashes_.empty()) { return promise.set_error(Status::Error(400, "Error hashes must be non-empty")); } auto type = get_secure_value_type_object(get_secure_value_type_td_api(error->type_)); - auto hashes = transform(error->hashes_, [](Slice hash) { return BufferSlice(hash); }); - input_errors.push_back( - make_tl_object(std::move(type), std::move(hashes), error->message_)); + auto file_hashes = transform(error->file_hashes_, [](Slice hash) { return BufferSlice(hash); }); + input_errors.push_back(make_tl_object( + std::move(type), std::move(file_hashes), error->message_)); break; } case td_api::passportDataErrorSelfie::ID: { @@ -570,7 +584,7 @@ void SecureManager::set_secure_value_errors(Td *td, tl_object_ptrtype_)); input_errors.push_back(make_tl_object( - std::move(type), BufferSlice(error->hash_), error->message_)); + std::move(type), BufferSlice(error->file_hash_), error->message_)); break; } default: