From c4c9e51157bbb0f93617dd66bb846826289e2608 Mon Sep 17 00:00:00 2001 From: levlam Date: Sun, 15 Mar 2020 04:15:54 +0300 Subject: [PATCH] Make all fields required in full NetQueryCreator methos. GitOrigin-RevId: aa8ebb5cc46b9f3b7c0b606c012ace5fafe2bbf2 --- td/telegram/SecretChatActor.cpp | 3 ++- td/telegram/files/FileDownloader.cpp | 17 +++++++++-------- td/telegram/net/DcAuthManager.cpp | 3 ++- td/telegram/net/NetQueryCreator.h | 4 ++-- td/telegram/net/Session.cpp | 6 ++++-- 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/td/telegram/SecretChatActor.cpp b/td/telegram/SecretChatActor.cpp index d89a1926..71e295bc 100644 --- a/td/telegram/SecretChatActor.cpp +++ b/td/telegram/SecretChatActor.cpp @@ -71,7 +71,8 @@ SecretChatActor::SecretChatActor(int32 id, unique_ptr context, bool can template NetQueryPtr SecretChatActor::create_net_query(QueryType type, const T &function) { return context_->net_query_creator().create(UniqueId::next(UniqueId::Type::Default, static_cast(type)), - create_storer(function)); + create_storer(function), DcId::main(), NetQuery::Type::Common, + NetQuery::AuthFlag::On); } void SecretChatActor::update_chat(telegram_api::object_ptr chat) { diff --git a/td/telegram/files/FileDownloader.cpp b/td/telegram/files/FileDownloader.cpp index b3adea04..65b7d24d 100644 --- a/td/telegram/files/FileDownloader.cpp +++ b/td/telegram/files/FileDownloader.cpp @@ -235,6 +235,7 @@ Result> FileDownloader::start_part(Part part, int32 callback_->on_start_download(); + auto net_query_type = is_small_ ? NetQuery::Type::DownloadSmall : NetQuery::Type::Download; NetQueryPtr net_query; if (!use_cdn_) { int32 flags = 0; @@ -253,7 +254,7 @@ Result> FileDownloader::start_part(Part part, int32 : create_storer(telegram_api::upload_getFile(flags, false /*ignored*/, false /*ignored*/, remote_.as_input_file_location(), static_cast(part.offset), static_cast(size))), - dc_id, is_small_ ? NetQuery::Type::DownloadSmall : NetQuery::Type::Download); + dc_id, net_query_type, NetQuery::AuthFlag::On); } else { if (remote_.is_web()) { return Status::Error("Can't download web file from CDN"); @@ -264,15 +265,15 @@ Result> FileDownloader::start_part(Part part, int32 static_cast(size)); cdn_part_file_token_generation_[part.id] = cdn_file_token_generation_; LOG(DEBUG) << part.id << " " << to_string(query); - net_query = G()->net_query_creator().create( - UniqueId::next(UniqueId::Type::Default, static_cast(QueryType::CDN)), create_storer(query), cdn_dc_id_, - is_small_ ? NetQuery::Type::DownloadSmall : NetQuery::Type::Download, NetQuery::AuthFlag::Off); + net_query = + G()->net_query_creator().create(UniqueId::next(UniqueId::Type::Default, static_cast(QueryType::CDN)), + create_storer(query), cdn_dc_id_, net_query_type, NetQuery::AuthFlag::Off); } else { auto query = telegram_api::upload_reuploadCdnFile(BufferSlice(cdn_file_token_), BufferSlice(it->second)); 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); + remote_.get_dc_id(), net_query_type, NetQuery::AuthFlag::On); cdn_part_reupload_token_.erase(it); } } @@ -464,9 +465,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); + auto net_query_type = is_small_ ? NetQuery::Type::DownloadSmall : NetQuery::Type::Download; + auto net_query = G()->net_query_creator().create(create_storer(query), remote_.get_dc_id(), net_query_type, + NetQuery::AuthFlag::On); info.queries.push_back(std::move(net_query)); break; } diff --git a/td/telegram/net/DcAuthManager.cpp b/td/telegram/net/DcAuthManager.cpp index 57b507dd..8d167f6c 100644 --- a/td/telegram/net/DcAuthManager.cpp +++ b/td/telegram/net/DcAuthManager.cpp @@ -172,7 +172,8 @@ void DcAuthManager::dc_loop(DcInfo &dc) { VLOG(dc) << "Send exportAuthorization to " << dc.dc_id; auto id = UniqueId::next(); auto query = G()->net_query_creator().create( - id, create_storer(telegram_api::auth_exportAuthorization(dc.dc_id.get_raw_id()))); + id, create_storer(telegram_api::auth_exportAuthorization(dc.dc_id.get_raw_id())), DcId::main(), + NetQuery::Type::Common, NetQuery::AuthFlag::On); query->total_timeout_limit = 60 * 60 * 24; G()->net_query_dispatcher().dispatch_with_callback(std::move(query), actor_shared(this, dc.dc_id.get_raw_id())); dc.wait_id = id; diff --git a/td/telegram/net/NetQueryCreator.h b/td/telegram/net/NetQueryCreator.h index 98fd1e21..455b6e7c 100644 --- a/td/telegram/net/NetQueryCreator.h +++ b/td/telegram/net/NetQueryCreator.h @@ -38,8 +38,8 @@ class NetQueryCreator { NetQuery::AuthFlag auth_flag = NetQuery::AuthFlag::On) { return create(UniqueId::next(), storer, dc_id, type, auth_flag); } - Ptr create(uint64 id, const Storer &storer, DcId dc_id = DcId::main(), NetQuery::Type type = NetQuery::Type::Common, - NetQuery::AuthFlag auth_flag = NetQuery::AuthFlag::On); + + Ptr create(uint64 id, const Storer &storer, DcId dc_id, NetQuery::Type type, NetQuery::AuthFlag auth_flag); private: ObjectPool object_pool_; diff --git a/td/telegram/net/Session.cpp b/td/telegram/net/Session.cpp index 391e189e..0b4e3ab0 100644 --- a/td/telegram/net/Session.cpp +++ b/td/telegram/net/Session.cpp @@ -1106,7 +1106,8 @@ bool Session::connection_send_check_main_key(ConnectionInfo *info) { being_checked_main_auth_key_id_ = key_id; last_check_query_id_ = UniqueId::next(UniqueId::BindKey); NetQueryPtr query = - G()->net_query_creator().create(last_check_query_id_, create_storer(telegram_api::help_getNearestDc())); + G()->net_query_creator().create(last_check_query_id_, create_storer(telegram_api::help_getNearestDc()), + DcId::main(), NetQuery::Type::Common, NetQuery::AuthFlag::On); query->dispatch_ttl = 0; query->set_callback(actor_shared(this)); connection_send_query(info, std::move(query)); @@ -1142,7 +1143,8 @@ bool Session::connection_send_bind_key(ConnectionInfo *info) { LOG(INFO) << "Bind key: " << tag("tmp", key_id) << tag("perm", static_cast(perm_auth_key_id)); NetQueryPtr query = G()->net_query_creator().create( last_bind_query_id_, - create_storer(telegram_api::auth_bindTempAuthKey(perm_auth_key_id, nonce, expires_at, std::move(encrypted)))); + create_storer(telegram_api::auth_bindTempAuthKey(perm_auth_key_id, nonce, expires_at, std::move(encrypted))), + DcId::main(), NetQuery::Type::Common, NetQuery::AuthFlag::On); query->dispatch_ttl = 0; query->set_callback(actor_shared(this)); connection_send_query(info, std::move(query), message_id);