diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 848cc8ab2..dc22622be 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -1002,14 +1002,14 @@ passportElementErrorSourceReverseSide = PassportElementErrorSource; //@description The selfie with the document contains an error. The error will be considered resolved when the file with the selfie changes passportElementErrorSourceSelfie = PassportElementErrorSource; -//@description One of files with the translation of the document contains an error. The error will be considered resolved when the file changes -passportElementErrorSourceTranslationFile = PassportElementErrorSource; +//@description One of files with the translation of the document contains an error. The error will be considered resolved when the file changes @file_index Index of a file with the error +passportElementErrorSourceTranslationFile file_index:int32 = PassportElementErrorSource; //@description The translation of the document contains an error. The error will be considered resolved when the list of translation files changes passportElementErrorSourceTranslationFiles = PassportElementErrorSource; -//@description The file contains an error. The error will be considered resolved when the file changes -passportElementErrorSourceFile = PassportElementErrorSource; +//@description The file contains an error. The error will be considered resolved when the file changes @file_index Index of a file with the error +passportElementErrorSourceFile file_index:int32 = PassportElementErrorSource; //@description The list of attached files contains an error. The error will be considered resolved when the list of files changes passportElementErrorSourceFiles = PassportElementErrorSource; diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index 5f2b8102d..e45e1d50d 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 b92ca27c2..f22deb267 100644 --- a/td/telegram/SecureManager.cpp +++ b/td/telegram/SecureManager.cpp @@ -690,6 +690,15 @@ class GetPassportAuthorizationForm : public NetQueryCallback { loop(); } + static int32 get_file_index(const vector &file_credentials, Slice file_hash) { + for (size_t i = 0; i < file_credentials.size(); i++) { + if (file_credentials[i].hash == file_hash) { + return narrow_cast(i); + } + } + return -1; + } + void loop() override { if (!secret_ || !authorization_form_) { return; @@ -732,6 +741,7 @@ class GetPassportAuthorizationForm : public NetQueryCallback { } std::vector values; + std::map all_credentials; for (auto suitable_type : all_types) { auto type = suitable_type.first; for (auto &value : authorization_form_->values_) { @@ -753,14 +763,15 @@ class GetPassportAuthorizationForm : public NetQueryCallback { send_closure(parent_, &SecureManager::on_get_secure_value, r_secure_value.ok()); - auto r_passport_element = - get_passport_element_object(file_manager, std::move(r_secure_value.move_as_ok().value)); + auto secure_value = r_secure_value.move_as_ok(); + auto r_passport_element = get_passport_element_object(file_manager, std::move(secure_value.value)); if (r_passport_element.is_error()) { LOG(ERROR) << "Failed to get passport element object: " << r_passport_element.error(); break; } - values.push_back(r_passport_element.move_as_ok()); + all_credentials.emplace(type, std::move(secure_value.credentials)); + break; } } @@ -794,7 +805,12 @@ class GetPassportAuthorizationForm : public NetQueryCallback { auto error = move_tl_object_as(error_ptr); type = get_secure_value_type(error->type_); message = std::move(error->text_); - source = td_api::make_object(); + int32 file_index = get_file_index(all_credentials[type].files, error->file_hash_.as_slice()); + if (file_index == -1) { + LOG(ERROR) << "Can't find file with error"; + break; + } + source = td_api::make_object(file_index); break; } case telegram_api::secureValueErrorFiles::ID: { @@ -829,7 +845,12 @@ class GetPassportAuthorizationForm : public NetQueryCallback { auto error = move_tl_object_as(error_ptr); type = get_secure_value_type(error->type_); message = std::move(error->text_); - source = td_api::make_object(); + int32 file_index = get_file_index(all_credentials[type].translations, error->file_hash_.as_slice()); + if (file_index == -1) { + LOG(ERROR) << "Can't find translation file with error"; + break; + } + source = td_api::make_object(file_index); break; } case telegram_api::secureValueErrorTranslationFiles::ID: {