Make all fields required in full NetQueryCreator methos.

GitOrigin-RevId: aa8ebb5cc46b9f3b7c0b606c012ace5fafe2bbf2
This commit is contained in:
levlam 2020-03-15 04:15:54 +03:00
parent 0d08895871
commit c4c9e51157
5 changed files with 19 additions and 14 deletions

View File

@ -71,7 +71,8 @@ SecretChatActor::SecretChatActor(int32 id, unique_ptr<Context> context, bool can
template <class T>
NetQueryPtr SecretChatActor::create_net_query(QueryType type, const T &function) {
return context_->net_query_creator().create(UniqueId::next(UniqueId::Type::Default, static_cast<uint8>(type)),
create_storer(function));
create_storer(function), DcId::main(), NetQuery::Type::Common,
NetQuery::AuthFlag::On);
}
void SecretChatActor::update_chat(telegram_api::object_ptr<telegram_api::EncryptedChat> chat) {

View File

@ -235,6 +235,7 @@ Result<std::pair<NetQueryPtr, bool>> 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<std::pair<NetQueryPtr, bool>> FileDownloader::start_part(Part part, int32
: create_storer(telegram_api::upload_getFile(flags, false /*ignored*/, false /*ignored*/,
remote_.as_input_file_location(),
static_cast<int32>(part.offset), static_cast<int32>(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<std::pair<NetQueryPtr, bool>> FileDownloader::start_part(Part part, int32
static_cast<int32>(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<uint8>(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<uint8>(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<uint8>(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<FileLoader::CheckInfo> FileDownloader::check_loop(int64 checked_prefix_si
has_hash_query_ = true;
auto query =
telegram_api::upload_getFileHashes(remote_.as_input_file_location(), narrow_cast<int32>(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;
}

View File

@ -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;

View File

@ -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<NetQuery> object_pool_;

View File

@ -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<uint64>(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);