Simplify NetQuery creation.

GitOrigin-RevId: a01e72f8e196b405dd28dfd75d16cadc7127ec4a
This commit is contained in:
levlam 2020-03-16 00:17:11 +03:00
parent 2bd330a5aa
commit b8848a2ab4
30 changed files with 393 additions and 435 deletions

View File

@ -45,7 +45,7 @@ class GetSavedGifsQuery : public Td::ResultHandler {
void send(bool is_repair, int32 hash) {
is_repair_ = is_repair;
LOG(INFO) << "Send get saved animations request with hash = " << hash;
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_getSavedGifs(hash))));
send_query(G()->net_query_creator().create(telegram_api::messages_getSavedGifs(hash)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -83,8 +83,7 @@ class SaveGifQuery : public Td::ResultHandler {
file_id_ = file_id;
file_reference_ = input_document->file_reference_.as_slice().str();
unsave_ = unsave;
send_query(G()->net_query_creator().create(
create_storer(telegram_api::messages_saveGif(std::move(input_document), unsave))));
send_query(G()->net_query_creator().create(telegram_api::messages_saveGif(std::move(input_document), unsave)));
}
void on_result(uint64 id, BufferSlice packet) override {

View File

@ -69,7 +69,7 @@ AuthManager::AuthManager(int32 api_id, const string &api_hash, ActorShared<> par
void AuthManager::start_up() {
if (state_ == State::LoggingOut) {
start_net_query(NetQueryType::LogOut, G()->net_query_creator().create(create_storer(telegram_api::auth_logOut())));
start_net_query(NetQueryType::LogOut, G()->net_query_creator().create(telegram_api::auth_logOut()));
} else if (state_ == State::DestroyingKeys) {
destroy_auth_keys();
}
@ -369,7 +369,7 @@ void AuthManager::logout(uint64 query_id) {
LOG(INFO) << "Logging out";
G()->td_db()->get_binlog_pmc()->set("auth", "logout");
update_state(State::LoggingOut);
start_net_query(NetQueryType::LogOut, G()->net_query_creator().create(create_storer(telegram_api::auth_logOut())));
start_net_query(NetQueryType::LogOut, G()->net_query_creator().create(telegram_api::auth_logOut()));
}
}

View File

@ -39,7 +39,7 @@ class GetAutoDownloadSettingsQuery : public Td::ResultHandler {
}
void send() {
send_query(G()->net_query_creator().create(create_storer(telegram_api::account_getAutoDownloadSettings())));
send_query(G()->net_query_creator().create(telegram_api::account_getAutoDownloadSettings()));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -94,8 +94,8 @@ class SaveAutoDownloadSettingsQuery : public Td::ResultHandler {
if (type == NetType::WiFi) {
flags |= telegram_api::account_saveAutoDownloadSettings::HIGH_MASK;
}
send_query(G()->net_query_creator().create(create_storer(telegram_api::account_saveAutoDownloadSettings(
flags, false /*ignored*/, false /*ignored*/, get_input_auto_download_settings(settings)))));
send_query(G()->net_query_creator().create(telegram_api::account_saveAutoDownloadSettings(
flags, false /*ignored*/, false /*ignored*/, get_input_auto_download_settings(settings))));
}
void on_result(uint64 id, BufferSlice packet) override {

View File

@ -51,8 +51,7 @@ class GetBackgroundQuery : public Td::ResultHandler {
background_id_ = background_id;
background_name_ = background_name;
LOG(INFO) << "Load " << background_id_ << "/" << background_name_ << " from server: " << to_string(input_wallpaper);
send_query(
G()->net_query_creator().create(create_storer(telegram_api::account_getWallPaper(std::move(input_wallpaper)))));
send_query(G()->net_query_creator().create(telegram_api::account_getWallPaper(std::move(input_wallpaper))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -81,7 +80,7 @@ class GetBackgroundsQuery : public Td::ResultHandler {
}
void send() {
send_query(G()->net_query_creator().create(create_storer(telegram_api::account_getWallPapers(0))));
send_query(G()->net_query_creator().create(telegram_api::account_getWallPapers(0)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -106,9 +105,9 @@ class InstallBackgroundQuery : public Td::ResultHandler {
}
void send(BackgroundId background_id, int64 access_hash, const BackgroundType &type) {
send_query(G()->net_query_creator().create(create_storer(telegram_api::account_installWallPaper(
send_query(G()->net_query_creator().create(telegram_api::account_installWallPaper(
telegram_api::make_object<telegram_api::inputWallPaper>(background_id.get(), access_hash),
get_input_wallpaper_settings(type)))));
get_input_wallpaper_settings(type))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -143,8 +142,8 @@ class UploadBackgroundQuery : public Td::ResultHandler {
type_ = type;
for_dark_theme_ = for_dark_theme;
string mime_type = type.type == BackgroundType::Type::Pattern ? "image/png" : "image/jpeg";
send_query(G()->net_query_creator().create(create_storer(
telegram_api::account_uploadWallPaper(std::move(input_file), mime_type, get_input_wallpaper_settings(type)))));
send_query(G()->net_query_creator().create(
telegram_api::account_uploadWallPaper(std::move(input_file), mime_type, get_input_wallpaper_settings(type))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -181,9 +180,9 @@ class SaveBackgroundQuery : public Td::ResultHandler {
}
void send(BackgroundId background_id, int64 access_hash, const BackgroundType &type, bool unsave) {
send_query(G()->net_query_creator().create(create_storer(telegram_api::account_saveWallPaper(
send_query(G()->net_query_creator().create(telegram_api::account_saveWallPaper(
telegram_api::make_object<telegram_api::inputWallPaper>(background_id.get(), access_hash), unsave,
get_input_wallpaper_settings(type)))));
get_input_wallpaper_settings(type))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -213,7 +212,7 @@ class ResetBackgroundsQuery : public Td::ResultHandler {
}
void send() {
send_query(G()->net_query_creator().create(create_storer(telegram_api::account_resetWallPapers())));
send_query(G()->net_query_creator().create(telegram_api::account_resetWallPapers()));
}
void on_result(uint64 id, BufferSlice packet) override {

View File

@ -237,7 +237,7 @@ void CallActor::rate_call(int32 rating, string comment, vector<td_api::object_pt
auto tl_query = telegram_api::phone_setCallRating(0, false /*ignored*/, get_input_phone_call("rate_call"), rating,
std::move(comment));
auto query = G()->net_query_creator().create(create_storer(tl_query));
auto query = G()->net_query_creator().create(tl_query);
send_with_promise(std::move(query), PromiseCreator::lambda([actor_id = actor_id(this)](NetQueryPtr net_query) {
send_closure(actor_id, &CallActor::on_set_rating_query_result, std::move(net_query));
}));
@ -260,7 +260,7 @@ void CallActor::send_call_debug_information(string data, Promise<> promise) {
promise.set_value(Unit());
auto tl_query = telegram_api::phone_saveCallDebug(get_input_phone_call("send_call_debug_information"),
make_tl_object<telegram_api::dataJSON>(std::move(data)));
auto query = G()->net_query_creator().create(create_storer(tl_query));
auto query = G()->net_query_creator().create(tl_query);
send_with_promise(std::move(query), PromiseCreator::lambda([actor_id = actor_id(this)](NetQueryPtr net_query) {
send_closure(actor_id, &CallActor::on_set_debug_query_result, std::move(net_query));
}));
@ -510,7 +510,7 @@ void CallActor::do_load_dh_config(Promise<std::shared_ptr<DhConfig>> promise) {
}
int random_length = 0;
telegram_api::messages_getDhConfig tl_query(version, random_length);
auto query = G()->net_query_creator().create(create_storer(tl_query));
auto query = G()->net_query_creator().create(tl_query);
send_with_promise(std::move(query),
PromiseCreator::lambda([actor_id = actor_id(this), old_dh_config = std::move(dh_config),
promise = std::move(promise)](Result<NetQueryPtr> result_query) mutable {
@ -540,7 +540,7 @@ void CallActor::do_load_dh_config(Promise<std::shared_ptr<DhConfig>> promise) {
void CallActor::send_received_query() {
auto tl_query = telegram_api::phone_receivedCall(get_input_phone_call("send_received_query"));
auto query = G()->net_query_creator().create(create_storer(tl_query));
auto query = G()->net_query_creator().create(tl_query);
send_with_promise(std::move(query), PromiseCreator::lambda([actor_id = actor_id(this)](NetQueryPtr net_query) {
send_closure(actor_id, &CallActor::on_received_query_result, std::move(net_query));
}));
@ -567,7 +567,7 @@ void CallActor::try_send_request_query() {
auto tl_query = telegram_api::phone_requestCall(flags, false /*ignored*/, std::move(input_user_),
Random::secure_int32(), BufferSlice(dh_handshake_.get_g_b_hash()),
call_state_.protocol.as_telegram_api());
auto query = G()->net_query_creator().create(create_storer(tl_query));
auto query = G()->net_query_creator().create(tl_query);
state_ = State::WaitRequestResult;
int32 call_receive_timeout_ms = G()->shared_config().get_option_integer("call_receive_timeout_ms", 20000);
double timeout = call_receive_timeout_ms * 0.001;
@ -602,7 +602,7 @@ void CallActor::try_send_accept_query() {
auto tl_query =
telegram_api::phone_acceptCall(get_input_phone_call("try_send_accept_query"),
BufferSlice(dh_handshake_.get_g_b()), call_state_.protocol.as_telegram_api());
auto query = G()->net_query_creator().create(create_storer(tl_query));
auto query = G()->net_query_creator().create(tl_query);
state_ = State::WaitAcceptResult;
send_with_promise(std::move(query), PromiseCreator::lambda([actor_id = actor_id(this)](NetQueryPtr net_query) {
send_closure(actor_id, &CallActor::on_accept_query_result, std::move(net_query));
@ -626,7 +626,7 @@ void CallActor::try_send_confirm_query() {
auto tl_query = telegram_api::phone_confirmCall(get_input_phone_call("try_send_confirm_query"),
BufferSlice(dh_handshake_.get_g_b()), call_state_.key_fingerprint,
call_state_.protocol.as_telegram_api());
auto query = G()->net_query_creator().create(create_storer(tl_query));
auto query = G()->net_query_creator().create(tl_query);
state_ = State::WaitConfirmResult;
send_with_promise(std::move(query), PromiseCreator::lambda([actor_id = actor_id(this)](NetQueryPtr net_query) {
send_closure(actor_id, &CallActor::on_confirm_query_result, std::move(net_query));
@ -656,7 +656,7 @@ void CallActor::try_send_discard_query() {
auto tl_query = telegram_api::phone_discardCall(
flags, false /*ignored*/, get_input_phone_call("try_send_discard_query"), duration_,
get_input_phone_call_discard_reason(call_state_.discard_reason), connection_id_);
auto query = G()->net_query_creator().create(create_storer(tl_query));
auto query = G()->net_query_creator().create(tl_query);
state_ = State::WaitDiscardResult;
send_with_promise(std::move(query), PromiseCreator::lambda([actor_id = actor_id(this)](NetQueryPtr net_query) {
send_closure(actor_id, &CallActor::on_discard_query_result, std::move(net_query));
@ -705,7 +705,7 @@ void CallActor::flush_call_state() {
void CallActor::start_up() {
auto tl_query = telegram_api::phone_getCallConfig();
auto query = G()->net_query_creator().create(create_storer(tl_query));
auto query = G()->net_query_creator().create(tl_query);
send_with_promise(std::move(query), PromiseCreator::lambda([actor_id = actor_id(this)](NetQueryPtr net_query) {
send_closure(actor_id, &CallActor::on_get_call_config_result, std::move(net_query));
}));

View File

@ -61,8 +61,8 @@ class GetBotCallbackAnswerQuery : public Td::ResultHandler {
UNREACHABLE();
}
auto net_query = G()->net_query_creator().create(create_storer(telegram_api::messages_getBotCallbackAnswer(
flags, false /*ignored*/, std::move(input_peer), message_id.get_server_message_id().get(), std::move(data))));
auto net_query = G()->net_query_creator().create(telegram_api::messages_getBotCallbackAnswer(
flags, false /*ignored*/, std::move(input_peer), message_id.get_server_message_id().get(), std::move(data)));
net_query->need_resend_on_503 = false;
send_query(std::move(net_query));
}
@ -95,8 +95,8 @@ class SetBotCallbackAnswerQuery : public Td::ResultHandler {
}
void send(int32 flags, int64 callback_query_id, const string &text, const string &url, int32 cache_time) {
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_setBotCallbackAnswer(
flags, false /*ignored*/, callback_query_id, text, url, cache_time))));
send_query(G()->net_query_creator().create(telegram_api::messages_setBotCallbackAnswer(
flags, false /*ignored*/, callback_query_id, text, url, cache_time)));
}
void on_result(uint64 id, BufferSlice packet) override {

View File

@ -950,8 +950,7 @@ void ConfigManager::get_content_settings(Promise<Unit> &&promise) {
get_content_settings_queries_.push_back(std::move(promise));
if (get_content_settings_queries_.size() == 1) {
G()->net_query_dispatcher().dispatch_with_callback(
G()->net_query_creator().create(create_storer(telegram_api::account_getContentSettings())),
actor_shared(this, 2));
G()->net_query_creator().create(telegram_api::account_getContentSettings()), actor_shared(this, 2));
}
}
@ -970,8 +969,7 @@ void ConfigManager::set_content_settings(bool ignore_sensitive_content_restricti
flags |= telegram_api::account_setContentSettings::SENSITIVE_ENABLED_MASK;
}
G()->net_query_dispatcher().dispatch_with_callback(
G()->net_query_creator().create(
create_storer(telegram_api::account_setContentSettings(flags, false /*ignored*/))),
G()->net_query_creator().create(telegram_api::account_setContentSettings(flags, false /*ignored*/)),
actor_shared(this, 3 + static_cast<uint64>(ignore_sensitive_content_restrictions)));
}
}

View File

@ -74,7 +74,7 @@ class SetAccountTtlQuery : public Td::ResultHandler {
void send(int32 account_ttl) {
send_query(G()->net_query_creator().create(
create_storer(telegram_api::account_setAccountTTL(make_tl_object<telegram_api::accountDaysTTL>(account_ttl)))));
telegram_api::account_setAccountTTL(make_tl_object<telegram_api::accountDaysTTL>(account_ttl))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -104,7 +104,7 @@ class GetAccountTtlQuery : public Td::ResultHandler {
}
void send() {
send_query(G()->net_query_creator().create(create_storer(telegram_api::account_getAccountTTL())));
send_query(G()->net_query_creator().create(telegram_api::account_getAccountTTL()));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -133,8 +133,7 @@ class AcceptLoginTokenQuery : public Td::ResultHandler {
}
void send(const string &login_token) {
send_query(
G()->net_query_creator().create(create_storer(telegram_api::auth_acceptLoginToken(BufferSlice(login_token)))));
send_query(G()->net_query_creator().create(telegram_api::auth_acceptLoginToken(BufferSlice(login_token))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -160,7 +159,7 @@ class GetAuthorizationsQuery : public Td::ResultHandler {
}
void send() {
send_query(G()->net_query_creator().create(create_storer(telegram_api::account_getAuthorizations())));
send_query(G()->net_query_creator().create(telegram_api::account_getAuthorizations()));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -201,8 +200,7 @@ class ResetAuthorizationQuery : public Td::ResultHandler {
}
void send(int64 authorization_id) {
send_query(
G()->net_query_creator().create(create_storer(telegram_api::account_resetAuthorization(authorization_id))));
send_query(G()->net_query_creator().create(telegram_api::account_resetAuthorization(authorization_id)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -229,7 +227,7 @@ class ResetAuthorizationsQuery : public Td::ResultHandler {
}
void send() {
send_query(G()->net_query_creator().create(create_storer(telegram_api::auth_resetAuthorizations())));
send_query(G()->net_query_creator().create(telegram_api::auth_resetAuthorizations()));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -258,7 +256,7 @@ class GetWebAuthorizationsQuery : public Td::ResultHandler {
}
void send() {
send_query(G()->net_query_creator().create(create_storer(telegram_api::account_getWebAuthorizations())));
send_query(G()->net_query_creator().create(telegram_api::account_getWebAuthorizations()));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -305,7 +303,7 @@ class ResetWebAuthorizationQuery : public Td::ResultHandler {
}
void send(int64 hash) {
send_query(G()->net_query_creator().create(create_storer(telegram_api::account_resetWebAuthorization(hash))));
send_query(G()->net_query_creator().create(telegram_api::account_resetWebAuthorization(hash)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -332,7 +330,7 @@ class ResetWebAuthorizationsQuery : public Td::ResultHandler {
}
void send() {
send_query(G()->net_query_creator().create(create_storer(telegram_api::account_resetWebAuthorizations())));
send_query(G()->net_query_creator().create(telegram_api::account_resetWebAuthorizations()));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -362,9 +360,9 @@ class SetUserIsBlockedQuery : public Td::ResultHandler {
void send(UserId user_id, tl_object_ptr<telegram_api::InputUser> &&input_user, bool is_blocked) {
user_id_ = user_id;
if (is_blocked) {
send_query(G()->net_query_creator().create(create_storer(telegram_api::contacts_block(std::move(input_user)))));
send_query(G()->net_query_creator().create(telegram_api::contacts_block(std::move(input_user))));
} else {
send_query(G()->net_query_creator().create(create_storer(telegram_api::contacts_unblock(std::move(input_user)))));
send_query(G()->net_query_creator().create(telegram_api::contacts_unblock(std::move(input_user))));
}
}
@ -402,7 +400,7 @@ class GetBlockedUsersQuery : public Td::ResultHandler {
limit_ = limit;
random_id_ = random_id;
send_query(G()->net_query_creator().create(create_storer(telegram_api::contacts_getBlocked(offset, limit))));
send_query(G()->net_query_creator().create(telegram_api::contacts_getBlocked(offset, limit)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -450,7 +448,7 @@ class GetContactsQuery : public Td::ResultHandler {
public:
void send(int32 hash) {
LOG(INFO) << "Reload contacts with hash " << hash;
send_query(G()->net_query_creator().create(create_storer(telegram_api::contacts_getContacts(hash))));
send_query(G()->net_query_creator().create(telegram_api::contacts_getContacts(hash)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -474,7 +472,7 @@ class GetContactsStatusesQuery : public Td::ResultHandler {
public:
void send() {
LOG(INFO) << "Reload contacts statuses";
send_query(G()->net_query_creator().create(create_storer(telegram_api::contacts_getStatuses())));
send_query(G()->net_query_creator().create(telegram_api::contacts_getStatuses()));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -508,8 +506,8 @@ class AddContactQuery : public Td::ResultHandler {
if (share_phone_number) {
flags |= telegram_api::contacts_addContact::ADD_PHONE_PRIVACY_EXCEPTION_MASK;
}
send_query(G()->net_query_creator().create(create_storer(telegram_api::contacts_addContact(
flags, false /*ignored*/, std::move(input_user), first_name, last_name, phone_number))));
send_query(G()->net_query_creator().create(telegram_api::contacts_addContact(
flags, false /*ignored*/, std::move(input_user), first_name, last_name, phone_number)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -542,8 +540,7 @@ class AcceptContactQuery : public Td::ResultHandler {
void send(UserId user_id, tl_object_ptr<telegram_api::InputUser> &&input_user) {
user_id_ = user_id;
send_query(
G()->net_query_creator().create(create_storer(telegram_api::contacts_acceptContact(std::move(input_user)))));
send_query(G()->net_query_creator().create(telegram_api::contacts_acceptContact(std::move(input_user))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -598,8 +595,7 @@ class ImportContactsQuery : public Td::ResultHandler {
contacts.push_back(input_contacts_[i].get_input_phone_contact(static_cast<int64>(i)));
}
send_query(
G()->net_query_creator().create(create_storer(telegram_api::contacts_importContacts(std::move(contacts)))));
send_query(G()->net_query_creator().create(telegram_api::contacts_importContacts(std::move(contacts))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -648,8 +644,7 @@ class ImportContactsQuery : public Td::ResultHandler {
contacts.push_back(input_contacts_[i].get_input_phone_contact(client_id));
}
send_query(
G()->net_query_creator().create(create_storer(telegram_api::contacts_importContacts(std::move(contacts)))));
send_query(G()->net_query_creator().create(telegram_api::contacts_importContacts(std::move(contacts))));
return;
}
@ -672,8 +667,7 @@ class DeleteContactsQuery : public Td::ResultHandler {
}
void send(vector<tl_object_ptr<telegram_api::InputUser>> &&input_users) {
send_query(
G()->net_query_creator().create(create_storer(telegram_api::contacts_deleteContacts(std::move(input_users)))));
send_query(G()->net_query_creator().create(telegram_api::contacts_deleteContacts(std::move(input_users))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -705,8 +699,7 @@ class DeleteContactsByPhoneNumberQuery : public Td::ResultHandler {
void send(vector<string> &&user_phone_numbers, vector<UserId> &&user_ids) {
user_ids_ = std::move(user_ids);
send_query(G()->net_query_creator().create(
create_storer(telegram_api::contacts_deleteByPhones(std::move(user_phone_numbers)))));
send_query(G()->net_query_creator().create(telegram_api::contacts_deleteByPhones(std::move(user_phone_numbers))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -738,7 +731,7 @@ class ResetContactsQuery : public Td::ResultHandler {
}
void send() {
send_query(G()->net_query_creator().create(create_storer(telegram_api::contacts_resetSaved())));
send_query(G()->net_query_creator().create(telegram_api::contacts_resetSaved()));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -780,8 +773,8 @@ class SearchDialogsNearbyQuery : public Td::ResultHandler {
if (expire_date != -1) {
flags |= telegram_api::contacts_getLocated::SELF_EXPIRES_MASK;
}
send_query(G()->net_query_creator().create(create_storer(
telegram_api::contacts_getLocated(flags, false /*ignored*/, location.get_input_geo_point(), expire_date))));
send_query(G()->net_query_creator().create(
telegram_api::contacts_getLocated(flags, false /*ignored*/, location.get_input_geo_point(), expire_date)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -812,8 +805,7 @@ class UploadProfilePhotoQuery : public Td::ResultHandler {
file_id_ = file_id;
send_query(
G()->net_query_creator().create(create_storer(telegram_api::photos_uploadProfilePhoto(std::move(input_file)))));
send_query(G()->net_query_creator().create(telegram_api::photos_uploadProfilePhoto(std::move(input_file))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -852,8 +844,7 @@ class UpdateProfilePhotoQuery : public Td::ResultHandler {
CHECK(input_photo != nullptr);
file_id_ = file_id;
file_reference_ = FileManager::extract_file_reference(input_photo);
send_query(G()->net_query_creator().create(
create_storer(telegram_api::photos_updateProfilePhoto(std::move(input_photo)))));
send_query(G()->net_query_creator().create(telegram_api::photos_updateProfilePhoto(std::move(input_photo))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -896,8 +887,7 @@ class DeleteProfilePhotoQuery : public Td::ResultHandler {
profile_photo_id_ = profile_photo_id;
vector<tl_object_ptr<telegram_api::InputPhoto>> input_photo_ids;
input_photo_ids.push_back(make_tl_object<telegram_api::inputPhoto>(profile_photo_id, 0, BufferSlice()));
send_query(
G()->net_query_creator().create(create_storer(telegram_api::photos_deletePhotos(std::move(input_photo_ids)))));
send_query(G()->net_query_creator().create(telegram_api::photos_deletePhotos(std::move(input_photo_ids))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -937,8 +927,8 @@ class UpdateProfileQuery : public Td::ResultHandler {
first_name_ = first_name;
last_name_ = last_name;
about_ = about;
send_query(G()->net_query_creator().create(
create_storer(telegram_api::account_updateProfile(flags, first_name, last_name, about))));
send_query(
G()->net_query_creator().create(telegram_api::account_updateProfile(flags, first_name, last_name, about)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -967,7 +957,7 @@ class CheckUsernameQuery : public Td::ResultHandler {
}
void send(const string &username) {
send_query(G()->net_query_creator().create(create_storer(telegram_api::account_checkUsername(username))));
send_query(G()->net_query_creator().create(telegram_api::account_checkUsername(username)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -992,7 +982,7 @@ class UpdateUsernameQuery : public Td::ResultHandler {
}
void send(const string &username) {
send_query(G()->net_query_creator().create(create_storer(telegram_api::account_updateUsername(username))));
send_query(G()->net_query_creator().create(telegram_api::account_updateUsername(username)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1033,8 +1023,8 @@ class CheckChannelUsernameQuery : public Td::ResultHandler {
input_channel = make_tl_object<telegram_api::inputChannelEmpty>();
}
CHECK(input_channel != nullptr);
send_query(G()->net_query_creator().create(
create_storer(telegram_api::channels_checkUsername(std::move(input_channel), username))));
send_query(
G()->net_query_creator().create(telegram_api::channels_checkUsername(std::move(input_channel), username)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1068,8 +1058,8 @@ class UpdateChannelUsernameQuery : public Td::ResultHandler {
username_ = username;
auto input_channel = td->contacts_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
send_query(G()->net_query_creator().create(
create_storer(telegram_api::channels_updateUsername(std::move(input_channel), username))));
send_query(
G()->net_query_creator().create(telegram_api::channels_updateUsername(std::move(input_channel), username)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1118,7 +1108,7 @@ class SetChannelStickerSetQuery : public Td::ResultHandler {
auto input_channel = td->contacts_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
send_query(G()->net_query_creator().create(
create_storer(telegram_api::channels_setStickers(std::move(input_channel), std::move(input_sticker_set)))));
telegram_api::channels_setStickers(std::move(input_channel), std::move(input_sticker_set))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1164,7 +1154,7 @@ class ToggleChannelSignaturesQuery : public Td::ResultHandler {
auto input_channel = td->contacts_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
send_query(G()->net_query_creator().create(
create_storer(telegram_api::channels_toggleSignatures(std::move(input_channel), sign_messages))));
telegram_api::channels_toggleSignatures(std::move(input_channel), sign_messages)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1208,8 +1198,8 @@ class ToggleChannelIsAllHistoryAvailableQuery : public Td::ResultHandler {
auto input_channel = td->contacts_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
send_query(G()->net_query_creator().create(create_storer(
telegram_api::channels_togglePreHistoryHidden(std::move(input_channel), !is_all_history_available))));
send_query(G()->net_query_creator().create(
telegram_api::channels_togglePreHistoryHidden(std::move(input_channel), !is_all_history_available)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1268,8 +1258,7 @@ class EditChatAboutQuery : public Td::ResultHandler {
if (input_peer == nullptr) {
return on_error(0, Status::Error(400, "Can't access the chat"));
}
send_query(G()->net_query_creator().create(
create_storer(telegram_api::messages_editChatAbout(std::move(input_peer), about))));
send_query(G()->net_query_creator().create(telegram_api::messages_editChatAbout(std::move(input_peer), about)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1316,8 +1305,8 @@ class SetDiscussionGroupQuery : public Td::ResultHandler {
telegram_api::object_ptr<telegram_api::InputChannel> group_input_channel) {
broadcast_channel_id_ = broadcast_channel_id;
group_channel_id_ = group_channel_id;
send_query(G()->net_query_creator().create(create_storer(telegram_api::channels_setDiscussionGroup(
std::move(broadcast_input_channel), std::move(group_input_channel)))));
send_query(G()->net_query_creator().create(
telegram_api::channels_setDiscussionGroup(std::move(broadcast_input_channel), std::move(group_input_channel))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1357,8 +1346,8 @@ class EditLocationQuery : public Td::ResultHandler {
auto input_channel = td->contacts_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
send_query(G()->net_query_creator().create(create_storer(telegram_api::channels_editLocation(
std::move(input_channel), location_.get_input_geo_point(), location_.get_address()))));
send_query(G()->net_query_creator().create(telegram_api::channels_editLocation(
std::move(input_channel), location_.get_input_geo_point(), location_.get_address())));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1397,7 +1386,7 @@ class ToggleSlowModeQuery : public Td::ResultHandler {
CHECK(input_channel != nullptr);
send_query(G()->net_query_creator().create(
create_storer(telegram_api::channels_toggleSlowMode(std::move(input_channel), slow_mode_delay))));
telegram_api::channels_toggleSlowMode(std::move(input_channel), slow_mode_delay)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1447,8 +1436,8 @@ class ReportChannelSpamQuery : public Td::ResultHandler {
auto input_user = td->contacts_manager_->get_input_user(user_id);
CHECK(input_user != nullptr);
send_query(G()->net_query_creator().create(create_storer(telegram_api::channels_reportSpam(
std::move(input_channel), std::move(input_user), MessagesManager::get_server_message_ids(message_ids)))));
send_query(G()->net_query_creator().create(telegram_api::channels_reportSpam(
std::move(input_channel), std::move(input_user), MessagesManager::get_server_message_ids(message_ids))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1481,8 +1470,7 @@ class DeleteChannelQuery : public Td::ResultHandler {
channel_id_ = channel_id;
auto input_channel = td->contacts_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
send_query(
G()->net_query_creator().create(create_storer(telegram_api::channels_deleteChannel(std::move(input_channel)))));
send_query(G()->net_query_creator().create(telegram_api::channels_deleteChannel(std::move(input_channel))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1513,7 +1501,7 @@ class AddChatUserQuery : public Td::ResultHandler {
void send(ChatId chat_id, tl_object_ptr<telegram_api::InputUser> &&input_user, int32 forward_limit) {
send_query(G()->net_query_creator().create(
create_storer(telegram_api::messages_addChatUser(chat_id.get(), std::move(input_user), forward_limit))));
telegram_api::messages_addChatUser(chat_id.get(), std::move(input_user), forward_limit)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1546,7 +1534,7 @@ class EditChatAdminQuery : public Td::ResultHandler {
void send(ChatId chat_id, tl_object_ptr<telegram_api::InputUser> &&input_user, bool is_administrator) {
chat_id_ = chat_id;
send_query(G()->net_query_creator().create(
create_storer(telegram_api::messages_editChatAdmin(chat_id.get(), std::move(input_user), is_administrator))));
telegram_api::messages_editChatAdmin(chat_id.get(), std::move(input_user), is_administrator)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1585,8 +1573,7 @@ class ExportChatInviteLinkQuery : public Td::ResultHandler {
if (input_peer == nullptr) {
return on_error(0, Status::Error(400, "Can't access the chat"));
}
send_query(
G()->net_query_creator().create(create_storer(telegram_api::messages_exportChatInvite(std::move(input_peer)))));
send_query(G()->net_query_creator().create(telegram_api::messages_exportChatInvite(std::move(input_peer))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1622,8 +1609,7 @@ class ExportChannelInviteLinkQuery : public Td::ResultHandler {
if (input_peer == nullptr) {
return on_error(0, Status::Error(400, "Can't access the chat"));
}
send_query(
G()->net_query_creator().create(create_storer(telegram_api::messages_exportChatInvite(std::move(input_peer)))));
send_query(G()->net_query_creator().create(telegram_api::messages_exportChatInvite(std::move(input_peer))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1656,8 +1642,8 @@ class CheckDialogInviteLinkQuery : public Td::ResultHandler {
void send(const string &invite_link) {
invite_link_ = invite_link;
send_query(G()->net_query_creator().create(create_storer(
telegram_api::messages_checkChatInvite(ContactsManager::get_dialog_invite_link_hash(invite_link_).str()))));
send_query(G()->net_query_creator().create(
telegram_api::messages_checkChatInvite(ContactsManager::get_dialog_invite_link_hash(invite_link_).str())));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1689,8 +1675,8 @@ class ImportDialogInviteLinkQuery : public Td::ResultHandler {
void send(const string &invite_link) {
invite_link_ = invite_link;
send_query(G()->net_query_creator().create(create_storer(
telegram_api::messages_importChatInvite(ContactsManager::get_dialog_invite_link_hash(invite_link).str()))));
send_query(G()->net_query_creator().create(
telegram_api::messages_importChatInvite(ContactsManager::get_dialog_invite_link_hash(invite_link).str())));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1727,8 +1713,8 @@ class DeleteChatUserQuery : public Td::ResultHandler {
}
void send(ChatId chat_id, tl_object_ptr<telegram_api::InputUser> &&input_user) {
send_query(G()->net_query_creator().create(
create_storer(telegram_api::messages_deleteChatUser(chat_id.get(), std::move(input_user)))));
send_query(
G()->net_query_creator().create(telegram_api::messages_deleteChatUser(chat_id.get(), std::move(input_user))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1762,8 +1748,7 @@ class JoinChannelQuery : public Td::ResultHandler {
channel_id_ = channel_id;
auto input_channel = td->contacts_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
send_query(
G()->net_query_creator().create(create_storer(telegram_api::channels_joinChannel(std::move(input_channel)))));
send_query(G()->net_query_creator().create(telegram_api::channels_joinChannel(std::move(input_channel))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1799,7 +1784,7 @@ class InviteToChannelQuery : public Td::ResultHandler {
auto input_channel = td->contacts_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
send_query(G()->net_query_creator().create(
create_storer(telegram_api::channels_inviteToChannel(std::move(input_channel), std::move(input_users)))));
telegram_api::channels_inviteToChannel(std::move(input_channel), std::move(input_users))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1835,8 +1820,8 @@ class EditChannelAdminQuery : public Td::ResultHandler {
channel_id_ = channel_id;
auto input_channel = td->contacts_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
send_query(G()->net_query_creator().create(create_storer(telegram_api::channels_editAdmin(
std::move(input_channel), std::move(input_user), status.get_chat_admin_rights(), status.get_rank()))));
send_query(G()->net_query_creator().create(telegram_api::channels_editAdmin(
std::move(input_channel), std::move(input_user), status.get_chat_admin_rights(), status.get_rank())));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1872,8 +1857,8 @@ class EditChannelBannedQuery : public Td::ResultHandler {
channel_id_ = channel_id;
auto input_channel = td->contacts_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
send_query(G()->net_query_creator().create(create_storer(telegram_api::channels_editBanned(
std::move(input_channel), std::move(input_user), status.get_chat_banned_rights()))));
send_query(G()->net_query_creator().create(telegram_api::channels_editBanned(
std::move(input_channel), std::move(input_user), status.get_chat_banned_rights())));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1909,8 +1894,7 @@ class LeaveChannelQuery : public Td::ResultHandler {
channel_id_ = channel_id;
auto input_channel = td->contacts_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
send_query(
G()->net_query_creator().create(create_storer(telegram_api::channels_leaveChannel(std::move(input_channel)))));
send_query(G()->net_query_creator().create(telegram_api::channels_leaveChannel(std::move(input_channel))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1943,9 +1927,9 @@ class CanEditChannelCreatorQuery : public Td::ResultHandler {
void send() {
auto input_user = td->contacts_manager_->get_input_user(td->contacts_manager_->get_my_id());
CHECK(input_user != nullptr);
send_query(G()->net_query_creator().create(create_storer(telegram_api::channels_editCreator(
send_query(G()->net_query_creator().create(telegram_api::channels_editCreator(
telegram_api::make_object<telegram_api::inputChannelEmpty>(), std::move(input_user),
make_tl_object<telegram_api::inputCheckPasswordEmpty>()))));
make_tl_object<telegram_api::inputCheckPasswordEmpty>())));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1983,8 +1967,8 @@ class EditChannelCreatorQuery : public Td::ResultHandler {
if (input_user == nullptr) {
return promise_.set_error(Status::Error(400, "Have no access to the user"));
}
send_query(G()->net_query_creator().create(create_storer(telegram_api::channels_editCreator(
std::move(input_channel), std::move(input_user), std::move(input_check_password)))));
send_query(G()->net_query_creator().create(telegram_api::channels_editCreator(
std::move(input_channel), std::move(input_user), std::move(input_check_password))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -2016,7 +2000,7 @@ class MigrateChatQuery : public Td::ResultHandler {
}
void send(ChatId chat_id) {
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_migrateChat(chat_id.get()))));
send_query(G()->net_query_creator().create(telegram_api::messages_migrateChat(chat_id.get())));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -2056,7 +2040,7 @@ class GetCreatedPublicChannelsQuery : public Td::ResultHandler {
flags |= telegram_api::channels_getAdminedPublicChannels::CHECK_LIMIT_MASK;
}
send_query(G()->net_query_creator().create(
create_storer(telegram_api::channels_getAdminedPublicChannels(flags, false /*ignored*/, false /*ignored*/))));
telegram_api::channels_getAdminedPublicChannels(flags, false /*ignored*/, false /*ignored*/)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -2100,7 +2084,7 @@ class GetGroupsForDiscussionQuery : public Td::ResultHandler {
}
void send() {
send_query(G()->net_query_creator().create(create_storer(telegram_api::channels_getGroupsForDiscussion())));
send_query(G()->net_query_creator().create(telegram_api::channels_getGroupsForDiscussion()));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -2144,7 +2128,7 @@ class GetInactiveChannelsQuery : public Td::ResultHandler {
}
void send() {
send_query(G()->net_query_creator().create(create_storer(telegram_api::channels_getInactiveChannels())));
send_query(G()->net_query_creator().create(telegram_api::channels_getInactiveChannels()));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -2175,7 +2159,7 @@ class GetUsersQuery : public Td::ResultHandler {
}
void send(vector<tl_object_ptr<telegram_api::InputUser>> &&input_users) {
send_query(G()->net_query_creator().create(create_storer(telegram_api::users_getUsers(std::move(input_users)))));
send_query(G()->net_query_creator().create(telegram_api::users_getUsers(std::move(input_users))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -2202,7 +2186,7 @@ class GetFullUserQuery : public Td::ResultHandler {
}
void send(tl_object_ptr<telegram_api::InputUser> &&input_user) {
send_query(G()->net_query_creator().create(create_storer(telegram_api::users_getFullUser(std::move(input_user)))));
send_query(G()->net_query_creator().create(telegram_api::users_getFullUser(std::move(input_user))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -2239,7 +2223,7 @@ class GetUserPhotosQuery : public Td::ResultHandler {
LOG(INFO) << "Get " << user_id << " profile photos with offset " << offset << " and limit " << limit
<< " from photo " << photo_id;
send_query(G()->net_query_creator().create(
create_storer(telegram_api::photos_getUserPhotos(std::move(input_user), offset, photo_id, limit))));
telegram_api::photos_getUserPhotos(std::move(input_user), offset, photo_id, limit)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -2282,7 +2266,7 @@ class GetChatsQuery : public Td::ResultHandler {
}
void send(vector<int32> &&chat_ids) {
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_getChats(std::move(chat_ids)))));
send_query(G()->net_query_creator().create(telegram_api::messages_getChats(std::move(chat_ids))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -2326,7 +2310,7 @@ class GetFullChatQuery : public Td::ResultHandler {
void send(ChatId chat_id) {
LOG(INFO) << "Send getFullChat query to get " << chat_id;
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_getFullChat(chat_id.get()))));
send_query(G()->net_query_creator().create(telegram_api::messages_getFullChat(chat_id.get())));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -2362,8 +2346,7 @@ class GetChannelsQuery : public Td::ResultHandler {
vector<tl_object_ptr<telegram_api::InputChannel>> input_channels;
input_channels.push_back(std::move(input_channel));
send_query(
G()->net_query_creator().create(create_storer(telegram_api::channels_getChannels(std::move(input_channels)))));
send_query(G()->net_query_creator().create(telegram_api::channels_getChannels(std::move(input_channels))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -2410,8 +2393,7 @@ class GetFullChannelQuery : public Td::ResultHandler {
void send(ChannelId channel_id, tl_object_ptr<telegram_api::InputChannel> &&input_channel) {
channel_id_ = channel_id;
send_query(G()->net_query_creator().create(
create_storer(telegram_api::channels_getFullChannel(std::move(input_channel)))));
send_query(G()->net_query_creator().create(telegram_api::channels_getFullChannel(std::move(input_channel))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -2452,7 +2434,7 @@ class GetChannelParticipantQuery : public Td::ResultHandler {
channel_id_ = channel_id;
user_id_ = user_id;
send_query(G()->net_query_creator().create(
create_storer(telegram_api::channels_getParticipant(std::move(input_channel), std::move(input_user)))));
telegram_api::channels_getParticipant(std::move(input_channel), std::move(input_user))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -2503,8 +2485,8 @@ class GetChannelParticipantsQuery : public Td::ResultHandler {
offset_ = offset;
limit_ = limit;
random_id_ = random_id;
send_query(G()->net_query_creator().create(create_storer(telegram_api::channels_getParticipants(
std::move(input_channel), filter_.get_input_channel_participants_filter(), offset, limit, 0))));
send_query(G()->net_query_creator().create(telegram_api::channels_getParticipants(
std::move(input_channel), filter_.get_input_channel_participants_filter(), offset, limit, 0)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -2560,9 +2542,9 @@ class GetChannelAdministratorsQuery : public Td::ResultHandler {
hash = 0; // to load even only ranks or creator changed
channel_id_ = channel_id;
send_query(G()->net_query_creator().create(create_storer(telegram_api::channels_getParticipants(
send_query(G()->net_query_creator().create(telegram_api::channels_getParticipants(
std::move(input_channel), telegram_api::make_object<telegram_api::channelParticipantsAdmins>(), 0,
std::numeric_limits<int32>::max(), hash))));
std::numeric_limits<int32>::max(), hash)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -2620,7 +2602,7 @@ class GetSupportUserQuery : public Td::ResultHandler {
}
void send() {
send_query(G()->net_query_creator().create(create_storer(telegram_api::help_getSupport())));
send_query(G()->net_query_creator().create(telegram_api::help_getSupport()));
}
void on_result(uint64 id, BufferSlice packet) override {

View File

@ -373,12 +373,12 @@ void DeviceTokenManager::loop() {
auto other_user_ids = info.other_user_ids;
if (info.state == TokenInfo::State::Unregister) {
net_query = G()->net_query_creator().create(
create_storer(telegram_api::account_unregisterDevice(token_type, info.token, std::move(other_user_ids))));
telegram_api::account_unregisterDevice(token_type, info.token, std::move(other_user_ids)));
} else {
int32 flags = telegram_api::account_registerDevice::NO_MUTED_MASK;
net_query = G()->net_query_creator().create(create_storer(
net_query = G()->net_query_creator().create(
telegram_api::account_registerDevice(flags, false /*ignored*/, token_type, info.token, info.is_app_sandbox,
BufferSlice(info.encryption_key), std::move(other_user_ids))));
BufferSlice(info.encryption_key), std::move(other_user_ids)));
}
info.net_query_id = net_query->id();
G()->net_query_dispatcher().dispatch_with_callback(std::move(net_query), actor_shared(this, token_type));

View File

@ -80,9 +80,9 @@ class GetInlineBotResultsQuery : public Td::ResultHandler {
input_peer = make_tl_object<telegram_api::inputPeerEmpty>();
}
auto net_query = G()->net_query_creator().create(create_storer(telegram_api::messages_getInlineBotResults(
auto net_query = G()->net_query_creator().create(telegram_api::messages_getInlineBotResults(
flags, std::move(bot_input_user), std::move(input_peer),
user_location.empty() ? nullptr : user_location.get_input_geo_point(), query, offset)));
user_location.empty() ? nullptr : user_location.get_input_geo_point(), query, offset));
auto result = net_query.get_weak();
net_query->need_resend_on_503 = false;
send_query(std::move(net_query));
@ -135,9 +135,9 @@ class SetInlineBotResultsQuery : public Td::ResultHandler {
flags |= telegram_api::messages_setInlineBotResults::SWITCH_PM_MASK;
inline_bot_switch_pm = make_tl_object<telegram_api::inlineBotSwitchPM>(switch_pm_text, switch_pm_parameter);
}
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_setInlineBotResults(
send_query(G()->net_query_creator().create(telegram_api::messages_setInlineBotResults(
flags, false /*ignored*/, false /*ignored*/, inline_query_id, std::move(results), cache_time, next_offset,
std::move(inline_bot_switch_pm)))));
std::move(inline_bot_switch_pm))));
}
void on_result(uint64 id, BufferSlice packet) override {

View File

@ -97,8 +97,7 @@ class GetOnlinesQuery : public Td::ResultHandler {
return on_error(0, Status::Error(400, "Can't access the chat"));
}
send_query(
G()->net_query_creator().create(create_storer(telegram_api::messages_getOnlines(std::move(input_peer)))));
send_query(G()->net_query_creator().create(telegram_api::messages_getOnlines(std::move(input_peer))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -120,7 +119,7 @@ class GetOnlinesQuery : public Td::ResultHandler {
class GetAllDraftsQuery : public Td::ResultHandler {
public:
void send() {
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_getAllDrafts())));
send_query(G()->net_query_creator().create(telegram_api::messages_getAllDrafts()));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -146,8 +145,8 @@ class GetDialogQuery : public Td::ResultHandler {
public:
void send(DialogId dialog_id) {
dialog_id_ = dialog_id;
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_getPeerDialogs(
td->messages_manager_->get_input_dialog_peers({dialog_id}, AccessRights::Read)))));
send_query(G()->net_query_creator().create(telegram_api::messages_getPeerDialogs(
td->messages_manager_->get_input_dialog_peers({dialog_id}, AccessRights::Read))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -192,8 +191,7 @@ class GetPinnedDialogsActor : public NetActorOnce {
NetQueryRef send(FolderId folder_id, uint64 sequence_id) {
folder_id_ = folder_id;
auto query =
G()->net_query_creator().create(create_storer(telegram_api::messages_getPinnedDialogs(folder_id.get())));
auto query = G()->net_query_creator().create(telegram_api::messages_getPinnedDialogs(folder_id.get()));
auto result = query.get_weak();
send_closure(td->messages_manager_->sequence_dispatcher_, &MultiSequenceDispatcher::send_with_callback,
std::move(query), actor_shared(this), sequence_id);
@ -224,7 +222,7 @@ class GetPinnedDialogsActor : public NetActorOnce {
class GetDialogUnreadMarksQuery : public Td::ResultHandler {
public:
void send() {
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_getDialogUnreadMarks())));
send_query(G()->net_query_creator().create(telegram_api::messages_getDialogUnreadMarks()));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -257,8 +255,7 @@ class GetMessagesQuery : public Td::ResultHandler {
}
void send(vector<tl_object_ptr<telegram_api::InputMessage>> &&message_ids) {
send_query(
G()->net_query_creator().create(create_storer(telegram_api::messages_getMessages(std::move(message_ids)))));
send_query(G()->net_query_creator().create(telegram_api::messages_getMessages(std::move(message_ids))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -297,7 +294,7 @@ class GetChannelMessagesQuery : public Td::ResultHandler {
channel_id_ = channel_id;
CHECK(input_channel != nullptr);
send_query(G()->net_query_creator().create(
create_storer(telegram_api::channels_getMessages(std::move(input_channel), std::move(message_ids)))));
telegram_api::channels_getMessages(std::move(input_channel), std::move(message_ids))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -336,7 +333,7 @@ class GetScheduledMessagesQuery : public Td::ResultHandler {
dialog_id_ = dialog_id;
CHECK(input_peer != nullptr);
send_query(G()->net_query_creator().create(
create_storer(telegram_api::messages_getScheduledMessages(std::move(input_peer), std::move(message_ids)))));
telegram_api::messages_getScheduledMessages(std::move(input_peer), std::move(message_ids))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -387,8 +384,8 @@ class UpdateDialogPinnedMessageQuery : public Td::ResultHandler {
flags |= telegram_api::messages_updatePinnedMessage::SILENT_MASK;
}
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_updatePinnedMessage(
flags, false /*ignored*/, std::move(input_peer), message_id.get_server_message_id().get()))));
send_query(G()->net_query_creator().create(telegram_api::messages_updatePinnedMessage(
flags, false /*ignored*/, std::move(input_peer), message_id.get_server_message_id().get())));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -436,8 +433,8 @@ class ExportChannelMessageLinkQuery : public Td::ResultHandler {
ignore_result_ = ignore_result;
auto input_channel = td->contacts_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
send_query(G()->net_query_creator().create(create_storer(telegram_api::channels_exportMessageLink(
std::move(input_channel), message_id.get_server_message_id().get(), for_group))));
send_query(G()->net_query_creator().create(telegram_api::channels_exportMessageLink(
std::move(input_channel), message_id.get_server_message_id().get(), for_group)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -483,8 +480,8 @@ class GetDialogListActor : public NetActorOnce {
int32 flags =
telegram_api::messages_getDialogs::EXCLUDE_PINNED_MASK | telegram_api::messages_getDialogs::FOLDER_ID_MASK;
auto query = G()->net_query_creator().create(
create_storer(telegram_api::messages_getDialogs(flags, false /*ignored*/, folder_id.get(), offset_date,
offset_message_id.get(), std::move(input_peer), limit, 0)));
telegram_api::messages_getDialogs(flags, false /*ignored*/, folder_id.get(), offset_date,
offset_message_id.get(), std::move(input_peer), limit, 0));
send_closure(td->messages_manager_->sequence_dispatcher_, &MultiSequenceDispatcher::send_with_callback,
std::move(query), actor_shared(this), sequence_id);
}
@ -534,8 +531,7 @@ class SearchPublicDialogsQuery : public Td::ResultHandler {
public:
void send(const string &query) {
query_ = query;
send_query(G()->net_query_creator().create(
create_storer(telegram_api::contacts_search(query, 3 /* ignored server-side */))));
send_query(G()->net_query_creator().create(telegram_api::contacts_search(query, 3 /* ignored server-side */)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -578,7 +574,7 @@ class GetCommonDialogsQuery : public Td::ResultHandler {
CHECK(input_user != nullptr);
send_query(G()->net_query_creator().create(
create_storer(telegram_api::messages_getCommonChats(std::move(input_user), offset_chat_id, limit))));
telegram_api::messages_getCommonChats(std::move(input_user), offset_chat_id, limit)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -624,8 +620,7 @@ class CreateChatQuery : public Td::ResultHandler {
void send(vector<tl_object_ptr<telegram_api::InputUser>> &&input_users, const string &title, int64 random_id) {
random_id_ = random_id;
send_query(G()->net_query_creator().create(
create_storer(telegram_api::messages_createChat(std::move(input_users), title))));
send_query(G()->net_query_creator().create(telegram_api::messages_createChat(std::move(input_users), title)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -667,8 +662,8 @@ class CreateChannelQuery : public Td::ResultHandler {
random_id_ = random_id;
send_query(G()->net_query_creator().create(
create_storer(telegram_api::channels_createChannel(flags, false /*ignored*/, false /*ignored*/, title, about,
location.get_input_geo_point(), location.get_address()))));
telegram_api::channels_createChannel(flags, false /*ignored*/, false /*ignored*/, title, about,
location.get_input_geo_point(), location.get_address())));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -708,15 +703,15 @@ class EditDialogPhotoQuery : public Td::ResultHandler {
switch (dialog_id.get_type()) {
case DialogType::Chat:
send_query(G()->net_query_creator().create(create_storer(
telegram_api::messages_editChatPhoto(dialog_id.get_chat_id().get(), std::move(input_chat_photo)))));
send_query(G()->net_query_creator().create(
telegram_api::messages_editChatPhoto(dialog_id.get_chat_id().get(), std::move(input_chat_photo))));
break;
case DialogType::Channel: {
auto channel_id = dialog_id.get_channel_id();
auto input_channel = td->contacts_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
send_query(G()->net_query_creator().create(
create_storer(telegram_api::channels_editPhoto(std::move(input_channel), std::move(input_chat_photo)))));
telegram_api::channels_editPhoto(std::move(input_channel), std::move(input_chat_photo))));
break;
}
default:
@ -786,14 +781,13 @@ class EditDialogTitleQuery : public Td::ResultHandler {
switch (dialog_id.get_type()) {
case DialogType::Chat:
send_query(G()->net_query_creator().create(
create_storer(telegram_api::messages_editChatTitle(dialog_id.get_chat_id().get(), title))));
telegram_api::messages_editChatTitle(dialog_id.get_chat_id().get(), title)));
break;
case DialogType::Channel: {
auto channel_id = dialog_id.get_channel_id();
auto input_channel = td->contacts_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
send_query(G()->net_query_creator().create(
create_storer(telegram_api::channels_editTitle(std::move(input_channel), title))));
send_query(G()->net_query_creator().create(telegram_api::channels_editTitle(std::move(input_channel), title)));
break;
}
default:
@ -844,8 +838,8 @@ class EditDialogDefaultBannedRightsQuery : public Td::ResultHandler {
dialog_id_ = dialog_id;
auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write);
CHECK(input_peer != nullptr);
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_editChatDefaultBannedRights(
std::move(input_peer), permissions.get_chat_banned_rights()))));
send_query(G()->net_query_creator().create(telegram_api::messages_editChatDefaultBannedRights(
std::move(input_peer), permissions.get_chat_banned_rights())));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -907,13 +901,13 @@ class SaveDraftMessageQuery : public Td::ResultHandler {
}
}
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_saveDraft(
send_query(G()->net_query_creator().create(telegram_api::messages_saveDraft(
flags, false /*ignored*/, reply_to_message_id.get(), std::move(input_peer),
draft_message == nullptr ? "" : draft_message->input_message_text.text.text,
draft_message == nullptr
? vector<tl_object_ptr<telegram_api::MessageEntity>>()
: get_input_message_entities(td->contacts_manager_.get(), draft_message->input_message_text.text.entities,
"SaveDraftMessageQuery")))));
"SaveDraftMessageQuery"))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -946,7 +940,7 @@ class ClearAllDraftsQuery : public Td::ResultHandler {
}
void send() {
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_clearAllDrafts())));
send_query(G()->net_query_creator().create(telegram_api::messages_clearAllDrafts()));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -996,7 +990,7 @@ class ToggleDialogPinQuery : public Td::ResultHandler {
flags |= telegram_api::messages_toggleDialogPin::PINNED_MASK;
}
send_query(G()->net_query_creator().create(
create_storer(telegram_api::messages_toggleDialogPin(flags, false /*ignored*/, std::move(input_peer)))));
telegram_api::messages_toggleDialogPin(flags, false /*ignored*/, std::move(input_peer))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1033,9 +1027,9 @@ class ReorderPinnedDialogsQuery : public Td::ResultHandler {
void send(FolderId folder_id, const vector<DialogId> &dialog_ids) {
folder_id_ = folder_id;
int32 flags = telegram_api::messages_reorderPinnedDialogs::FORCE_MASK;
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_reorderPinnedDialogs(
send_query(G()->net_query_creator().create(telegram_api::messages_reorderPinnedDialogs(
flags, true /*ignored*/, folder_id.get(),
td->messages_manager_->get_input_dialog_peers(dialog_ids, AccessRights::Read)))));
td->messages_manager_->get_input_dialog_peers(dialog_ids, AccessRights::Read))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1085,7 +1079,7 @@ class ToggleDialogUnreadMarkQuery : public Td::ResultHandler {
flags |= telegram_api::messages_markDialogUnread::UNREAD_MASK;
}
send_query(G()->net_query_creator().create(
create_storer(telegram_api::messages_markDialogUnread(flags, false /*ignored*/, std::move(input_peer)))));
telegram_api::messages_markDialogUnread(flags, false /*ignored*/, std::move(input_peer))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1128,8 +1122,8 @@ class GetMessagesViewsQuery : public Td::ResultHandler {
LOG(INFO) << "View " << message_ids_.size() << " messages in " << dialog_id
<< ", increment = " << increment_view_counter;
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_getMessagesViews(
std::move(input_peer), MessagesManager::get_server_message_ids(message_ids_), increment_view_counter))));
send_query(G()->net_query_creator().create(telegram_api::messages_getMessagesViews(
std::move(input_peer), MessagesManager::get_server_message_ids(message_ids_), increment_view_counter)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1166,8 +1160,8 @@ class ReadMessagesContentsQuery : public Td::ResultHandler {
void send(vector<MessageId> &&message_ids) {
LOG(INFO) << "Receive ReadMessagesContentsQuery for messages " << format::as_array(message_ids);
send_query(G()->net_query_creator().create(create_storer(
telegram_api::messages_readMessageContents(MessagesManager::get_server_message_ids(message_ids)))));
send_query(G()->net_query_creator().create(
telegram_api::messages_readMessageContents(MessagesManager::get_server_message_ids(message_ids))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1215,8 +1209,8 @@ class ReadChannelMessagesContentsQuery : public Td::ResultHandler {
LOG(INFO) << "Receive ReadChannelMessagesContentsQuery for messages " << format::as_array(message_ids) << " in "
<< channel_id;
send_query(G()->net_query_creator().create(create_storer(telegram_api::channels_readMessageContents(
std::move(input_channel), MessagesManager::get_server_message_ids(message_ids)))));
send_query(G()->net_query_creator().create(telegram_api::channels_readMessageContents(
std::move(input_channel), MessagesManager::get_server_message_ids(message_ids))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1260,7 +1254,7 @@ class GetDialogMessageByDateQuery : public Td::ResultHandler {
random_id_ = random_id;
send_query(G()->net_query_creator().create(
create_storer(telegram_api::messages_getHistory(std::move(input_peer), 0, date, -3, 5, 0, 0, 0))));
telegram_api::messages_getHistory(std::move(input_peer), 0, date, -3, 5, 0, 0, 0)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1309,8 +1303,8 @@ class GetHistoryQuery : public Td::ResultHandler {
offset_ = offset;
limit_ = limit;
from_the_end_ = false;
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_getHistory(
std::move(input_peer), from_message_id.get_server_message_id().get(), 0, offset, limit, 0, 0, 0))));
send_query(G()->net_query_creator().create(telegram_api::messages_getHistory(
std::move(input_peer), from_message_id.get_server_message_id().get(), 0, offset, limit, 0, 0, 0)));
}
void send_get_from_the_end(DialogId dialog_id, int32 limit) {
@ -1325,7 +1319,7 @@ class GetHistoryQuery : public Td::ResultHandler {
limit_ = limit;
from_the_end_ = true;
send_query(G()->net_query_creator().create(
create_storer(telegram_api::messages_getHistory(std::move(input_peer), 0, 0, 0, limit, 0, 0, 0))));
telegram_api::messages_getHistory(std::move(input_peer), 0, 0, 0, limit, 0, 0, 0)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1360,9 +1354,9 @@ class ReadHistoryQuery : public Td::ResultHandler {
void send(DialogId dialog_id, MessageId max_message_id) {
dialog_id_ = dialog_id;
send_query(G()->net_query_creator().create(create_storer(
send_query(G()->net_query_creator().create(
telegram_api::messages_readHistory(td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read),
max_message_id.get_server_message_id().get()))));
max_message_id.get_server_message_id().get())));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1404,8 +1398,8 @@ class ReadChannelHistoryQuery : public Td::ResultHandler {
auto input_channel = td->contacts_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
send_query(G()->net_query_creator().create(create_storer(
telegram_api::channels_readHistory(std::move(input_channel), max_message_id.get_server_message_id().get()))));
send_query(G()->net_query_creator().create(
telegram_api::channels_readHistory(std::move(input_channel), max_message_id.get_server_message_id().get())));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1460,19 +1454,19 @@ class SearchMessagesQuery : public Td::ResultHandler {
random_id_ = random_id;
if (filter == SearchMessagesFilter::UnreadMention) {
send_query(G()->net_query_creator().create(create_storer(
send_query(G()->net_query_creator().create(
telegram_api::messages_getUnreadMentions(std::move(input_peer), from_message_id.get_server_message_id().get(),
offset, limit, std::numeric_limits<int32>::max(), 0))));
offset, limit, std::numeric_limits<int32>::max(), 0)));
} else {
int32 flags = 0;
if (sender_input_user != nullptr) {
flags |= telegram_api::messages_search::FROM_ID_MASK;
}
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_search(
send_query(G()->net_query_creator().create(telegram_api::messages_search(
flags, std::move(input_peer), query, std::move(sender_input_user),
MessagesManager::get_input_messages_filter(filter), 0, std::numeric_limits<int32>::max(),
from_message_id.get_server_message_id().get(), offset, limit, std::numeric_limits<int32>::max(), 0, 0))));
from_message_id.get_server_message_id().get(), offset, limit, std::numeric_limits<int32>::max(), 0, 0)));
}
}
@ -1531,9 +1525,9 @@ class SearchMessagesGlobalQuery : public Td::ResultHandler {
if (!ignore_folder_id) {
flags |= telegram_api::messages_searchGlobal::FOLDER_ID_MASK;
}
send_query(G()->net_query_creator().create(create_storer(
send_query(G()->net_query_creator().create(
telegram_api::messages_searchGlobal(flags, folder_id.get(), query, offset_date_, std::move(input_peer),
offset_message_id.get_server_message_id().get(), limit))));
offset_message_id.get_server_message_id().get(), limit)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1572,8 +1566,8 @@ class GetAllScheduledMessagesQuery : public Td::ResultHandler {
dialog_id_ = dialog_id;
generation_ = generation;
send_query(G()->net_query_creator().create(
create_storer(telegram_api::messages_getScheduledHistory(std::move(input_peer), hash))));
send_query(
G()->net_query_creator().create(telegram_api::messages_getScheduledHistory(std::move(input_peer), hash)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1619,8 +1613,8 @@ class GetRecentLocationsQuery : public Td::ResultHandler {
limit_ = limit;
random_id_ = random_id;
send_query(G()->net_query_creator().create(
create_storer(telegram_api::messages_getRecentLocations(std::move(input_peer), limit, 0))));
send_query(
G()->net_query_creator().create(telegram_api::messages_getRecentLocations(std::move(input_peer), limit, 0)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1665,9 +1659,9 @@ class DeleteHistoryQuery : public Td::ResultHandler {
}
LOG(INFO) << "Delete " << dialog_id_ << " history up to " << max_message_id_ << " with flags " << flags;
send_query(G()->net_query_creator().create(create_storer(
send_query(G()->net_query_creator().create(
telegram_api::messages_deleteHistory(flags, false /*ignored*/, false /*ignored*/, std::move(input_peer),
max_message_id_.get_server_message_id().get()))));
max_message_id_.get_server_message_id().get())));
}
public:
@ -1728,8 +1722,8 @@ class DeleteChannelHistoryQuery : public Td::ResultHandler {
auto input_channel = td->contacts_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
send_query(G()->net_query_creator().create(create_storer(
telegram_api::channels_deleteHistory(std::move(input_channel), max_message_id.get_server_message_id().get()))));
send_query(G()->net_query_creator().create(
telegram_api::channels_deleteHistory(std::move(input_channel), max_message_id.get_server_message_id().get())));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1771,7 +1765,7 @@ class DeleteUserHistoryQuery : public Td::ResultHandler {
LOG(INFO) << "Delete all messages from " << user_id_ << " in " << channel_id_;
send_query(G()->net_query_creator().create(
create_storer(telegram_api::channels_deleteUserHistory(std::move(input_channel), std::move(input_user)))));
telegram_api::channels_deleteUserHistory(std::move(input_channel), std::move(input_user))));
}
public:
@ -1826,8 +1820,7 @@ class ReadAllMentionsQuery : public Td::ResultHandler {
LOG(INFO) << "Read all mentions in " << dialog_id_;
send_query(
G()->net_query_creator().create(create_storer(telegram_api::messages_readMentions(std::move(input_peer)))));
send_query(G()->net_query_creator().create(telegram_api::messages_readMentions(std::move(input_peer))));
}
public:
@ -1944,10 +1937,10 @@ class SendMessageActor : public NetActorOnce {
flags |= MessagesManager::SEND_MESSAGE_FLAG_HAS_ENTITIES;
}
auto query = G()->net_query_creator().create(create_storer(telegram_api::messages_sendMessage(
auto query = G()->net_query_creator().create(telegram_api::messages_sendMessage(
flags, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, std::move(input_peer),
reply_to_message_id.get_server_message_id().get(), text, random_id, std::move(reply_markup),
std::move(entities), schedule_date)));
std::move(entities), schedule_date));
if (G()->shared_config().get_option_boolean("use_quick_ack")) {
query->quick_ack_promise_ = PromiseCreator::lambda(
[random_id](Unit) {
@ -2015,8 +2008,8 @@ class StartBotQuery : public Td::ResultHandler {
random_id_ = random_id;
dialog_id_ = dialog_id;
auto query = G()->net_query_creator().create(create_storer(
telegram_api::messages_startBot(std::move(bot_input_user), std::move(input_peer), random_id, parameter)));
auto query = G()->net_query_creator().create(
telegram_api::messages_startBot(std::move(bot_input_user), std::move(input_peer), random_id, parameter));
if (G()->shared_config().get_option_boolean("use_quick_ack")) {
query->quick_ack_promise_ = PromiseCreator::lambda(
[random_id](Unit) {
@ -2066,9 +2059,9 @@ class SendInlineBotResultQuery : public Td::ResultHandler {
auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write);
CHECK(input_peer != nullptr);
auto query = G()->net_query_creator().create(create_storer(telegram_api::messages_sendInlineBotResult(
auto query = G()->net_query_creator().create(telegram_api::messages_sendInlineBotResult(
flags, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, std::move(input_peer),
reply_to_message_id.get_server_message_id().get(), random_id, query_id, result_id, schedule_date)));
reply_to_message_id.get_server_message_id().get(), random_id, query_id, result_id, schedule_date));
auto send_query_ref = query.get_weak();
send_query(std::move(query));
return send_query_ref;
@ -2123,9 +2116,9 @@ class SendMultiMediaActor : public NetActorOnce {
return;
}
auto query = G()->net_query_creator().create(create_storer(telegram_api::messages_sendMultiMedia(
auto query = G()->net_query_creator().create(telegram_api::messages_sendMultiMedia(
flags, false /*ignored*/, false /*ignored*/, false /*ignored*/, std::move(input_peer),
reply_to_message_id.get_server_message_id().get(), std::move(input_single_media), schedule_date)));
reply_to_message_id.get_server_message_id().get(), std::move(input_single_media), schedule_date));
// no quick ack, because file reference errors are very likely to happen
query->debug("send to MessagesManager::MultiSequenceDispatcher");
send_closure(td->messages_manager_->sequence_dispatcher_, &MultiSequenceDispatcher::send_with_callback,
@ -2241,7 +2234,7 @@ class SendMediaActor : public NetActorOnce {
std::move(input_media), text, random_id, std::move(reply_markup),
std::move(entities), schedule_date);
LOG(INFO) << "Send media: " << to_string(request);
auto query = G()->net_query_creator().create(create_storer(request));
auto query = G()->net_query_creator().create(request);
if (G()->shared_config().get_option_boolean("use_quick_ack") && was_uploaded_) {
query->quick_ack_promise_ = PromiseCreator::lambda(
[random_id](Unit) {
@ -2341,7 +2334,7 @@ class UploadMediaQuery : public Td::ResultHandler {
}
send_query(G()->net_query_creator().create(
create_storer(telegram_api::messages_uploadMedia(std::move(input_peer), std::move(input_media)))));
telegram_api::messages_uploadMedia(std::move(input_peer), std::move(input_media))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -2414,7 +2407,7 @@ class SendScheduledMessageActor : public NetActorOnce {
int32 server_message_id = message_id.get_scheduled_server_message_id().get();
auto query = G()->net_query_creator().create(
create_storer(telegram_api::messages_sendScheduledMessages(std::move(input_peer), {server_message_id})));
telegram_api::messages_sendScheduledMessages(std::move(input_peer), {server_message_id}));
query->debug("send to MessagesManager::MultiSequenceDispatcher");
send_closure(td->messages_manager_->sequence_dispatcher_, &MultiSequenceDispatcher::send_with_callback,
@ -2488,9 +2481,9 @@ class EditMessageActor : public NetActorOnce {
int32 server_message_id = schedule_date != 0 ? message_id.get_scheduled_server_message_id().get()
: message_id.get_server_message_id().get();
auto query = G()->net_query_creator().create(create_storer(telegram_api::messages_editMessage(
auto query = G()->net_query_creator().create(telegram_api::messages_editMessage(
flags, false /*ignored*/, std::move(input_peer), server_message_id, text, std::move(input_media),
std::move(reply_markup), std::move(entities), schedule_date)));
std::move(reply_markup), std::move(entities), schedule_date));
query->debug("send to MessagesManager::MultiSequenceDispatcher");
send_closure(td->messages_manager_->sequence_dispatcher_, &MultiSequenceDispatcher::send_with_callback,
@ -2604,9 +2597,9 @@ class SetGameScoreActor : public NetActorOnce {
}
CHECK(input_user != nullptr);
auto query = G()->net_query_creator().create(create_storer(
auto query = G()->net_query_creator().create(
telegram_api::messages_setGameScore(flags, false /*ignored*/, false /*ignored*/, std::move(input_peer),
message_id.get_server_message_id().get(), std::move(input_user), score)));
message_id.get_server_message_id().get(), std::move(input_user), score));
LOG(INFO) << "Set game score to " << score;
@ -2699,8 +2692,8 @@ class GetGameHighScoresQuery : public Td::ResultHandler {
CHECK(input_peer != nullptr);
CHECK(input_user != nullptr);
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_getGameHighScores(
std::move(input_peer), message_id.get_server_message_id().get(), std::move(input_user)))));
send_query(G()->net_query_creator().create(telegram_api::messages_getGameHighScores(
std::move(input_peer), message_id.get_server_message_id().get(), std::move(input_user))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -2790,10 +2783,10 @@ class ForwardMessagesActor : public NetActorOnce {
return;
}
auto query = G()->net_query_creator().create(create_storer(telegram_api::messages_forwardMessages(
auto query = G()->net_query_creator().create(telegram_api::messages_forwardMessages(
flags, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, std::move(from_input_peer),
MessagesManager::get_server_message_ids(message_ids), std::move(random_ids), std::move(to_input_peer),
schedule_date)));
schedule_date));
if (G()->shared_config().get_option_boolean("use_quick_ack")) {
query->quick_ack_promise_ = PromiseCreator::lambda(
[random_ids = random_ids_](Unit) {
@ -2884,7 +2877,7 @@ class SendScreenshotNotificationQuery : public Td::ResultHandler {
CHECK(input_peer != nullptr);
auto query = G()->net_query_creator().create(
create_storer(telegram_api::messages_sendScreenshotNotification(std::move(input_peer), 0, random_id)));
telegram_api::messages_sendScreenshotNotification(std::move(input_peer), 0, random_id));
send_query(std::move(query));
}
@ -2927,8 +2920,8 @@ class SetTypingQuery : public Td::ResultHandler {
auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write);
CHECK(input_peer != nullptr);
auto net_query = G()->net_query_creator().create(
create_storer(telegram_api::messages_setTyping(std::move(input_peer), std::move(action))));
auto net_query =
G()->net_query_creator().create(telegram_api::messages_setTyping(std::move(input_peer), std::move(action)));
auto result = net_query.get_weak();
send_query(std::move(net_query));
return result;
@ -2982,7 +2975,7 @@ class DeleteMessagesQuery : public Td::ResultHandler {
query_count_++;
send_query(G()->net_query_creator().create(
create_storer(telegram_api::messages_deleteMessages(flags, false /*ignored*/, std::move(slice)))));
telegram_api::messages_deleteMessages(flags, false /*ignored*/, std::move(slice))));
}
}
@ -3038,7 +3031,7 @@ class DeleteChannelMessagesQuery : public Td::ResultHandler {
auto input_channel = td->contacts_manager_->get_input_channel(channel_id);
CHECK(input_channel != nullptr);
send_query(G()->net_query_creator().create(
create_storer(telegram_api::channels_deleteMessages(std::move(input_channel), std::move(slice)))));
telegram_api::channels_deleteMessages(std::move(input_channel), std::move(slice))));
}
}
@ -3086,8 +3079,8 @@ class DeleteScheduledMessagesQuery : public Td::ResultHandler {
if (input_peer == nullptr) {
return on_error(0, Status::Error(400, "Can't access the chat"));
}
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_deleteScheduledMessages(
std::move(input_peer), MessagesManager::get_scheduled_server_message_ids(message_ids)))));
send_query(G()->net_query_creator().create(telegram_api::messages_deleteScheduledMessages(
std::move(input_peer), MessagesManager::get_scheduled_server_message_ids(message_ids))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -3119,8 +3112,7 @@ class GetDialogNotifySettingsQuery : public Td::ResultHandler {
dialog_id_ = dialog_id;
auto input_notify_peer = td->messages_manager_->get_input_notify_peer(dialog_id);
CHECK(input_notify_peer != nullptr);
send_query(G()->net_query_creator().create(
create_storer(telegram_api::account_getNotifySettings(std::move(input_notify_peer)))));
send_query(G()->net_query_creator().create(telegram_api::account_getNotifySettings(std::move(input_notify_peer))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -3157,8 +3149,8 @@ class GetNotifySettingsExceptionsQuery : public Td::ResultHandler {
if (compare_sound) {
flags |= telegram_api::account_getNotifyExceptions::COMPARE_SOUND_MASK;
}
send_query(G()->net_query_creator().create(create_storer(
telegram_api::account_getNotifyExceptions(flags, false /* ignored */, std::move(input_notify_peer)))));
send_query(G()->net_query_creator().create(
telegram_api::account_getNotifyExceptions(flags, false /* ignored */, std::move(input_notify_peer))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -3216,8 +3208,7 @@ class GetScopeNotifySettingsQuery : public Td::ResultHandler {
scope_ = scope;
auto input_notify_peer = get_input_notify_peer(scope);
CHECK(input_notify_peer != nullptr);
send_query(G()->net_query_creator().create(
create_storer(telegram_api::account_getNotifySettings(std::move(input_notify_peer)))));
send_query(G()->net_query_creator().create(telegram_api::account_getNotifySettings(std::move(input_notify_peer))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -3266,10 +3257,10 @@ class UpdateDialogNotifySettingsQuery : public Td::ResultHandler {
if (new_settings.silent_send_message) {
flags |= telegram_api::inputPeerNotifySettings::SILENT_MASK;
}
send_query(G()->net_query_creator().create(create_storer(telegram_api::account_updateNotifySettings(
send_query(G()->net_query_creator().create(telegram_api::account_updateNotifySettings(
std::move(input_notify_peer), make_tl_object<telegram_api::inputPeerNotifySettings>(
flags, new_settings.show_preview, new_settings.silent_send_message,
new_settings.mute_until, new_settings.sound)))));
new_settings.mute_until, new_settings.sound))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -3314,10 +3305,10 @@ class UpdateScopeNotifySettingsQuery : public Td::ResultHandler {
int32 flags = telegram_api::inputPeerNotifySettings::MUTE_UNTIL_MASK |
telegram_api::inputPeerNotifySettings::SOUND_MASK |
telegram_api::inputPeerNotifySettings::SHOW_PREVIEWS_MASK;
send_query(G()->net_query_creator().create(create_storer(telegram_api::account_updateNotifySettings(
send_query(G()->net_query_creator().create(telegram_api::account_updateNotifySettings(
std::move(input_notify_peer),
make_tl_object<telegram_api::inputPeerNotifySettings>(flags, new_settings.show_preview, false,
new_settings.mute_until, new_settings.sound)))));
new_settings.mute_until, new_settings.sound))));
scope_ = scope;
}
@ -3355,7 +3346,7 @@ class ResetNotifySettingsQuery : public Td::ResultHandler {
}
void send() {
send_query(G()->net_query_creator().create(create_storer(telegram_api::account_resetNotifySettings())));
send_query(G()->net_query_creator().create(telegram_api::account_resetNotifySettings()));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -3390,8 +3381,7 @@ class GetPeerSettingsQuery : public Td::ResultHandler {
auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read);
CHECK(input_peer != nullptr);
send_query(
G()->net_query_creator().create(create_storer(telegram_api::messages_getPeerSettings(std::move(input_peer)))));
send_query(G()->net_query_creator().create(telegram_api::messages_getPeerSettings(std::move(input_peer))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -3426,11 +3416,9 @@ class UpdatePeerSettingsQuery : public Td::ResultHandler {
}
if (is_spam_dialog) {
send_query(
G()->net_query_creator().create(create_storer(telegram_api::messages_reportSpam(std::move(input_peer)))));
send_query(G()->net_query_creator().create(telegram_api::messages_reportSpam(std::move(input_peer))));
} else {
send_query(G()->net_query_creator().create(
create_storer(telegram_api::messages_hidePeerSettingsBar(std::move(input_peer)))));
send_query(G()->net_query_creator().create(telegram_api::messages_hidePeerSettingsBar(std::move(input_peer))));
}
}
@ -3475,8 +3463,7 @@ class ReportEncryptedSpamQuery : public Td::ResultHandler {
CHECK(input_peer != nullptr);
LOG(INFO) << "Report spam in " << to_string(input_peer);
send_query(G()->net_query_creator().create(
create_storer(telegram_api::messages_reportEncryptedSpam(std::move(input_peer)))));
send_query(G()->net_query_creator().create(telegram_api::messages_reportEncryptedSpam(std::move(input_peer))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -3521,10 +3508,10 @@ class ReportPeerQuery : public Td::ResultHandler {
if (message_ids.empty()) {
send_query(G()->net_query_creator().create(
create_storer(telegram_api::account_reportPeer(std::move(input_peer), std::move(report_reason)))));
telegram_api::account_reportPeer(std::move(input_peer), std::move(report_reason))));
} else {
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_report(
std::move(input_peer), MessagesManager::get_server_message_ids(message_ids), std::move(report_reason)))));
send_query(G()->net_query_creator().create(telegram_api::messages_report(
std::move(input_peer), MessagesManager::get_server_message_ids(message_ids), std::move(report_reason))));
}
}
@ -3570,8 +3557,7 @@ class EditPeerFoldersQuery : public Td::ResultHandler {
vector<telegram_api::object_ptr<telegram_api::inputFolderPeer>> input_folder_peers;
input_folder_peers.push_back(
telegram_api::make_object<telegram_api::inputFolderPeer>(std::move(input_peer), folder_id.get()));
send_query(G()->net_query_creator().create(
create_storer(telegram_api::folders_editPeerFolders(std::move(input_folder_peers)))));
send_query(G()->net_query_creator().create(telegram_api::folders_editPeerFolders(std::move(input_folder_peers))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -3614,8 +3600,8 @@ class GetStatsUrlQuery : public Td::ResultHandler {
if (is_dark) {
flags |= telegram_api::messages_getStatsURL::DARK_MASK;
}
send_query(G()->net_query_creator().create(create_storer(
telegram_api::messages_getStatsURL(flags, false /*ignored*/, std::move(input_peer), parameters))));
send_query(G()->net_query_creator().create(
telegram_api::messages_getStatsURL(flags, false /*ignored*/, std::move(input_peer), parameters)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -3649,8 +3635,8 @@ class RequestUrlAuthQuery : public Td::ResultHandler {
dialog_id_ = dialog_id;
auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read);
CHECK(input_peer != nullptr);
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_requestUrlAuth(
std::move(input_peer), message_id.get_server_message_id().get(), button_id))));
send_query(G()->net_query_creator().create(telegram_api::messages_requestUrlAuth(
std::move(input_peer), message_id.get_server_message_id().get(), button_id)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -3713,8 +3699,8 @@ class AcceptUrlAuthQuery : public Td::ResultHandler {
if (allow_write_access) {
flags |= telegram_api::messages_acceptUrlAuth::WRITE_ALLOWED_MASK;
}
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_acceptUrlAuth(
flags, false /*ignored*/, std::move(input_peer), message_id.get_server_message_id().get(), button_id))));
send_query(G()->net_query_creator().create(telegram_api::messages_acceptUrlAuth(
flags, false /*ignored*/, std::move(input_peer), message_id.get_server_message_id().get(), button_id)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -3766,9 +3752,9 @@ class GetChannelDifferenceQuery : public Td::ResultHandler {
if (force) {
flags |= telegram_api::updates_getChannelDifference::FORCE_MASK;
}
send_query(G()->net_query_creator().create(create_storer(telegram_api::updates_getChannelDifference(
send_query(G()->net_query_creator().create(telegram_api::updates_getChannelDifference(
flags, false /*ignored*/, std::move(input_channel), make_tl_object<telegram_api::channelMessagesFilterEmpty>(),
pts, limit))));
pts, limit)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -3801,7 +3787,7 @@ class ResolveUsernameQuery : public Td::ResultHandler {
username_ = username;
LOG(INFO) << "Send ResolveUsernameQuery with username = " << username;
send_query(G()->net_query_creator().create(create_storer(telegram_api::contacts_resolveUsername(username))));
send_query(G()->net_query_creator().create(telegram_api::contacts_resolveUsername(username)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -3854,8 +3840,8 @@ class GetChannelAdminLogQuery : public Td::ResultHandler {
flags |= telegram_api::channels_getAdminLog::ADMINS_MASK;
}
send_query(G()->net_query_creator().create(create_storer(telegram_api::channels_getAdminLog(
flags, std::move(input_channel), query, std::move(filter), std::move(input_users), from_event_id, 0, limit))));
send_query(G()->net_query_creator().create(telegram_api::channels_getAdminLog(
flags, std::move(input_channel), query, std::move(filter), std::move(input_users), from_event_id, 0, limit)));
}
void on_result(uint64 id, BufferSlice packet) override {

View File

@ -73,8 +73,7 @@ class SetContactSignUpNotificationQuery : public Td::ResultHandler {
}
void send(bool is_disabled) {
send_query(G()->net_query_creator().create(
create_storer(telegram_api::account_setContactSignUpNotification(is_disabled))));
send_query(G()->net_query_creator().create(telegram_api::account_setContactSignUpNotification(is_disabled)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -102,7 +101,7 @@ class GetContactSignUpNotificationQuery : public Td::ResultHandler {
}
void send() {
send_query(G()->net_query_creator().create(create_storer(telegram_api::account_getContactSignUpNotification())));
send_query(G()->net_query_creator().create(telegram_api::account_getContactSignUpNotification()));
}
void on_result(uint64 id, BufferSlice packet) override {

View File

@ -275,20 +275,19 @@ void PasswordManager::drop_temp_password() {
void PasswordManager::do_create_temp_password(string password, int32 timeout, PasswordState &&password_state,
Promise<TempPasswordState> promise) {
auto hash = get_input_check_password(password, password_state);
send_with_promise(
G()->net_query_creator().create(create_storer(telegram_api::account_getTmpPassword(std::move(hash), timeout))),
PromiseCreator::lambda([promise = std::move(promise)](Result<NetQueryPtr> r_query) mutable {
auto r_result = fetch_result<telegram_api::account_getTmpPassword>(std::move(r_query));
if (r_result.is_error()) {
return promise.set_error(r_result.move_as_error());
}
auto result = r_result.move_as_ok();
TempPasswordState res;
res.has_temp_password = true;
res.temp_password = result->tmp_password_.as_slice().str();
res.valid_until = result->valid_until_;
promise.set_value(std::move(res));
}));
send_with_promise(G()->net_query_creator().create(telegram_api::account_getTmpPassword(std::move(hash), timeout)),
PromiseCreator::lambda([promise = std::move(promise)](Result<NetQueryPtr> r_query) mutable {
auto r_result = fetch_result<telegram_api::account_getTmpPassword>(std::move(r_query));
if (r_result.is_error()) {
return promise.set_error(r_result.move_as_error());
}
auto result = r_result.move_as_ok();
TempPasswordState res;
res.has_temp_password = true;
res.temp_password = result->tmp_password_.as_slice().str();
res.valid_until = result->valid_until_;
promise.set_value(std::move(res));
}));
}
void PasswordManager::on_finish_create_temp_password(Result<TempPasswordState> result, bool /*dummy*/) {
@ -352,28 +351,28 @@ void PasswordManager::do_get_full_state(string password, PasswordState state, Pr
}
auto hash = get_input_check_password(password, state);
send_with_promise(
G()->net_query_creator().create(create_storer(telegram_api::account_getPasswordSettings(std::move(hash)))),
PromiseCreator::lambda(
[promise = std::move(promise), state = std::move(state), password](Result<NetQueryPtr> r_query) mutable {
promise.set_result([&]() -> Result<PasswordFullState> {
TRY_RESULT(result, fetch_result<telegram_api::account_getPasswordSettings>(std::move(r_query)));
LOG(INFO) << "Receive password settings: " << to_string(result);
PasswordPrivateState private_state;
private_state.email = std::move(result->email_);
send_with_promise(G()->net_query_creator().create(telegram_api::account_getPasswordSettings(std::move(hash))),
PromiseCreator::lambda([promise = std::move(promise), state = std::move(state),
password](Result<NetQueryPtr> r_query) mutable {
promise.set_result([&]() -> Result<PasswordFullState> {
TRY_RESULT(result, fetch_result<telegram_api::account_getPasswordSettings>(std::move(r_query)));
LOG(INFO) << "Receive password settings: " << to_string(result);
PasswordPrivateState private_state;
private_state.email = std::move(result->email_);
if (result->secure_settings_ != nullptr) {
auto r_secret = decrypt_secure_secret(password, std::move(result->secure_settings_->secure_algo_),
result->secure_settings_->secure_secret_.as_slice(),
result->secure_settings_->secure_secret_id_);
if (r_secret.is_ok()) {
private_state.secret = r_secret.move_as_ok();
}
}
if (result->secure_settings_ != nullptr) {
auto r_secret =
decrypt_secure_secret(password, std::move(result->secure_settings_->secure_algo_),
result->secure_settings_->secure_secret_.as_slice(),
result->secure_settings_->secure_secret_id_);
if (r_secret.is_ok()) {
private_state.secret = r_secret.move_as_ok();
}
}
return PasswordFullState{std::move(state), std::move(private_state)};
}());
}));
return PasswordFullState{std::move(state), std::move(private_state)};
}());
}));
}
void PasswordManager::get_recovery_email_address(string password,
@ -390,8 +389,7 @@ void PasswordManager::get_recovery_email_address(string password,
}
void PasswordManager::check_recovery_email_address_code(string code, Promise<State> promise) {
auto query =
G()->net_query_creator().create(create_storer(telegram_api::account_confirmPasswordEmail(std::move(code))));
auto query = G()->net_query_creator().create(telegram_api::account_confirmPasswordEmail(std::move(code)));
send_with_promise(std::move(query), PromiseCreator::lambda([actor_id = actor_id(this), promise = std::move(promise)](
Result<NetQueryPtr> r_query) mutable {
auto r_result = fetch_result<telegram_api::account_confirmPasswordEmail>(std::move(r_query));
@ -404,7 +402,7 @@ void PasswordManager::check_recovery_email_address_code(string code, Promise<Sta
}
void PasswordManager::resend_recovery_email_address_code(Promise<State> promise) {
auto query = G()->net_query_creator().create(create_storer(telegram_api::account_resendPasswordEmail()));
auto query = G()->net_query_creator().create(telegram_api::account_resendPasswordEmail());
send_with_promise(std::move(query), PromiseCreator::lambda([actor_id = actor_id(this), promise = std::move(promise)](
Result<NetQueryPtr> r_query) mutable {
auto r_result = fetch_result<telegram_api::account_resendPasswordEmail>(std::move(r_query));
@ -418,8 +416,7 @@ void PasswordManager::resend_recovery_email_address_code(Promise<State> promise)
void PasswordManager::send_email_address_verification_code(
string email, Promise<td_api::object_ptr<td_api::emailAddressAuthenticationCodeInfo>> promise) {
last_verified_email_address_ = email;
auto query =
G()->net_query_creator().create(create_storer(telegram_api::account_sendVerifyEmailCode(std::move(email))));
auto query = G()->net_query_creator().create(telegram_api::account_sendVerifyEmailCode(std::move(email)));
send_with_promise(
std::move(query), PromiseCreator::lambda([promise = std::move(promise)](Result<NetQueryPtr> r_query) mutable {
auto r_result = fetch_result<telegram_api::account_sendVerifyEmailCode>(std::move(r_query));
@ -448,8 +445,8 @@ void PasswordManager::check_email_address_verification_code(string code, Promise
if (last_verified_email_address_.empty()) {
return promise.set_error(Status::Error(400, "No email address verification was sent"));
}
auto query = G()->net_query_creator().create(
create_storer(telegram_api::account_verifyEmail(last_verified_email_address_, std::move(code))));
auto query =
G()->net_query_creator().create(telegram_api::account_verifyEmail(last_verified_email_address_, std::move(code)));
send_with_promise(std::move(query),
PromiseCreator::lambda([promise = std::move(promise)](Result<NetQueryPtr> r_query) mutable {
auto r_result = fetch_result<telegram_api::account_verifyEmail>(std::move(r_query));
@ -464,7 +461,7 @@ void PasswordManager::request_password_recovery(
Promise<td_api::object_ptr<td_api::emailAddressAuthenticationCodeInfo>> promise) {
// is called only after authoriation
send_with_promise(
G()->net_query_creator().create(create_storer(telegram_api::auth_requestPasswordRecovery())),
G()->net_query_creator().create(telegram_api::auth_requestPasswordRecovery()),
PromiseCreator::lambda([promise = std::move(promise)](Result<NetQueryPtr> r_query) mutable {
auto r_result = fetch_result<telegram_api::auth_requestPasswordRecovery>(std::move(r_query));
if (r_result.is_error()) {
@ -477,7 +474,7 @@ void PasswordManager::request_password_recovery(
void PasswordManager::recover_password(string code, Promise<State> promise) {
// is called only after authoriation
send_with_promise(G()->net_query_creator().create(create_storer(telegram_api::auth_recoverPassword(std::move(code)))),
send_with_promise(G()->net_query_creator().create(telegram_api::auth_recoverPassword(std::move(code))),
PromiseCreator::lambda(
[actor_id = actor_id(this), promise = std::move(promise)](Result<NetQueryPtr> r_query) mutable {
auto r_result = fetch_result<telegram_api::auth_recoverPassword>(std::move(r_query));
@ -592,7 +589,7 @@ void PasswordManager::do_update_password_settings_impl(UpdateSettings update_set
}
auto current_hash = get_input_check_password(state.has_password ? update_settings.current_password : Slice(), state);
auto query = G()->net_query_creator().create(
create_storer(telegram_api::account_updatePasswordSettings(std::move(current_hash), std::move(new_settings))));
telegram_api::account_updatePasswordSettings(std::move(current_hash), std::move(new_settings)));
send_with_promise(std::move(query), PromiseCreator::lambda([actor_id = actor_id(this), promise = std::move(promise)](
Result<NetQueryPtr> r_query) mutable {
@ -633,7 +630,7 @@ void PasswordManager::get_state(Promise<State> promise) {
}
void PasswordManager::do_get_state(Promise<PasswordState> promise) {
auto query = G()->net_query_creator().create(create_storer(telegram_api::account_getPassword()));
auto query = G()->net_query_creator().create(telegram_api::account_getPassword());
send_with_promise(
std::move(query), PromiseCreator::lambda([actor_id = actor_id(this), code_length = last_code_length_,
promise = std::move(promise)](Result<NetQueryPtr> r_query) mutable {
@ -743,7 +740,7 @@ void PasswordManager::get_ton_wallet_password_salt(Promise<td_api::object_ptr<td
get_ton_wallet_password_salt_queries_.push_back(std::move(promise));
if (get_ton_wallet_password_salt_queries_.size() == 1) {
send_with_promise(G()->net_query_creator().create(create_storer(telegram_api::wallet_getKeySecretSalt(false))),
send_with_promise(G()->net_query_creator().create(telegram_api::wallet_getKeySecretSalt(false)),
PromiseCreator::lambda([actor_id = actor_id(this)](Result<NetQueryPtr> r_query) mutable {
auto r_result = fetch_result<telegram_api::wallet_getKeySecretSalt>(std::move(r_query));
send_closure(actor_id, &PasswordManager::on_get_ton_wallet_password_salt, std::move(r_result));

View File

@ -43,8 +43,8 @@ class SetBotShippingAnswerQuery : public Td::ResultHandler {
if (!shipping_options.empty()) {
flags |= telegram_api::messages_setBotShippingResults::SHIPPING_OPTIONS_MASK;
}
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_setBotShippingResults(
flags, shipping_query_id, error_message, std::move(shipping_options)))));
send_query(G()->net_query_creator().create(telegram_api::messages_setBotShippingResults(
flags, shipping_query_id, error_message, std::move(shipping_options))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -80,8 +80,8 @@ class SetBotPreCheckoutAnswerQuery : public Td::ResultHandler {
flags |= telegram_api::messages_setBotPrecheckoutResults::SUCCESS_MASK;
}
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_setBotPrecheckoutResults(
flags, false /*ignored*/, pre_checkout_query_id, error_message))));
send_query(G()->net_query_creator().create(telegram_api::messages_setBotPrecheckoutResults(
flags, false /*ignored*/, pre_checkout_query_id, error_message)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -258,8 +258,7 @@ class GetPaymentFormQuery : public Td::ResultHandler {
}
void send(ServerMessageId server_message_id) {
send_query(
G()->net_query_creator().create(create_storer(telegram_api::payments_getPaymentForm(server_message_id.get()))));
send_query(G()->net_query_creator().create(telegram_api::payments_getPaymentForm(server_message_id.get())));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -306,8 +305,8 @@ class ValidateRequestedInfoQuery : public Td::ResultHandler {
requested_info = make_tl_object<telegram_api::paymentRequestedInfo>();
requested_info->flags_ = 0;
}
send_query(G()->net_query_creator().create(create_storer(telegram_api::payments_validateRequestedInfo(
flags, false /*ignored*/, server_message_id.get(), std::move(requested_info)))));
send_query(G()->net_query_creator().create(telegram_api::payments_validateRequestedInfo(
flags, false /*ignored*/, server_message_id.get(), std::move(requested_info))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -347,8 +346,8 @@ class SendPaymentFormQuery : public Td::ResultHandler {
if (!shipping_option_id.empty()) {
flags |= telegram_api::payments_sendPaymentForm::SHIPPING_OPTION_ID_MASK;
}
send_query(G()->net_query_creator().create(create_storer(telegram_api::payments_sendPaymentForm(
flags, server_message_id.get(), order_info_id, shipping_option_id, std::move(input_credentials)))));
send_query(G()->net_query_creator().create(telegram_api::payments_sendPaymentForm(
flags, server_message_id.get(), order_info_id, shipping_option_id, std::move(input_credentials))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -391,8 +390,7 @@ class GetPaymentReceiptQuery : public Td::ResultHandler {
}
void send(ServerMessageId server_message_id) {
send_query(G()->net_query_creator().create(
create_storer(telegram_api::payments_getPaymentReceipt(server_message_id.get()))));
send_query(G()->net_query_creator().create(telegram_api::payments_getPaymentReceipt(server_message_id.get())));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -434,7 +432,7 @@ class GetSavedInfoQuery : public Td::ResultHandler {
}
void send() {
send_query(G()->net_query_creator().create(create_storer(telegram_api::payments_getSavedInfo())));
send_query(G()->net_query_creator().create(telegram_api::payments_getSavedInfo()));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -470,7 +468,7 @@ class ClearSavedInfoQuery : public Td::ResultHandler {
flags |= telegram_api::payments_clearSavedInfo::INFO_MASK;
}
send_query(G()->net_query_creator().create(
create_storer(telegram_api::payments_clearSavedInfo(flags, false /*ignored*/, false /*ignored*/))));
telegram_api::payments_clearSavedInfo(flags, false /*ignored*/, false /*ignored*/)));
}
void on_result(uint64 id, BufferSlice packet) override {

View File

@ -39,7 +39,7 @@ PhoneNumberManager::PhoneNumberManager(PhoneNumberManager::Type type, ActorShare
template <class T>
void PhoneNumberManager::process_send_code_result(uint64 query_id, const T &send_code) {
on_new_query(query_id);
start_net_query(NetQueryType::SendCode, G()->net_query_creator().create(create_storer(send_code)));
start_net_query(NetQueryType::SendCode, G()->net_query_creator().create(send_code));
}
void PhoneNumberManager::set_phone_number(uint64 query_id, string phone_number, Settings settings) {
@ -96,7 +96,7 @@ void PhoneNumberManager::resend_authentication_code(uint64 query_id) {
template <class T>
void PhoneNumberManager::send_new_check_code_query(const T &query) {
start_net_query(NetQueryType::CheckCode, G()->net_query_creator().create(create_storer(query)));
start_net_query(NetQueryType::CheckCode, G()->net_query_creator().create(query));
}
void PhoneNumberManager::check_code(uint64 query_id, string code) {

View File

@ -64,8 +64,8 @@ class GetPollResultsQuery : public Td::ResultHandler {
}
auto message_id = full_message_id.get_message_id().get_server_message_id().get();
send_query(G()->net_query_creator().create(
create_storer(telegram_api::messages_getPollResults(std::move(input_peer), message_id))));
send_query(
G()->net_query_creator().create(telegram_api::messages_getPollResults(std::move(input_peer), message_id)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -112,8 +112,8 @@ class GetPollVotersQuery : public Td::ResultHandler {
}
auto message_id = full_message_id.get_message_id().get_server_message_id().get();
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_getPollVotes(
flags, std::move(input_peer), message_id, std::move(option), offset, limit))));
send_query(G()->net_query_creator().create(telegram_api::messages_getPollVotes(
flags, std::move(input_peer), message_id, std::move(option), offset, limit)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -152,7 +152,7 @@ class SetPollAnswerActor : public NetActorOnce {
auto message_id = full_message_id.get_message_id().get_server_message_id().get();
auto query = G()->net_query_creator().create(
create_storer(telegram_api::messages_sendVote(std::move(input_peer), message_id, std::move(options))));
telegram_api::messages_sendVote(std::move(input_peer), message_id, std::move(options)));
*query_ref = query.get_weak();
auto sequence_id = -1;
send_closure(td->messages_manager_->sequence_dispatcher_, &MultiSequenceDispatcher::send_with_callback,
@ -203,9 +203,9 @@ class StopPollActor : public NetActorOnce {
poll->flags_ |= telegram_api::poll::CLOSED_MASK;
auto input_media =
telegram_api::make_object<telegram_api::inputMediaPoll>(0, std::move(poll), vector<BufferSlice>());
auto query = G()->net_query_creator().create(create_storer(telegram_api::messages_editMessage(
auto query = G()->net_query_creator().create(telegram_api::messages_editMessage(
flags, false /*ignored*/, std::move(input_peer), message_id, string(), std::move(input_media),
std::move(input_reply_markup), vector<tl_object_ptr<telegram_api::MessageEntity>>(), 0)));
std::move(input_reply_markup), vector<tl_object_ptr<telegram_api::MessageEntity>>(), 0));
auto sequence_id = -1;
send_closure(td->messages_manager_->sequence_dispatcher_, &MultiSequenceDispatcher::send_with_callback,
std::move(query), actor_shared(this), sequence_id);

View File

@ -409,8 +409,8 @@ void PrivacyManager::get_privacy(tl_object_ptr<td_api::UserPrivacySetting> key,
// query has already been sent, just wait for the result
return;
}
auto net_query = G()->net_query_creator().create(
create_storer(telegram_api::account_getPrivacy(user_privacy_setting.as_telegram_api())));
auto net_query =
G()->net_query_creator().create(telegram_api::account_getPrivacy(user_privacy_setting.as_telegram_api()));
send_with_promise(std::move(net_query),
PromiseCreator::lambda([this, user_privacy_setting](Result<NetQueryPtr> x_net_query) {
@ -442,8 +442,8 @@ void PrivacyManager::set_privacy(tl_object_ptr<td_api::UserPrivacySetting> key,
// TODO cancel previous query
return promise.set_error(Status::Error(5, "Another set_privacy query is active"));
}
auto net_query = G()->net_query_creator().create(create_storer(
telegram_api::account_setPrivacy(user_privacy_setting.as_telegram_api(), privacy_rules.as_telegram_api())));
auto net_query = G()->net_query_creator().create(
telegram_api::account_setPrivacy(user_privacy_setting.as_telegram_api(), privacy_rules.as_telegram_api()));
info.has_set_query = true;
send_with_promise(std::move(net_query),

View File

@ -136,7 +136,7 @@ class SetSecureValueErrorsQuery : public Td::ResultHandler {
void send(tl_object_ptr<telegram_api::InputUser> input_user,
vector<tl_object_ptr<telegram_api::SecureValueError>> input_errors) {
send_query(G()->net_query_creator().create(
create_storer(telegram_api::users_setSecureValueErrors(std::move(input_user), std::move(input_errors)))));
telegram_api::users_setSecureValueErrors(std::move(input_user), std::move(input_errors))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -208,7 +208,7 @@ void GetSecureValue::start_up() {
std::vector<telegram_api::object_ptr<telegram_api::SecureValueType>> types;
types.push_back(get_input_secure_value_type(type_));
auto query = G()->net_query_creator().create(create_storer(telegram_api::account_getSecureValue(std::move(types))));
auto query = G()->net_query_creator().create(telegram_api::account_getSecureValue(std::move(types)));
G()->net_query_dispatcher().dispatch_with_callback(std::move(query), actor_shared(this));
@ -288,7 +288,7 @@ void GetAllSecureValues::loop() {
}
void GetAllSecureValues::start_up() {
auto query = G()->net_query_creator().create(create_storer(telegram_api::account_getAllSecureValues()));
auto query = G()->net_query_creator().create(telegram_api::account_getAllSecureValues());
G()->net_query_dispatcher().dispatch_with_callback(std::move(query), actor_shared(this));
@ -572,7 +572,7 @@ void SetSecureValue::loop() {
files_to_upload_, front_side_, reverse_side_, selfie_, translations_to_upload_);
auto save_secure_value =
telegram_api::account_saveSecureValue(std::move(input_secure_value), secret_.value().get_hash());
auto query = G()->net_query_creator().create(create_storer(save_secure_value));
auto query = G()->net_query_creator().create(save_secure_value);
G()->net_query_dispatcher().dispatch_with_callback(std::move(query), actor_shared(this));
state_ = State::WaitSetValue;
@ -664,8 +664,7 @@ class DeleteSecureValue : public NetQueryCallback {
void start_up() override {
std::vector<telegram_api::object_ptr<telegram_api::SecureValueType>> types;
types.push_back(get_input_secure_value_type(type_));
auto query =
G()->net_query_creator().create(create_storer(telegram_api::account_deleteSecureValue(std::move(types))));
auto query = G()->net_query_creator().create(telegram_api::account_deleteSecureValue(std::move(types)));
G()->net_query_dispatcher().dispatch_with_callback(std::move(query), actor_shared(this));
}
@ -710,7 +709,7 @@ class GetPassportAuthorizationForm : public NetQueryCallback {
void start_up() override {
auto account_get_authorization_form =
telegram_api::account_getAuthorizationForm(bot_user_id_.get(), std::move(scope_), std::move(public_key_));
auto query = G()->net_query_creator().create(create_storer(account_get_authorization_form));
auto query = G()->net_query_creator().create(account_get_authorization_form);
G()->net_query_dispatcher().dispatch_with_callback(std::move(query), actor_shared(this));
}
@ -764,7 +763,7 @@ class GetPassportConfig : public NetQueryCallback {
Promise<td_api::object_ptr<td_api::text>> promise_;
void start_up() override {
auto query = G()->net_query_creator().create(create_storer(telegram_api::help_getPassportConfig(0)));
auto query = G()->net_query_creator().create(telegram_api::help_getPassportConfig(0));
G()->net_query_dispatcher().dispatch_with_callback(std::move(query), actor_shared(this));
}
@ -1269,7 +1268,7 @@ void SecureManager::send_passport_authorization_form(int32 authorization_form_id
auto td_query = telegram_api::account_acceptAuthorization(
it->second.bot_user_id.get(), it->second.scope, it->second.public_key, std::move(hashes),
get_secure_credentials_encrypted_object(r_encrypted_credentials.move_as_ok()));
auto query = G()->net_query_creator().create(create_storer(td_query));
auto query = G()->net_query_creator().create(td_query);
auto new_promise =
PromiseCreator::lambda([promise = std::move(promise)](Result<NetQueryPtr> r_net_query_ptr) mutable {
auto r_result = fetch_result<telegram_api::account_acceptAuthorization>(std::move(r_net_query_ptr));

View File

@ -61,9 +61,9 @@ class GetAllStickersQuery : public Td::ResultHandler {
void send(bool is_masks, int32 hash) {
is_masks_ = is_masks;
if (is_masks) {
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_getMaskStickers(hash))));
send_query(G()->net_query_creator().create(telegram_api::messages_getMaskStickers(hash)));
} else {
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_getAllStickers(hash))));
send_query(G()->net_query_creator().create(telegram_api::messages_getAllStickers(hash)));
}
}
@ -95,7 +95,7 @@ class SearchStickersQuery : public Td::ResultHandler {
public:
void send(string emoji) {
emoji_ = std::move(emoji);
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_getStickers(emoji_, 0))));
send_query(G()->net_query_creator().create(telegram_api::messages_getStickers(emoji_, 0)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -125,8 +125,8 @@ class GetEmojiKeywordsLanguageQuery : public Td::ResultHandler {
}
void send(vector<string> &&language_codes) {
send_query(G()->net_query_creator().create(
create_storer(telegram_api::messages_getEmojiKeywordsLanguages(std::move(language_codes)))));
send_query(
G()->net_query_creator().create(telegram_api::messages_getEmojiKeywordsLanguages(std::move(language_codes))));
}
void on_result(uint64 id, BufferSlice packet) override {
auto result_ptr = fetch_result<telegram_api::messages_getEmojiKeywordsLanguages>(packet);
@ -153,7 +153,7 @@ class GetEmojiKeywordsQuery : public Td::ResultHandler {
}
void send(const string &language_code) {
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_getEmojiKeywords(language_code))));
send_query(G()->net_query_creator().create(telegram_api::messages_getEmojiKeywords(language_code)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -180,8 +180,8 @@ class GetEmojiKeywordsDifferenceQuery : public Td::ResultHandler {
}
void send(const string &language_code, int32 version) {
send_query(G()->net_query_creator().create(
create_storer(telegram_api::messages_getEmojiKeywordsDifference(language_code, version))));
send_query(
G()->net_query_creator().create(telegram_api::messages_getEmojiKeywordsDifference(language_code, version)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -207,7 +207,7 @@ class GetEmojiUrlQuery : public Td::ResultHandler {
}
void send(const string &language_code) {
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_getEmojiURL(language_code))));
send_query(G()->net_query_creator().create(telegram_api::messages_getEmojiURL(language_code)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -245,8 +245,8 @@ class GetArchivedStickerSetsQuery : public Td::ResultHandler {
}
is_masks_ = is_masks;
send_query(G()->net_query_creator().create(create_storer(
telegram_api::messages_getArchivedStickers(flags, is_masks /*ignored*/, offset_sticker_set_id.get(), limit))));
send_query(G()->net_query_creator().create(
telegram_api::messages_getArchivedStickers(flags, is_masks /*ignored*/, offset_sticker_set_id.get(), limit)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -272,7 +272,7 @@ class GetFeaturedStickerSetsQuery : public Td::ResultHandler {
public:
void send(int32 hash) {
LOG(INFO) << "Get featured sticker sets with hash " << hash;
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_getFeaturedStickers(hash))));
send_query(G()->net_query_creator().create(telegram_api::messages_getFeaturedStickers(hash)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -304,8 +304,8 @@ class GetAttachedStickerSetsQuery : public Td::ResultHandler {
tl_object_ptr<telegram_api::InputStickeredMedia> &&input_stickered_media) {
file_id_ = file_id;
file_reference_ = std::move(file_reference);
send_query(G()->net_query_creator().create(
create_storer(telegram_api::messages_getAttachedStickers(std::move(input_stickered_media)))));
send_query(
G()->net_query_creator().create(telegram_api::messages_getAttachedStickers(std::move(input_stickered_media))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -354,7 +354,7 @@ class GetRecentStickersQuery : public Td::ResultHandler {
}
send_query(G()->net_query_creator().create(
create_storer(telegram_api::messages_getRecentStickers(flags, is_attached /*ignored*/, hash))));
telegram_api::messages_getRecentStickers(flags, is_attached /*ignored*/, hash)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -402,8 +402,8 @@ class SaveRecentStickerQuery : public Td::ResultHandler {
flags |= telegram_api::messages_saveRecentSticker::ATTACHED_MASK;
}
send_query(G()->net_query_creator().create(create_storer(
telegram_api::messages_saveRecentSticker(flags, is_attached /*ignored*/, std::move(input_document), unsave))));
send_query(G()->net_query_creator().create(
telegram_api::messages_saveRecentSticker(flags, is_attached /*ignored*/, std::move(input_document), unsave)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -462,8 +462,8 @@ class ClearRecentStickersQuery : public Td::ResultHandler {
flags |= telegram_api::messages_clearRecentStickers::ATTACHED_MASK;
}
send_query(G()->net_query_creator().create(
create_storer(telegram_api::messages_clearRecentStickers(flags, is_attached /*ignored*/))));
send_query(
G()->net_query_creator().create(telegram_api::messages_clearRecentStickers(flags, is_attached /*ignored*/)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -497,7 +497,7 @@ class GetFavedStickersQuery : public Td::ResultHandler {
void send(bool is_repair, int32 hash) {
is_repair_ = is_repair;
LOG(INFO) << "Send get favorite stickers request with hash = " << hash;
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_getFavedStickers(hash))));
send_query(G()->net_query_creator().create(telegram_api::messages_getFavedStickers(hash)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -536,8 +536,7 @@ class FaveStickerQuery : public Td::ResultHandler {
file_reference_ = input_document->file_reference_.as_slice().str();
unsave_ = unsave;
send_query(G()->net_query_creator().create(
create_storer(telegram_api::messages_faveSticker(std::move(input_document), unsave))));
send_query(G()->net_query_creator().create(telegram_api::messages_faveSticker(std::move(input_document), unsave)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -590,8 +589,8 @@ class ReorderStickerSetsQuery : public Td::ResultHandler {
if (is_masks) {
flags |= telegram_api::messages_reorderStickerSets::MASKS_MASK;
}
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_reorderStickerSets(
flags, is_masks /*ignored*/, StickersManager::convert_sticker_set_ids(sticker_set_ids)))));
send_query(G()->net_query_creator().create(telegram_api::messages_reorderStickerSets(
flags, is_masks /*ignored*/, StickersManager::convert_sticker_set_ids(sticker_set_ids))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -630,8 +629,7 @@ class GetStickerSetQuery : public Td::ResultHandler {
static_cast<const telegram_api::inputStickerSetShortName *>(input_sticker_set.get())->short_name_;
}
LOG(INFO) << "Load " << sticker_set_id << " from server: " << to_string(input_sticker_set);
send_query(G()->net_query_creator().create(
create_storer(telegram_api::messages_getStickerSet(std::move(input_sticker_set)))));
send_query(G()->net_query_creator().create(telegram_api::messages_getStickerSet(std::move(input_sticker_set))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -667,8 +665,8 @@ class GetStickerSetQuery : public Td::ResultHandler {
class ReloadAnimatedEmojiStickerSetQuery : public Td::ResultHandler {
public:
void send() {
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_getStickerSet(
telegram_api::make_object<telegram_api::inputStickerSetAnimatedEmoji>()))));
send_query(G()->net_query_creator().create(telegram_api::messages_getStickerSet(
telegram_api::make_object<telegram_api::inputStickerSetAnimatedEmoji>())));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -695,8 +693,8 @@ class SearchStickerSetsQuery : public Td::ResultHandler {
public:
void send(string query) {
query_ = std::move(query);
send_query(G()->net_query_creator().create(
create_storer(telegram_api::messages_searchStickerSets(0, false /*ignored*/, query_, 0))));
send_query(
G()->net_query_creator().create(telegram_api::messages_searchStickerSets(0, false /*ignored*/, query_, 0)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -730,8 +728,8 @@ class InstallStickerSetQuery : public Td::ResultHandler {
void send(StickerSetId set_id, tl_object_ptr<telegram_api::InputStickerSet> &&input_set, bool is_archived) {
set_id_ = set_id;
is_archived_ = is_archived;
send_query(G()->net_query_creator().create(
create_storer(telegram_api::messages_installStickerSet(std::move(input_set), is_archived))));
send_query(
G()->net_query_creator().create(telegram_api::messages_installStickerSet(std::move(input_set), is_archived)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -761,8 +759,7 @@ class UninstallStickerSetQuery : public Td::ResultHandler {
void send(StickerSetId set_id, tl_object_ptr<telegram_api::InputStickerSet> &&input_set) {
set_id_ = set_id;
send_query(G()->net_query_creator().create(
create_storer(telegram_api::messages_uninstallStickerSet(std::move(input_set)))));
send_query(G()->net_query_creator().create(telegram_api::messages_uninstallStickerSet(std::move(input_set))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -791,8 +788,8 @@ class ReadFeaturedStickerSetsQuery : public Td::ResultHandler {
public:
void send(vector<StickerSetId> sticker_set_ids) {
LOG(INFO) << "Read featured sticker sets " << format::as_array(sticker_set_ids);
send_query(G()->net_query_creator().create(create_storer(
telegram_api::messages_readFeaturedStickers(StickersManager::convert_sticker_set_ids(sticker_set_ids)))));
send_query(G()->net_query_creator().create(
telegram_api::messages_readFeaturedStickers(StickersManager::convert_sticker_set_ids(sticker_set_ids))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -829,7 +826,7 @@ class UploadStickerFileQuery : public Td::ResultHandler {
file_id_ = file_id;
was_uploaded_ = FileManager::extract_was_uploaded(input_media);
send_query(G()->net_query_creator().create(
create_storer(telegram_api::messages_uploadMedia(std::move(input_peer), std::move(input_media)))));
telegram_api::messages_uploadMedia(std::move(input_peer), std::move(input_media))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -877,8 +874,8 @@ class CreateNewStickerSetQuery : public Td::ResultHandler {
flags |= telegram_api::stickers_createStickerSet::MASKS_MASK;
}
send_query(G()->net_query_creator().create(create_storer(telegram_api::stickers_createStickerSet(
flags, false /*ignored*/, std::move(input_user), title, short_name, std::move(input_stickers)))));
send_query(G()->net_query_creator().create(telegram_api::stickers_createStickerSet(
flags, false /*ignored*/, std::move(input_user), title, short_name, std::move(input_stickers))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -907,8 +904,8 @@ class AddStickerToSetQuery : public Td::ResultHandler {
}
void send(const string &short_name, tl_object_ptr<telegram_api::inputStickerSetItem> &&input_sticker) {
send_query(G()->net_query_creator().create(create_storer(telegram_api::stickers_addStickerToSet(
make_tl_object<telegram_api::inputStickerSetShortName>(short_name), std::move(input_sticker)))));
send_query(G()->net_query_creator().create(telegram_api::stickers_addStickerToSet(
make_tl_object<telegram_api::inputStickerSetShortName>(short_name), std::move(input_sticker))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -938,7 +935,7 @@ class SetStickerPositionQuery : public Td::ResultHandler {
void send(tl_object_ptr<telegram_api::inputDocument> &&input_document, int32 position) {
send_query(G()->net_query_creator().create(
create_storer(telegram_api::stickers_changeStickerPosition(std::move(input_document), position))));
telegram_api::stickers_changeStickerPosition(std::move(input_document), position)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -967,8 +964,7 @@ class DeleteStickerFromSetQuery : public Td::ResultHandler {
}
void send(tl_object_ptr<telegram_api::inputDocument> &&input_document) {
send_query(G()->net_query_creator().create(
create_storer(telegram_api::stickers_removeStickerFromSet(std::move(input_document)))));
send_query(G()->net_query_creator().create(telegram_api::stickers_removeStickerFromSet(std::move(input_document))));
}
void on_result(uint64 id, BufferSlice packet) override {

View File

@ -184,7 +184,7 @@ class GetRecentMeUrlsQuery : public Td::ResultHandler {
}
void send(const string &referrer) {
send_query(G()->net_query_creator().create(create_storer(telegram_api::help_getRecentMeUrls(referrer))));
send_query(G()->net_query_creator().create(telegram_api::help_getRecentMeUrls(referrer)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -279,8 +279,8 @@ class SendCustomRequestQuery : public Td::ResultHandler {
}
void send(const string &method, const string &parameters) {
send_query(G()->net_query_creator().create(create_storer(
telegram_api::bots_sendCustomRequest(method, make_tl_object<telegram_api::dataJSON>(parameters)))));
send_query(G()->net_query_creator().create(
telegram_api::bots_sendCustomRequest(method, make_tl_object<telegram_api::dataJSON>(parameters))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -306,8 +306,8 @@ class AnswerCustomQueryQuery : public Td::ResultHandler {
}
void send(int64 custom_query_id, const string &data) {
send_query(G()->net_query_creator().create(create_storer(
telegram_api::bots_answerWebhookJSONQuery(custom_query_id, make_tl_object<telegram_api::dataJSON>(data)))));
send_query(G()->net_query_creator().create(
telegram_api::bots_answerWebhookJSONQuery(custom_query_id, make_tl_object<telegram_api::dataJSON>(data))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -331,8 +331,8 @@ class AnswerCustomQueryQuery : public Td::ResultHandler {
class SetBotUpdatesStatusQuery : public Td::ResultHandler {
public:
void send(int32 pending_update_count, const string &error_message) {
send_query(G()->net_query_creator().create(
create_storer(telegram_api::help_setBotUpdatesStatus(pending_update_count, error_message))));
send_query(
G()->net_query_creator().create(telegram_api::help_setBotUpdatesStatus(pending_update_count, error_message)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -359,7 +359,7 @@ class UpdateStatusQuery : public Td::ResultHandler {
public:
NetQueryRef send(bool is_offline) {
is_offline_ = is_offline;
auto net_query = G()->net_query_creator().create(create_storer(telegram_api::account_updateStatus(is_offline)));
auto net_query = G()->net_query_creator().create(telegram_api::account_updateStatus(is_offline));
auto result = net_query.get_weak();
send_query(std::move(net_query));
return result;
@ -392,7 +392,7 @@ class GetInviteTextQuery : public Td::ResultHandler {
}
void send() {
send_query(G()->net_query_creator().create(create_storer(telegram_api::help_getInviteText())));
send_query(G()->net_query_creator().create(telegram_api::help_getInviteText()));
}
void on_result(uint64 id, BufferSlice packet) override {

View File

@ -27,7 +27,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())));
send_query(G()->net_query_creator().create(telegram_api::help_getTermsOfServiceUpdate()));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -66,8 +66,8 @@ class AcceptTermsOfServiceQuery : public Td::ResultHandler {
}
void send(string terms_of_service_id) {
send_query(G()->net_query_creator().create(create_storer(telegram_api::help_acceptTermsOfService(
telegram_api::make_object<telegram_api::dataJSON>(std::move(terms_of_service_id))))));
send_query(G()->net_query_creator().create(telegram_api::help_acceptTermsOfService(
telegram_api::make_object<telegram_api::dataJSON>(std::move(terms_of_service_id)))));
}
void on_result(uint64 id, BufferSlice packet) override {

View File

@ -140,7 +140,7 @@ void TopDialogManager::send_toggle_top_peers(bool is_enabled) {
LOG(DEBUG) << "Send toggle top peers query to " << is_enabled;
have_toggle_top_peers_query_ = true;
toggle_top_peers_query_is_enabled_ = is_enabled;
auto net_query = G()->net_query_creator().create(create_storer(telegram_api::contacts_toggleTopPeers(is_enabled)));
auto net_query = G()->net_query_creator().create(telegram_api::contacts_toggleTopPeers(is_enabled));
G()->net_query_dispatcher().dispatch_with_callback(std::move(net_query), actor_shared(this, 2));
}
@ -201,7 +201,7 @@ void TopDialogManager::remove_dialog(TopDialogCategory category, DialogId dialog
if (input_peer != nullptr) {
auto query =
telegram_api::contacts_resetTopPeerRating(top_dialog_category_as_telegram_api(category), std::move(input_peer));
auto net_query = G()->net_query_creator().create(create_storer(query));
auto net_query = G()->net_query_creator().create(query);
G()->net_query_dispatcher().dispatch_with_callback(std::move(net_query), actor_shared(this, 1));
}
@ -398,7 +398,7 @@ void TopDialogManager::do_get_top_peers() {
0 /*offset*/,
100 /*limit*/,
hash};
auto net_query = G()->net_query_creator().create(create_storer(query));
auto net_query = G()->net_query_creator().create(query);
G()->net_query_dispatcher().dispatch_with_callback(std::move(net_query), actor_shared(this));
}

View File

@ -79,7 +79,7 @@ class GetUpdatesStateQuery : public Td::ResultHandler {
void send() {
// TODO this call must be first after client is logged in, there must be no API calls before
// it succeeds
send_query(G()->net_query_creator().create(create_storer(telegram_api::updates_getState())));
send_query(G()->net_query_creator().create(telegram_api::updates_getState()));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -106,7 +106,7 @@ class GetUpdatesStateQuery : public Td::ResultHandler {
class PingServerQuery : public Td::ResultHandler {
public:
void send() {
send_query(G()->net_query_creator().create(create_storer(telegram_api::updates_getState())));
send_query(G()->net_query_creator().create(telegram_api::updates_getState()));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -138,8 +138,7 @@ class GetDifferenceQuery : public Td::ResultHandler {
VLOG(get_difference) << tag("pts", pts) << tag("qts", qts) << tag("date", date);
send_query(
G()->net_query_creator().create(create_storer(telegram_api::updates_getDifference(0, pts, 0, date, qts))));
send_query(G()->net_query_creator().create(telegram_api::updates_getDifference(0, pts, 0, date, qts)));
}
void on_result(uint64 id, BufferSlice packet) override {

View File

@ -70,8 +70,8 @@ class GetWebPagePreviewQuery : public Td::ResultHandler {
flags |= telegram_api::messages_getWebPagePreview::ENTITIES_MASK;
}
send_query(G()->net_query_creator().create(
create_storer(telegram_api::messages_getWebPagePreview(flags, text, std::move(entities)))));
send_query(
G()->net_query_creator().create(telegram_api::messages_getWebPagePreview(flags, text, std::move(entities))));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -100,7 +100,7 @@ class GetWebPageQuery : public Td::ResultHandler {
void send(const string &url, int32 hash) {
url_ = url;
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_getWebPage(url, hash))));
send_query(G()->net_query_creator().create(telegram_api::messages_getWebPage(url, hash)));
}
void on_result(uint64 id, BufferSlice packet) override {

View File

@ -74,7 +74,7 @@ Status FileHashUploader::loop_impl() {
auto query =
telegram_api::messages_getDocumentByHash(std::move(hash), static_cast<int32>(size_), std::move(mime_type));
LOG(INFO) << "Send getDocumentByHash request: " << to_string(query);
auto ptr = G()->net_query_creator().create(create_storer(query));
auto ptr = G()->net_query_creator().create(query);
G()->net_query_dispatcher().dispatch_with_callback(std::move(ptr), actor_shared(this));
state_ = State::WaitNetResult;
}

View File

@ -120,7 +120,6 @@ Status PartsManager::init(int64 size, int64 expected_size, bool is_size_final, s
return Status::Error("FILE_UPLOAD_RESTART");
}
} else {
// TODO choose part_size_ depending on size
part_size_ = 64 * (1 << 10);
while (use_part_count_limit && calc_part_count(expected_size_, part_size_) > MAX_PART_COUNT) {
part_size_ *= 2;

View File

@ -1238,7 +1238,7 @@ void ConnectionCreator::loop() {
if (get_proxy_info_timestamp_.is_in_past()) {
if (get_proxy_info_query_token_ == 0) {
get_proxy_info_query_token_ = next_token();
auto query = G()->net_query_creator().create(create_storer(telegram_api::help_getProxyData()));
auto query = G()->net_query_creator().create(telegram_api::help_getProxyData());
G()->net_query_dispatcher().dispatch_with_callback(std::move(query),
actor_shared(this, get_proxy_info_query_token_));
}

View File

@ -13,6 +13,10 @@
namespace td {
NetQueryPtr NetQueryCreator::create_regular(const Storer &storer) {
return create(UniqueId::next(), storer, DcId::main(), NetQuery::Type::Common, NetQuery::AuthFlag::On);
}
NetQueryPtr NetQueryCreator::create(uint64 id, const Storer &storer, DcId dc_id, NetQuery::Type type,
NetQuery::AuthFlag auth_flag) {
BufferSlice slice(storer.size());

View File

@ -33,14 +33,17 @@ class NetQueryCreator {
NetQuery::Type::Common, NetQuery::AuthFlag::On, NetQuery::GzipFlag::Off, 0);
}
NetQueryPtr create(const Storer &storer) {
return create(UniqueId::next(), storer, DcId::main(), NetQuery::Type::Common, NetQuery::AuthFlag::On);
template <class T>
NetQueryPtr create(const T &function) {
return create_regular(create_storer(function));
}
NetQueryPtr create(const Storer &storer, DcId dc_id, NetQuery::Type type) {
return create(UniqueId::next(), storer, dc_id, type, NetQuery::AuthFlag::On);
}
NetQueryPtr create_regular(const Storer &storer);
NetQueryPtr create_guest_dc(const Storer &storer, DcId dc_id) {
return create(UniqueId::next(), storer, dc_id, NetQuery::Type::Common, NetQuery::AuthFlag::On);
}

View File

@ -68,7 +68,7 @@ void PublicRsaKeyWatchdog::loop() {
}
flood_control_.add_event(static_cast<int32>(Time::now_cached()));
has_query_ = true;
auto query = G()->net_query_creator().create(create_storer(telegram_api::help_getCdnConfig()));
auto query = G()->net_query_creator().create(telegram_api::help_getCdnConfig());
query->total_timeout_limit = 60 * 60 * 24;
G()->net_query_dispatcher().dispatch_with_callback(std::move(query), actor_shared(this));
}