Update Passport Data errors.

GitOrigin-RevId: fbf12ff23c5f6baf4696a05024edc2c9aa6970b6
This commit is contained in:
levlam 2018-04-17 20:53:25 +03:00
parent 9319cb981e
commit b4b9d19768
3 changed files with 32 additions and 15 deletions

View File

@ -926,20 +926,23 @@ passportAuthorizationForm id:int32 required_types:vector<PassportDataType> data:
encryptedCredentials data:bytes hash:bytes secret:bytes = EncryptedCredentials; 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<file> value:string selfie:file = EncryptedPassportData; encryptedPassportData type:PassportDataType data:bytes files:vector<file> value:string selfie:file = EncryptedPassportData;
//@class PassportDataError @description Contains description of an error in a Telegram Passport data; for bots only //@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 //@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
passportDataErrorField type:PassportDataType field_name:string hash:bytes message:string = PassportDataError; 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 //@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
passportDataErrorFiles type:PassportDataType hashes:vector<bytes> message:string = PassportDataError; passportDataErrorFile type:PassportDataType file_hash:bytes message:string = PassportDataError;
//@description Selfie contains an error @type Data type @hash Current selfie hash @message Error message //@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
passportDataErrorSelfie type:PassportDataType hash:bytes message:string = PassportDataError; passportDataErrorFiles type:PassportDataType file_hashes:vector<bytes> 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 //@class MessageContent @description Contains the content of a message

Binary file not shown.

View File

@ -524,8 +524,8 @@ void SecureManager::set_secure_value_errors(Td *td, tl_object_ptr<telegram_api::
return promise.set_error(Status::Error(400, "Error must be non-empty")); return promise.set_error(Status::Error(400, "Error must be non-empty"));
} }
switch (error_ptr->get_id()) { switch (error_ptr->get_id()) {
case td_api::passportDataErrorField::ID: { case td_api::passportDataErrorDataField::ID: {
auto error = td_api::move_object_as<td_api::passportDataErrorField>(error_ptr); auto error = td_api::move_object_as<td_api::passportDataErrorDataField>(error_ptr);
if (error->type_ == nullptr) { if (error->type_ == nullptr) {
return promise.set_error(Status::Error(400, "Type must be non-empty")); 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_ptr<telegram_api::
auto type = get_secure_value_type_object(get_secure_value_type_td_api(error->type_)); auto type = get_secure_value_type_object(get_secure_value_type_td_api(error->type_));
input_errors.push_back(make_tl_object<telegram_api::secureValueErrorData>( input_errors.push_back(make_tl_object<telegram_api::secureValueErrorData>(
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<td_api::passportDataErrorFile>(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<telegram_api::secureValueErrorFile>(
std::move(type), BufferSlice(error->file_hash_), error->message_));
break; break;
} }
case td_api::passportDataErrorFiles::ID: { case td_api::passportDataErrorFiles::ID: {
@ -549,14 +563,14 @@ void SecureManager::set_secure_value_errors(Td *td, tl_object_ptr<telegram_api::
if (!clean_input_string(error->message_)) { if (!clean_input_string(error->message_)) {
return promise.set_error(Status::Error(400, "Error message must be encoded in UTF-8")); 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")); 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 type = get_secure_value_type_object(get_secure_value_type_td_api(error->type_));
auto hashes = transform(error->hashes_, [](Slice hash) { return BufferSlice(hash); }); auto file_hashes = transform(error->file_hashes_, [](Slice hash) { return BufferSlice(hash); });
input_errors.push_back( input_errors.push_back(make_tl_object<telegram_api::secureValueErrorFiles>(
make_tl_object<telegram_api::secureValueErrorFiles>(std::move(type), std::move(hashes), error->message_)); std::move(type), std::move(file_hashes), error->message_));
break; break;
} }
case td_api::passportDataErrorSelfie::ID: { case td_api::passportDataErrorSelfie::ID: {
@ -570,7 +584,7 @@ void SecureManager::set_secure_value_errors(Td *td, tl_object_ptr<telegram_api::
auto type = get_secure_value_type_object(get_secure_value_type_td_api(error->type_)); auto type = get_secure_value_type_object(get_secure_value_type_td_api(error->type_));
input_errors.push_back(make_tl_object<telegram_api::secureValueErrorSelfie>( input_errors.push_back(make_tl_object<telegram_api::secureValueErrorSelfie>(
std::move(type), BufferSlice(error->hash_), error->message_)); std::move(type), BufferSlice(error->file_hash_), error->message_));
break; break;
} }
default: default: