From 2714fbf1f883552c95778f813f673bab80c98d6c Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 13 Dec 2019 04:00:33 +0300 Subject: [PATCH] Fix some preauthentication requests. GitOrigin-RevId: 1bbbbef17b740140ae99c4972d569306f6ca52ac --- td/generate/scheme/td_api.tl | 2 +- td/telegram/PasswordManager.cpp | 2 ++ td/telegram/Payments.cpp | 4 ++-- td/telegram/Td.cpp | 7 +++++-- td/telegram/TermsOfService.cpp | 1 + td/telegram/files/FileDownloader.cpp | 9 ++++----- td/telegram/net/PublicRsaKeyWatchdog.cpp | 2 +- td/telegram/net/TempAuthKeyWatchdog.h | 3 ++- 8 files changed, 18 insertions(+), 12 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 41c67700..db3aea4f 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -4168,7 +4168,7 @@ sendCustomRequest method:string parameters:string = CustomRequestResult; answerCustomQuery custom_query_id:int64 data:string = Ok; -//@description Sends a request to TON lite server through Telegram servers @request The request +//@description Sends a request to TON lite server through Telegram servers. Can be called before authorization @request The request sendTonLiteServerRequest request:bytes = TonLiteServerResponse; //@description Returns a salt to be used with locally stored password to access a local TON-based wallet diff --git a/td/telegram/PasswordManager.cpp b/td/telegram/PasswordManager.cpp index 872cc616..bd278ffb 100644 --- a/td/telegram/PasswordManager.cpp +++ b/td/telegram/PasswordManager.cpp @@ -465,6 +465,7 @@ void PasswordManager::check_email_address_verification_code(string code, Promise void PasswordManager::request_password_recovery( Promise> promise) { + // is called only after authoriation send_with_promise( G()->net_query_creator().create(create_storer(telegram_api::auth_requestPasswordRecovery())), PromiseCreator::lambda([promise = std::move(promise)](Result r_query) mutable { @@ -478,6 +479,7 @@ void PasswordManager::request_password_recovery( } void PasswordManager::recover_password(string code, Promise promise) { + // is called only after authoriation send_with_promise(G()->net_query_creator().create(create_storer(telegram_api::auth_recoverPassword(std::move(code)))), PromiseCreator::lambda( [actor_id = actor_id(this), promise = std::move(promise)](Result r_query) mutable { diff --git a/td/telegram/Payments.cpp b/td/telegram/Payments.cpp index aded5026..b7c4f93e 100644 --- a/td/telegram/Payments.cpp +++ b/td/telegram/Payments.cpp @@ -495,8 +495,8 @@ class SendLiteRequestQuery : public Td::ResultHandler { } void send(BufferSlice request) { - send_query( - G()->net_query_creator().create(create_storer(telegram_api::wallet_sendLiteRequest(std::move(request))))); + send_query(G()->net_query_creator().create(create_storer(telegram_api::wallet_sendLiteRequest(std::move(request))), + DcId::main(), NetQuery::Type::Common, NetQuery::AuthFlag::Off)); } void on_result(uint64 id, BufferSlice packet) override { diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index d60465a5..825ecc86 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -477,7 +477,8 @@ class GetAppConfigQuery : public Td::ResultHandler { } void send() { - send_query(G()->net_query_creator().create(create_storer(telegram_api::help_getAppConfig()))); + send_query(G()->net_query_creator().create(create_storer(telegram_api::help_getAppConfig()), DcId::main(), + NetQuery::Type::Common, NetQuery::AuthFlag::Off)); } void on_result(uint64 id, BufferSlice packet) override { @@ -508,7 +509,8 @@ class SaveAppLogQuery : public Td::ResultHandler { input_app_events.push_back( make_tl_object(G()->server_time_cached(), type, peer_id, std::move(data))); send_query( - G()->net_query_creator().create(create_storer(telegram_api::help_saveAppLog(std::move(input_app_events))))); + G()->net_query_creator().create(create_storer(telegram_api::help_saveAppLog(std::move(input_app_events))), + DcId::main(), NetQuery::Type::Common, NetQuery::AuthFlag::Off)); } void on_result(uint64 id, BufferSlice packet) override { @@ -3504,6 +3506,7 @@ bool Td::is_preauthentication_request(int32 id) { case td_api::setCustomLanguagePackString::ID: case td_api::deleteLanguagePack::ID: case td_api::processPushNotification::ID: + case td_api::sendTonLiteServerRequest::ID: case td_api::getOption::ID: case td_api::setOption::ID: case td_api::getStorageStatistics::ID: diff --git a/td/telegram/TermsOfService.cpp b/td/telegram/TermsOfService.cpp index 687783c7..fc766fc1 100644 --- a/td/telegram/TermsOfService.cpp +++ b/td/telegram/TermsOfService.cpp @@ -26,6 +26,7 @@ class GetTermsOfServiceUpdateQuery : public Td::ResultHandler { } void send() { + // we don't poll terms of service before authorization send_query(G()->net_query_creator().create(create_storer(telegram_api::help_getTermsOfServiceUpdate()))); } diff --git a/td/telegram/files/FileDownloader.cpp b/td/telegram/files/FileDownloader.cpp index 094f2d0c..76fc550c 100644 --- a/td/telegram/files/FileDownloader.cpp +++ b/td/telegram/files/FileDownloader.cpp @@ -261,8 +261,7 @@ Result> FileDownloader::start_part(Part part, int32 LOG(DEBUG) << part.id << " " << to_string(query); net_query = G()->net_query_creator().create( UniqueId::next(UniqueId::Type::Default, static_cast(QueryType::ReuploadCDN)), create_storer(query), - remote_.get_dc_id(), is_small_ ? NetQuery::Type::DownloadSmall : NetQuery::Type::Download, - NetQuery::AuthFlag::On); + remote_.get_dc_id(), is_small_ ? NetQuery::Type::DownloadSmall : NetQuery::Type::Download); cdn_part_reupload_token_.erase(it); } } @@ -452,9 +451,9 @@ Result FileDownloader::check_loop(int64 checked_prefix_si has_hash_query_ = true; auto query = telegram_api::upload_getFileHashes(remote_.as_input_file_location(), narrow_cast(checked_prefix_size)); - auto net_query = G()->net_query_creator().create( - create_storer(query), remote_.get_dc_id(), - is_small_ ? NetQuery::Type::DownloadSmall : NetQuery::Type::Download, NetQuery::AuthFlag::On); + auto net_query = + G()->net_query_creator().create(create_storer(query), remote_.get_dc_id(), + is_small_ ? NetQuery::Type::DownloadSmall : NetQuery::Type::Download); info.queries.push_back(std::move(net_query)); break; } diff --git a/td/telegram/net/PublicRsaKeyWatchdog.cpp b/td/telegram/net/PublicRsaKeyWatchdog.cpp index 306b0947..713e2467 100644 --- a/td/telegram/net/PublicRsaKeyWatchdog.cpp +++ b/td/telegram/net/PublicRsaKeyWatchdog.cpp @@ -70,7 +70,7 @@ void PublicRsaKeyWatchdog::loop() { has_query_ = true; G()->net_query_dispatcher().dispatch_with_callback( G()->net_query_creator().create(create_storer(telegram_api::help_getCdnConfig()), DcId::main(), - NetQuery::Type::Common, NetQuery::AuthFlag::Off, NetQuery::GzipFlag::On, + NetQuery::Type::Common, NetQuery::AuthFlag::On, NetQuery::GzipFlag::On, 60 * 60 * 24), actor_shared(this)); } diff --git a/td/telegram/net/TempAuthKeyWatchdog.h b/td/telegram/net/TempAuthKeyWatchdog.h index e7c9681e..d25062c2 100644 --- a/td/telegram/net/TempAuthKeyWatchdog.h +++ b/td/telegram/net/TempAuthKeyWatchdog.h @@ -110,7 +110,8 @@ class TempAuthKeyWatchdog : public NetQueryCallback { return; } LOG(WARNING) << "Start auth_dropTempAuthKeys except keys " << format::as_array(ids); - auto query = G()->net_query_creator().create(create_storer(telegram_api::auth_dropTempAuthKeys(std::move(ids)))); + auto query = G()->net_query_creator().create(create_storer(telegram_api::auth_dropTempAuthKeys(std::move(ids))), + DcId::main(), NetQuery::Type::Common, NetQuery::AuthFlag::Off); G()->net_query_dispatcher().dispatch_with_callback(std::move(query), actor_shared(this)); }