diff --git a/td/telegram/AnimationsManager.cpp b/td/telegram/AnimationsManager.cpp index 7e3da46c8..d92bb6c8c 100644 --- a/td/telegram/AnimationsManager.cpp +++ b/td/telegram/AnimationsManager.cpp @@ -56,14 +56,14 @@ class GetSavedGifsQuery final : public Td::ResultHandler { } auto ptr = result_ptr.move_as_ok(); - td->animations_manager_->on_get_saved_animations(is_repair_, std::move(ptr)); + td_->animations_manager_->on_get_saved_animations(is_repair_, std::move(ptr)); } void on_error(Status status) final { if (!G()->is_expected_error(status)) { LOG(ERROR) << "Receive error for get saved animations: " << status; } - td->animations_manager_->on_get_saved_animations_failed(is_repair_, std::move(status)); + td_->animations_manager_->on_get_saved_animations_failed(is_repair_, std::move(status)); } }; @@ -96,17 +96,17 @@ class SaveGifQuery final : public Td::ResultHandler { bool result = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for save GIF: " << result; if (!result) { - td->animations_manager_->reload_saved_animations(true); + td_->animations_manager_->reload_saved_animations(true); } promise_.set_value(Unit()); } void on_error(Status status) final { - if (!td->auth_manager_->is_bot() && FileReferenceManager::is_file_reference_error(status)) { + if (!td_->auth_manager_->is_bot() && FileReferenceManager::is_file_reference_error(status)) { VLOG(file_references) << "Receive " << status << " for " << file_id_; - td->file_manager_->delete_file_reference(file_id_, file_reference_); - td->file_reference_manager_->repair_file_reference( + td_->file_manager_->delete_file_reference(file_id_, file_reference_); + td_->file_reference_manager_->repair_file_reference( file_id_, PromiseCreator::lambda([animation_id = file_id_, unsave = unsave_, promise = std::move(promise_)](Result result) mutable { if (result.is_error()) { @@ -122,7 +122,7 @@ class SaveGifQuery final : public Td::ResultHandler { if (!G()->is_expected_error(status)) { LOG(ERROR) << "Receive error for save GIF: " << status; } - td->animations_manager_->reload_saved_animations(true); + td_->animations_manager_->reload_saved_animations(true); promise_.set_error(std::move(status)); } }; diff --git a/td/telegram/AuthManager.cpp b/td/telegram/AuthManager.cpp index 0a07619db..14a15f8df 100644 --- a/td/telegram/AuthManager.cpp +++ b/td/telegram/AuthManager.cpp @@ -56,7 +56,7 @@ AuthManager::AuthManager(int32 api_id, const string &api_hash, ActorShared<> par } else { LOG(ERROR) << "Restore unknown my_id"; ContactsManager::send_get_me_query( - td, PromiseCreator::lambda([this](Result result) { update_state(State::Ok); })); + td_, PromiseCreator::lambda([this](Result result) { update_state(State::Ok); })); } } else if (auth_str == "logout") { LOG(WARNING) << "Continue to log out"; @@ -208,7 +208,7 @@ void AuthManager::set_login_token_expires_at(double login_token_expires_at) { login_token_expires_at_ = login_token_expires_at; poll_export_login_code_timeout_.cancel_timeout(); poll_export_login_code_timeout_.set_callback(std::move(on_update_login_token_static)); - poll_export_login_code_timeout_.set_callback_data(static_cast(td)); + poll_export_login_code_timeout_.set_callback_data(static_cast(td_)); poll_export_login_code_timeout_.set_timeout_at(login_token_expires_at_); } @@ -763,9 +763,9 @@ void AuthManager::on_get_authorization(tl_object_ptrcontacts_manager_->on_get_user(std::move(auth->user_), "on_get_authorization", true); + td_->contacts_manager_->on_get_user(std::move(auth->user_), "on_get_authorization", true); update_state(State::Ok, true); - if (!td->contacts_manager_->get_my_id().is_valid()) { + if (!td_->contacts_manager_->get_my_id().is_valid()) { LOG(ERROR) << "Server doesn't send proper authorization"; if (query_id_ != 0) { on_query_error(Status::Error(500, "Server doesn't send proper authorization")); @@ -776,19 +776,19 @@ void AuthManager::on_get_authorization(tl_object_ptrflags_ & telegram_api::auth_authorization::TMP_SESSIONS_MASK) != 0) { G()->shared_config().set_option_integer("session_count", auth->tmp_sessions_); } - td->messages_manager_->on_authorization_success(); - td->notification_manager_->init(); - td->stickers_manager_->init(); - td->theme_manager_->init(); - td->top_dialog_manager_->init(); - td->updates_manager_->get_difference("on_get_authorization"); - td->on_online_updated(false, true); + td_->messages_manager_->on_authorization_success(); + td_->notification_manager_->init(); + td_->stickers_manager_->init(); + td_->theme_manager_->init(); + td_->top_dialog_manager_->init(); + td_->updates_manager_->get_difference("on_get_authorization"); + td_->on_online_updated(false, true); if (!is_bot()) { - td->schedule_get_terms_of_service(0); - td->schedule_get_promo_data(0); + td_->schedule_get_terms_of_service(0); + td_->schedule_get_promo_data(0); G()->td_db()->get_binlog_pmc()->set("fetched_marks_as_unread", "1"); } else { - td->set_is_bot_online(true); + td_->set_is_bot_online(true); } send_closure(G()->config_manager(), &ConfigManager::request_config); if (query_id_ != 0) { diff --git a/td/telegram/BackgroundManager.cpp b/td/telegram/BackgroundManager.cpp index 9ca3dc5a2..6fdfd782c 100644 --- a/td/telegram/BackgroundManager.cpp +++ b/td/telegram/BackgroundManager.cpp @@ -60,7 +60,7 @@ class GetBackgroundQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - td->background_manager_->on_get_background(background_id_, background_name_, result_ptr.move_as_ok(), true); + td_->background_manager_->on_get_background(background_id_, background_name_, result_ptr.move_as_ok(), true); promise_.set_value(Unit()); } @@ -151,22 +151,22 @@ class UploadBackgroundQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - td->background_manager_->on_uploaded_background_file(file_id_, type_, for_dark_theme_, result_ptr.move_as_ok(), - std::move(promise_)); + td_->background_manager_->on_uploaded_background_file(file_id_, type_, for_dark_theme_, result_ptr.move_as_ok(), + std::move(promise_)); } void on_error(Status status) final { CHECK(status.is_error()); CHECK(file_id_.is_valid()); if (begins_with(status.message(), "FILE_PART_") && ends_with(status.message(), "_MISSING")) { - // TODO td->background_manager_->on_upload_background_file_part_missing(file_id_, to_integer(status.message().substr(10))); + // TODO td_->background_manager_->on_upload_background_file_part_missing(file_id_, to_integer(status.message().substr(10))); // return; } else { if (status.code() != 429 && status.code() < 500 && !G()->close_flag()) { - td->file_manager_->delete_partial_remote_location(file_id_); + td_->file_manager_->delete_partial_remote_location(file_id_); } } - td->file_manager_->cancel_upload(file_id_); + td_->file_manager_->cancel_upload(file_id_); promise_.set_error(std::move(status)); } }; diff --git a/td/telegram/BotCommand.cpp b/td/telegram/BotCommand.cpp index af391bcce..652059207 100644 --- a/td/telegram/BotCommand.cpp +++ b/td/telegram/BotCommand.cpp @@ -31,7 +31,7 @@ class SetBotCommandsQuery final : public Td::ResultHandler { void send(BotCommandScope scope, const string &language_code, vector &&commands) { send_query(G()->net_query_creator().create(telegram_api::bots_setBotCommands( - scope.get_input_bot_command_scope(td), language_code, + scope.get_input_bot_command_scope(td_), language_code, transform(commands, [](const BotCommand &command) { return command.get_input_bot_command(); })))); } @@ -61,7 +61,7 @@ class ResetBotCommandsQuery final : public Td::ResultHandler { void send(BotCommandScope scope, const string &language_code) { send_query(G()->net_query_creator().create( - telegram_api::bots_resetBotCommands(scope.get_input_bot_command_scope(td), language_code))); + telegram_api::bots_resetBotCommands(scope.get_input_bot_command_scope(td_), language_code))); } void on_result(BufferSlice packet) final { @@ -88,7 +88,7 @@ class GetBotCommandsQuery final : public Td::ResultHandler { void send(BotCommandScope scope, const string &language_code) { send_query(G()->net_query_creator().create( - telegram_api::bots_getBotCommands(scope.get_input_bot_command_scope(td), language_code))); + telegram_api::bots_getBotCommands(scope.get_input_bot_command_scope(td_), language_code))); } void on_result(BufferSlice packet) final { @@ -97,8 +97,8 @@ class GetBotCommandsQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - BotCommands commands(td->contacts_manager_->get_my_id(), result_ptr.move_as_ok()); - promise_.set_value(commands.get_bot_commands_object(td)); + BotCommands commands(td_->contacts_manager_->get_my_id(), result_ptr.move_as_ok()); + promise_.set_value(commands.get_bot_commands_object(td_)); } void on_error(Status status) final { diff --git a/td/telegram/CallbackQueriesManager.cpp b/td/telegram/CallbackQueriesManager.cpp index a6f707826..b69ed809b 100644 --- a/td/telegram/CallbackQueriesManager.cpp +++ b/td/telegram/CallbackQueriesManager.cpp @@ -41,7 +41,7 @@ class GetBotCallbackAnswerQuery final : public Td::ResultHandler { dialog_id_ = dialog_id; message_id_ = message_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); CHECK(input_peer != nullptr); int32 flags = 0; @@ -85,15 +85,15 @@ class GetBotCallbackAnswerQuery final : public Td::ResultHandler { void on_error(Status status) final { if (status.message() == "DATA_INVALID" || status.message() == "MESSAGE_ID_INVALID") { - td->messages_manager_->get_message_from_server({dialog_id_, message_id_}, Auto(), "GetBotCallbackAnswerQuery"); + td_->messages_manager_->get_message_from_server({dialog_id_, message_id_}, Auto(), "GetBotCallbackAnswerQuery"); } else if (status.message() == "BOT_RESPONSE_TIMEOUT") { status = Status::Error(502, "The bot is not responding"); } - if (status.code() == 502 && td->messages_manager_->is_message_edited_recently({dialog_id_, message_id_}, 31)) { + if (status.code() == 502 && td_->messages_manager_->is_message_edited_recently({dialog_id_, message_id_}, 31)) { return promise_.set_value(td_api::make_object()); } - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetBotCallbackAnswerQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetBotCallbackAnswerQuery"); promise_.set_error(std::move(status)); } }; diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index f2efd7230..36310b960 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -83,7 +83,7 @@ class DismissSuggestionQuery final : public Td::ResultHandler { void send(SuggestedAction action) { dialog_id_ = action.dialog_id_; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read); CHECK(input_peer != nullptr); send_query(G()->net_query_creator().create( @@ -100,7 +100,7 @@ class DismissSuggestionQuery final : public Td::ResultHandler { } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "DismissSuggestionQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "DismissSuggestionQuery"); promise_.set_error(std::move(status)); } }; @@ -278,7 +278,7 @@ class ResetAuthorizationsQuery final : public Td::ResultHandler { bool result = result_ptr.move_as_ok(); LOG_IF(WARNING, !result) << "Failed to terminate all sessions"; - send_closure(td->device_token_manager_, &DeviceTokenManager::reregister_device); + send_closure(td_->device_token_manager_, &DeviceTokenManager::reregister_device); promise_.set_value(Unit()); } @@ -308,7 +308,7 @@ class GetWebAuthorizationsQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for GetWebAuthorizationsQuery: " << to_string(ptr); - td->contacts_manager_->on_get_users(std::move(ptr->users_), "GetWebAuthorizationsQuery"); + td_->contacts_manager_->on_get_users(std::move(ptr->users_), "GetWebAuthorizationsQuery"); auto results = make_tl_object(); results->websites_.reserve(ptr->authorizations_.size()); @@ -322,7 +322,7 @@ class GetWebAuthorizationsQuery final : public Td::ResultHandler { results->websites_.push_back(make_tl_object( authorization->hash_, authorization->domain_, - td->contacts_manager_->get_user_id_object(bot_user_id, "GetWebAuthorizationsQuery"), authorization->browser_, + td_->contacts_manager_->get_user_id_object(bot_user_id, "GetWebAuthorizationsQuery"), authorization->browser_, authorization->platform_, authorization->date_created_, authorization->date_active_, authorization->ip_, authorization->region_)); } @@ -404,12 +404,12 @@ class GetContactsQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for GetContactsQuery: " << to_string(ptr); - td->contacts_manager_->on_get_contacts(std::move(ptr)); + td_->contacts_manager_->on_get_contacts(std::move(ptr)); } void on_error(Status status) final { - td->contacts_manager_->on_get_contacts_failed(std::move(status)); - td->updates_manager_->get_difference("GetContactsQuery"); + td_->contacts_manager_->on_get_contacts_failed(std::move(status)); + td_->updates_manager_->get_difference("GetContactsQuery"); } }; @@ -426,7 +426,7 @@ class GetContactsStatusesQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - td->contacts_manager_->on_get_contacts_statuses(result_ptr.move_as_ok()); + td_->contacts_manager_->on_get_contacts_statuses(result_ptr.move_as_ok()); } void on_error(Status status) final { @@ -464,13 +464,13 @@ class AddContactQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for AddContactQuery: " << to_string(ptr); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { promise_.set_error(std::move(status)); - td->contacts_manager_->reload_contacts(true); - td->messages_manager_->reget_dialog_action_bar(DialogId(user_id_), "AddContactQuery"); + td_->contacts_manager_->reload_contacts(true); + td_->messages_manager_->reget_dialog_action_bar(DialogId(user_id_), "AddContactQuery"); } }; @@ -495,13 +495,13 @@ class AcceptContactQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for AcceptContactQuery: " << to_string(ptr); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { promise_.set_error(std::move(status)); - td->contacts_manager_->reload_contacts(true); - td->messages_manager_->reget_dialog_action_bar(DialogId(user_id_), "AcceptContactQuery"); + td_->contacts_manager_->reload_contacts(true); + td_->messages_manager_->reget_dialog_action_bar(DialogId(user_id_), "AcceptContactQuery"); } }; @@ -522,8 +522,8 @@ class ImportContactsQuery final : public Td::ResultHandler { size_t size = input_contacts.size(); if (size == 0) { - td->contacts_manager_->on_imported_contacts(random_id, std::move(imported_user_ids_), - std::move(unimported_contact_invites_)); + td_->contacts_manager_->on_imported_contacts(random_id, std::move(imported_user_ids_), + std::move(unimported_contact_invites_)); promise_.set_value(Unit()); return; } @@ -551,7 +551,7 @@ class ImportContactsQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for ImportContactsQuery: " << to_string(ptr); - td->contacts_manager_->on_get_users(std::move(ptr->users_), "ImportContactsQuery"); + td_->contacts_manager_->on_get_users(std::move(ptr->users_), "ImportContactsQuery"); for (auto &imported_contact : ptr->imported_) { int64 client_id = imported_contact->client_id_; if (client_id < 0 || client_id >= static_cast(imported_user_ids_.size())) { @@ -597,14 +597,14 @@ class ImportContactsQuery final : public Td::ResultHandler { return; } - td->contacts_manager_->on_imported_contacts(random_id_, std::move(imported_user_ids_), - std::move(unimported_contact_invites_)); + td_->contacts_manager_->on_imported_contacts(random_id_, std::move(imported_user_ids_), + std::move(unimported_contact_invites_)); promise_.set_value(Unit()); } void on_error(Status status) final { promise_.set_error(std::move(status)); - td->contacts_manager_->reload_contacts(true); + td_->contacts_manager_->reload_contacts(true); } }; @@ -627,12 +627,12 @@ class DeleteContactsQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for DeleteContactsQuery: " << to_string(ptr); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { promise_.set_error(std::move(status)); - td->contacts_manager_->reload_contacts(true); + td_->contacts_manager_->reload_contacts(true); } }; @@ -663,13 +663,13 @@ class DeleteContactsByPhoneNumberQuery final : public Td::ResultHandler { return on_error(Status::Error(500, "Some contacts can't be deleted")); } - td->contacts_manager_->on_deleted_contacts(user_ids_); + td_->contacts_manager_->on_deleted_contacts(user_ids_); promise_.set_value(Unit()); } void on_error(Status status) final { promise_.set_error(std::move(status)); - td->contacts_manager_->reload_contacts(true); + td_->contacts_manager_->reload_contacts(true); } }; @@ -693,9 +693,9 @@ class ResetContactsQuery final : public Td::ResultHandler { bool result = result_ptr.ok(); if (!result) { LOG(ERROR) << "Failed to delete imported contacts"; - td->contacts_manager_->reload_contacts(true); + td_->contacts_manager_->reload_contacts(true); } else { - td->contacts_manager_->on_update_contacts_reset(); + td_->contacts_manager_->on_update_contacts_reset(); } promise_.set_value(Unit()); @@ -703,7 +703,7 @@ class ResetContactsQuery final : public Td::ResultHandler { void on_error(Status status) final { promise_.set_error(std::move(status)); - td->contacts_manager_->reload_contacts(true); + td_->contacts_manager_->reload_contacts(true); } }; @@ -780,17 +780,17 @@ class UploadProfilePhotoQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - td->contacts_manager_->on_set_profile_photo(result_ptr.move_as_ok(), 0); + td_->contacts_manager_->on_set_profile_photo(result_ptr.move_as_ok(), 0); - td->file_manager_->delete_partial_remote_location(file_id_); + td_->file_manager_->delete_partial_remote_location(file_id_); promise_.set_value(Unit()); } void on_error(Status status) final { promise_.set_error(std::move(status)); - td->file_manager_->delete_partial_remote_location(file_id_); - td->updates_manager_->get_difference("UploadProfilePhotoQuery"); + td_->file_manager_->delete_partial_remote_location(file_id_); + td_->updates_manager_->get_difference("UploadProfilePhotoQuery"); } }; @@ -818,17 +818,17 @@ class UpdateProfilePhotoQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - td->contacts_manager_->on_set_profile_photo(result_ptr.move_as_ok(), old_photo_id_); + td_->contacts_manager_->on_set_profile_photo(result_ptr.move_as_ok(), old_photo_id_); promise_.set_value(Unit()); } void on_error(Status status) final { - if (!td->auth_manager_->is_bot() && FileReferenceManager::is_file_reference_error(status)) { + if (!td_->auth_manager_->is_bot() && FileReferenceManager::is_file_reference_error(status)) { if (file_id_.is_valid()) { VLOG(file_references) << "Receive " << status << " for " << file_id_; - td->file_manager_->delete_file_reference(file_id_, file_reference_); - td->file_reference_manager_->repair_file_reference( + td_->file_manager_->delete_file_reference(file_id_, file_reference_); + td_->file_reference_manager_->repair_file_reference( file_id_, PromiseCreator::lambda([file_id = file_id_, old_photo_id = old_photo_id_, promise = std::move(promise_)](Result result) mutable { if (result.is_error()) { @@ -876,7 +876,7 @@ class DeleteProfilePhotoQuery final : public Td::ResultHandler { return on_error(Status::Error(400, "Photo can't be deleted")); } - td->contacts_manager_->on_delete_profile_photo(profile_photo_id_, std::move(promise_)); + td_->contacts_manager_->on_delete_profile_photo(profile_photo_id_, std::move(promise_)); } void on_error(Status status) final { @@ -911,8 +911,8 @@ class UpdateProfileQuery final : public Td::ResultHandler { } LOG(DEBUG) << "Receive result for UpdateProfileQuery: " << to_string(result_ptr.ok()); - td->contacts_manager_->on_get_user(result_ptr.move_as_ok(), "UpdateProfileQuery"); - td->contacts_manager_->on_update_profile_success(flags_, first_name_, last_name_, about_); + td_->contacts_manager_->on_get_user(result_ptr.move_as_ok(), "UpdateProfileQuery"); + td_->contacts_manager_->on_update_profile_success(flags_, first_name_, last_name_, about_); promise_.set_value(Unit()); } @@ -965,12 +965,12 @@ class UpdateUsernameQuery final : public Td::ResultHandler { } LOG(DEBUG) << "Receive result for UpdateUsernameQuery: " << to_string(result_ptr.ok()); - td->contacts_manager_->on_get_user(result_ptr.move_as_ok(), "UpdateUsernameQuery"); + td_->contacts_manager_->on_get_user(result_ptr.move_as_ok(), "UpdateUsernameQuery"); promise_.set_value(Unit()); } void on_error(Status status) final { - if (status.message() == "USERNAME_NOT_MODIFIED" && !td->auth_manager_->is_bot()) { + if (status.message() == "USERNAME_NOT_MODIFIED" && !td_->auth_manager_->is_bot()) { promise_.set_value(Unit()); return; } @@ -991,7 +991,7 @@ class CheckChannelUsernameQuery final : public Td::ResultHandler { channel_id_ = channel_id; tl_object_ptr input_channel; if (channel_id.is_valid()) { - input_channel = td->contacts_manager_->get_input_channel(channel_id); + input_channel = td_->contacts_manager_->get_input_channel(channel_id); } else { input_channel = make_tl_object(); } @@ -1011,7 +1011,7 @@ class CheckChannelUsernameQuery final : public Td::ResultHandler { void on_error(Status status) final { if (channel_id_.is_valid()) { - td->contacts_manager_->on_get_channel_error(channel_id_, status, "CheckChannelUsernameQuery"); + td_->contacts_manager_->on_get_channel_error(channel_id_, status, "CheckChannelUsernameQuery"); } promise_.set_error(std::move(status)); } @@ -1029,7 +1029,7 @@ class UpdateChannelUsernameQuery final : public Td::ResultHandler { void send(ChannelId channel_id, const string &username) { channel_id_ = channel_id; username_ = username; - auto input_channel = td->contacts_manager_->get_input_channel(channel_id); + auto input_channel = td_->contacts_manager_->get_input_channel(channel_id); CHECK(input_channel != nullptr); send_query( G()->net_query_creator().create(telegram_api::channels_updateUsername(std::move(input_channel), username))); @@ -1047,19 +1047,19 @@ class UpdateChannelUsernameQuery final : public Td::ResultHandler { return on_error(Status::Error(500, "Supergroup username is not updated")); } - td->contacts_manager_->on_update_channel_username(channel_id_, std::move(username_)); + td_->contacts_manager_->on_update_channel_username(channel_id_, std::move(username_)); promise_.set_value(Unit()); } void on_error(Status status) final { if (status.message() == "USERNAME_NOT_MODIFIED" || status.message() == "CHAT_NOT_MODIFIED") { - td->contacts_manager_->on_update_channel_username(channel_id_, std::move(username_)); - if (!td->auth_manager_->is_bot()) { + td_->contacts_manager_->on_update_channel_username(channel_id_, std::move(username_)); + if (!td_->auth_manager_->is_bot()) { promise_.set_value(Unit()); return; } } else { - td->contacts_manager_->on_get_channel_error(channel_id_, status, "UpdateChannelUsernameQuery"); + td_->contacts_manager_->on_get_channel_error(channel_id_, status, "UpdateChannelUsernameQuery"); } promise_.set_error(std::move(status)); } @@ -1078,7 +1078,7 @@ class SetChannelStickerSetQuery final : public Td::ResultHandler { telegram_api::object_ptr &&input_sticker_set) { channel_id_ = channel_id; sticker_set_id_ = sticker_set_id; - auto input_channel = td->contacts_manager_->get_input_channel(channel_id); + auto input_channel = td_->contacts_manager_->get_input_channel(channel_id); CHECK(input_channel != nullptr); send_query(G()->net_query_creator().create( telegram_api::channels_setStickers(std::move(input_channel), std::move(input_sticker_set)))); @@ -1096,19 +1096,19 @@ class SetChannelStickerSetQuery final : public Td::ResultHandler { return on_error(Status::Error(500, "Supergroup sticker set not updated")); } - td->contacts_manager_->on_update_channel_sticker_set(channel_id_, sticker_set_id_); + td_->contacts_manager_->on_update_channel_sticker_set(channel_id_, sticker_set_id_); promise_.set_value(Unit()); } void on_error(Status status) final { if (status.message() == "CHAT_NOT_MODIFIED") { - td->contacts_manager_->on_update_channel_sticker_set(channel_id_, sticker_set_id_); - if (!td->auth_manager_->is_bot()) { + td_->contacts_manager_->on_update_channel_sticker_set(channel_id_, sticker_set_id_); + if (!td_->auth_manager_->is_bot()) { promise_.set_value(Unit()); return; } } else { - td->contacts_manager_->on_get_channel_error(channel_id_, status, "SetChannelStickerSetQuery"); + td_->contacts_manager_->on_get_channel_error(channel_id_, status, "SetChannelStickerSetQuery"); } promise_.set_error(std::move(status)); } @@ -1124,7 +1124,7 @@ class ToggleChannelSignaturesQuery final : public Td::ResultHandler { void send(ChannelId channel_id, bool sign_messages) { channel_id_ = channel_id; - auto input_channel = td->contacts_manager_->get_input_channel(channel_id); + auto input_channel = td_->contacts_manager_->get_input_channel(channel_id); CHECK(input_channel != nullptr); send_query(G()->net_query_creator().create( telegram_api::channels_toggleSignatures(std::move(input_channel), sign_messages))); @@ -1138,17 +1138,17 @@ class ToggleChannelSignaturesQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for ToggleChannelSignaturesQuery: " << to_string(ptr); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { if (status.message() == "CHAT_NOT_MODIFIED") { - if (!td->auth_manager_->is_bot()) { + if (!td_->auth_manager_->is_bot()) { promise_.set_value(Unit()); return; } } else { - td->contacts_manager_->on_get_channel_error(channel_id_, status, "ToggleChannelSignaturesQuery"); + td_->contacts_manager_->on_get_channel_error(channel_id_, status, "ToggleChannelSignaturesQuery"); } promise_.set_error(std::move(status)); } @@ -1167,7 +1167,7 @@ class TogglePrehistoryHiddenQuery final : public Td::ResultHandler { channel_id_ = channel_id; is_all_history_available_ = is_all_history_available; - auto input_channel = td->contacts_manager_->get_input_channel(channel_id); + auto input_channel = td_->contacts_manager_->get_input_channel(channel_id); CHECK(input_channel != nullptr); send_query(G()->net_query_creator().create( telegram_api::channels_togglePreHistoryHidden(std::move(input_channel), !is_all_history_available))); @@ -1182,7 +1182,7 @@ class TogglePrehistoryHiddenQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for TogglePrehistoryHiddenQuery: " << to_string(ptr); - td->updates_manager_->on_get_updates( + td_->updates_manager_->on_get_updates( std::move(ptr), PromiseCreator::lambda([actor_id = G()->contacts_manager(), promise = std::move(promise_), channel_id = channel_id_, @@ -1194,12 +1194,12 @@ class TogglePrehistoryHiddenQuery final : public Td::ResultHandler { void on_error(Status status) final { if (status.message() == "CHAT_NOT_MODIFIED") { - if (!td->auth_manager_->is_bot()) { + if (!td_->auth_manager_->is_bot()) { promise_.set_value(Unit()); return; } } else { - td->contacts_manager_->on_get_channel_error(channel_id_, status, "TogglePrehistoryHiddenQuery"); + td_->contacts_manager_->on_get_channel_error(channel_id_, status, "TogglePrehistoryHiddenQuery"); } promise_.set_error(std::move(status)); } @@ -1216,7 +1216,7 @@ class ConvertToGigagroupQuery final : public Td::ResultHandler { void send(ChannelId channel_id) { channel_id_ = channel_id; - auto input_channel = td->contacts_manager_->get_input_channel(channel_id); + auto input_channel = td_->contacts_manager_->get_input_channel(channel_id); CHECK(input_channel != nullptr); send_query(G()->net_query_creator().create(telegram_api::channels_convertToGigagroup(std::move(input_channel)))); } @@ -1230,7 +1230,7 @@ class ConvertToGigagroupQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for ConvertToGigagroupQuery: " << to_string(ptr); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { @@ -1238,7 +1238,7 @@ class ConvertToGigagroupQuery final : public Td::ResultHandler { promise_.set_value(Unit()); return; } else { - td->contacts_manager_->on_get_channel_error(channel_id_, status, "ConvertToGigagroupQuery"); + td_->contacts_manager_->on_get_channel_error(channel_id_, status, "ConvertToGigagroupQuery"); } promise_.set_error(std::move(status)); } @@ -1252,9 +1252,9 @@ class EditChatAboutQuery final : public Td::ResultHandler { void on_success() { switch (dialog_id_.get_type()) { case DialogType::Chat: - return td->contacts_manager_->on_update_chat_description(dialog_id_.get_chat_id(), std::move(about_)); + return td_->contacts_manager_->on_update_chat_description(dialog_id_.get_chat_id(), std::move(about_)); case DialogType::Channel: - return td->contacts_manager_->on_update_channel_description(dialog_id_.get_channel_id(), std::move(about_)); + return td_->contacts_manager_->on_update_channel_description(dialog_id_.get_channel_id(), std::move(about_)); case DialogType::User: case DialogType::SecretChat: case DialogType::None: @@ -1269,7 +1269,7 @@ class EditChatAboutQuery final : public Td::ResultHandler { void send(DialogId dialog_id, const string &about) { dialog_id_ = dialog_id; about_ = about; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); if (input_peer == nullptr) { return on_error(Status::Error(400, "Can't access the chat")); } @@ -1295,12 +1295,12 @@ class EditChatAboutQuery final : public Td::ResultHandler { void on_error(Status status) final { if (status.message() == "CHAT_ABOUT_NOT_MODIFIED" || status.message() == "CHAT_NOT_MODIFIED") { on_success(); - if (!td->auth_manager_->is_bot()) { + if (!td_->auth_manager_->is_bot()) { promise_.set_value(Unit()); return; } } else { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "EditChatAboutQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "EditChatAboutQuery"); } promise_.set_error(std::move(status)); } @@ -1333,7 +1333,7 @@ class SetDiscussionGroupQuery final : public Td::ResultHandler { bool result = result_ptr.move_as_ok(); LOG_IF(INFO, !result) << "Set discussion group has failed"; - td->contacts_manager_->on_update_channel_linked_channel_id(broadcast_channel_id_, group_channel_id_); + td_->contacts_manager_->on_update_channel_linked_channel_id(broadcast_channel_id_, group_channel_id_); promise_.set_value(Unit()); } @@ -1358,7 +1358,7 @@ class EditLocationQuery final : public Td::ResultHandler { channel_id_ = channel_id; location_ = location; - auto input_channel = td->contacts_manager_->get_input_channel(channel_id); + auto input_channel = td_->contacts_manager_->get_input_channel(channel_id); CHECK(input_channel != nullptr); send_query(G()->net_query_creator().create(telegram_api::channels_editLocation( @@ -1374,12 +1374,12 @@ class EditLocationQuery final : public Td::ResultHandler { bool result = result_ptr.move_as_ok(); LOG_IF(INFO, !result) << "Edit chat location has failed"; - td->contacts_manager_->on_update_channel_location(channel_id_, location_); + td_->contacts_manager_->on_update_channel_location(channel_id_, location_); promise_.set_value(Unit()); } void on_error(Status status) final { - td->contacts_manager_->on_get_channel_error(channel_id_, status, "EditLocationQuery"); + td_->contacts_manager_->on_get_channel_error(channel_id_, status, "EditLocationQuery"); promise_.set_error(std::move(status)); } }; @@ -1397,7 +1397,7 @@ class ToggleSlowModeQuery final : public Td::ResultHandler { channel_id_ = channel_id; slow_mode_delay_ = slow_mode_delay; - auto input_channel = td->contacts_manager_->get_input_channel(channel_id); + auto input_channel = td_->contacts_manager_->get_input_channel(channel_id); CHECK(input_channel != nullptr); send_query(G()->net_query_creator().create( @@ -1413,7 +1413,7 @@ class ToggleSlowModeQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for ToggleSlowModeQuery: " << to_string(ptr); - td->updates_manager_->on_get_updates( + td_->updates_manager_->on_get_updates( std::move(ptr), PromiseCreator::lambda([actor_id = G()->contacts_manager(), promise = std::move(promise_), channel_id = channel_id_, slow_mode_delay = slow_mode_delay_](Unit result) mutable { @@ -1424,13 +1424,13 @@ class ToggleSlowModeQuery final : public Td::ResultHandler { void on_error(Status status) final { if (status.message() == "CHAT_NOT_MODIFIED") { - td->contacts_manager_->on_update_channel_slow_mode_delay(channel_id_, slow_mode_delay_, Promise()); - if (!td->auth_manager_->is_bot()) { + td_->contacts_manager_->on_update_channel_slow_mode_delay(channel_id_, slow_mode_delay_, Promise()); + if (!td_->auth_manager_->is_bot()) { promise_.set_value(Unit()); return; } } else { - td->contacts_manager_->on_get_channel_error(channel_id_, status, "ToggleSlowModeQuery"); + td_->contacts_manager_->on_get_channel_error(channel_id_, status, "ToggleSlowModeQuery"); } promise_.set_error(std::move(status)); } @@ -1449,10 +1449,10 @@ class ReportChannelSpamQuery final : public Td::ResultHandler { << " and " << user_id; channel_id_ = channel_id; - auto input_channel = td->contacts_manager_->get_input_channel(channel_id); + auto input_channel = td_->contacts_manager_->get_input_channel(channel_id); CHECK(input_channel != nullptr); - auto input_user = td->contacts_manager_->get_input_user(user_id); + auto input_user = td_->contacts_manager_->get_input_user(user_id); CHECK(input_user != nullptr); send_query(G()->net_query_creator().create(telegram_api::channels_reportSpam( @@ -1472,7 +1472,7 @@ class ReportChannelSpamQuery final : public Td::ResultHandler { } void on_error(Status status) final { - td->contacts_manager_->on_get_channel_error(channel_id_, status, "ReportChannelSpamQuery"); + td_->contacts_manager_->on_get_channel_error(channel_id_, status, "ReportChannelSpamQuery"); promise_.set_error(std::move(status)); } }; @@ -1495,8 +1495,8 @@ class DeleteChatQuery final : public Td::ResultHandler { } LOG(INFO) << "Receive result for DeleteChatQuery: " << result_ptr.ok(); - td->updates_manager_->get_difference("DeleteChatQuery"); - td->updates_manager_->on_get_updates(make_tl_object(), std::move(promise_)); + td_->updates_manager_->get_difference("DeleteChatQuery"); + td_->updates_manager_->on_get_updates(make_tl_object(), std::move(promise_)); } void on_error(Status status) final { @@ -1514,7 +1514,7 @@ class DeleteChannelQuery final : public Td::ResultHandler { void send(ChannelId channel_id) { channel_id_ = channel_id; - auto input_channel = td->contacts_manager_->get_input_channel(channel_id); + auto input_channel = td_->contacts_manager_->get_input_channel(channel_id); CHECK(input_channel != nullptr); send_query(G()->net_query_creator().create(telegram_api::channels_deleteChannel(std::move(input_channel)))); } @@ -1527,11 +1527,11 @@ class DeleteChannelQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for DeleteChannelQuery: " << to_string(ptr); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { - td->contacts_manager_->on_get_channel_error(channel_id_, status, "DeleteChannelQuery"); + td_->contacts_manager_->on_get_channel_error(channel_id_, status, "DeleteChannelQuery"); promise_.set_error(std::move(status)); } }; @@ -1556,12 +1556,12 @@ class AddChatUserQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for AddChatUserQuery: " << to_string(ptr); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { promise_.set_error(std::move(status)); - td->updates_manager_->get_difference("AddChatUserQuery"); + td_->updates_manager_->get_difference("AddChatUserQuery"); } }; @@ -1597,7 +1597,7 @@ class EditChatAdminQuery final : public Td::ResultHandler { void on_error(Status status) final { promise_.set_error(std::move(status)); - td->updates_manager_->get_difference("EditChatAdminQuery"); + td_->updates_manager_->get_difference("EditChatAdminQuery"); } }; @@ -1613,7 +1613,7 @@ class ExportChatInviteQuery final : public Td::ResultHandler { void send(DialogId dialog_id, const string &title, int32 expire_date, int32 usage_limit, bool creates_join_request, bool is_permanent) { dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); if (input_peer == nullptr) { return on_error(Status::Error(400, "Can't access the chat")); } @@ -1652,17 +1652,17 @@ class ExportChatInviteQuery final : public Td::ResultHandler { if (!invite_link.is_valid()) { return on_error(Status::Error(500, "Receive invalid invite link")); } - if (invite_link.get_creator_user_id() != td->contacts_manager_->get_my_id()) { + if (invite_link.get_creator_user_id() != td_->contacts_manager_->get_my_id()) { return on_error(Status::Error(500, "Receive invalid invite link creator")); } if (invite_link.is_permanent()) { - td->contacts_manager_->on_get_permanent_dialog_invite_link(dialog_id_, invite_link); + td_->contacts_manager_->on_get_permanent_dialog_invite_link(dialog_id_, invite_link); } - promise_.set_value(invite_link.get_chat_invite_link_object(td->contacts_manager_.get())); + promise_.set_value(invite_link.get_chat_invite_link_object(td_->contacts_manager_.get())); } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "ExportChatInviteQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "ExportChatInviteQuery"); promise_.set_error(std::move(status)); } }; @@ -1679,7 +1679,7 @@ class EditChatInviteLinkQuery final : public Td::ResultHandler { void send(DialogId dialog_id, const string &invite_link, const string &title, int32 expire_date, int32 usage_limit, bool creates_join_request) { dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); if (input_peer == nullptr) { return on_error(Status::Error(400, "Can't access the chat")); } @@ -1708,17 +1708,17 @@ class EditChatInviteLinkQuery final : public Td::ResultHandler { auto invite = move_tl_object_as(result); - td->contacts_manager_->on_get_users(std::move(invite->users_), "EditChatInviteLinkQuery"); + td_->contacts_manager_->on_get_users(std::move(invite->users_), "EditChatInviteLinkQuery"); DialogInviteLink invite_link(std::move(invite->invite_)); if (!invite_link.is_valid()) { return on_error(Status::Error(500, "Receive invalid invite link")); } - promise_.set_value(invite_link.get_chat_invite_link_object(td->contacts_manager_.get())); + promise_.set_value(invite_link.get_chat_invite_link_object(td_->contacts_manager_.get())); } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "EditChatInviteLinkQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "EditChatInviteLinkQuery"); promise_.set_error(std::move(status)); } }; @@ -1734,7 +1734,7 @@ class GetExportedChatInviteQuery final : public Td::ResultHandler { void send(DialogId dialog_id, const string &invite_link) { dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); if (input_peer == nullptr) { return on_error(Status::Error(400, "Can't access the chat")); } @@ -1757,18 +1757,18 @@ class GetExportedChatInviteQuery final : public Td::ResultHandler { auto result = move_tl_object_as(result_ptr.ok_ref()); LOG(INFO) << "Receive result for GetExportedChatInviteQuery: " << to_string(result); - td->contacts_manager_->on_get_users(std::move(result->users_), "GetExportedChatInviteQuery"); + td_->contacts_manager_->on_get_users(std::move(result->users_), "GetExportedChatInviteQuery"); DialogInviteLink invite_link(std::move(result->invite_)); if (!invite_link.is_valid()) { LOG(ERROR) << "Receive invalid invite link in " << dialog_id_; return on_error(Status::Error(500, "Receive invalid invite link")); } - promise_.set_value(invite_link.get_chat_invite_link_object(td->contacts_manager_.get())); + promise_.set_value(invite_link.get_chat_invite_link_object(td_->contacts_manager_.get())); } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetExportedChatInviteQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetExportedChatInviteQuery"); promise_.set_error(std::move(status)); } }; @@ -1785,12 +1785,12 @@ class GetExportedChatInvitesQuery final : public Td::ResultHandler { void send(DialogId dialog_id, UserId creator_user_id, bool is_revoked, int32 offset_date, const string &offset_invite_link, int32 limit) { dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); if (input_peer == nullptr) { return on_error(Status::Error(400, "Can't access the chat")); } - auto input_user = td->contacts_manager_->get_input_user(creator_user_id); + auto input_user = td_->contacts_manager_->get_input_user(creator_user_id); CHECK(input_user != nullptr); int32 flags = 0; @@ -1815,7 +1815,7 @@ class GetExportedChatInvitesQuery final : public Td::ResultHandler { auto result = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for GetExportedChatInvitesQuery: " << to_string(result); - td->contacts_manager_->on_get_users(std::move(result->users_), "GetExportedChatInvitesQuery"); + td_->contacts_manager_->on_get_users(std::move(result->users_), "GetExportedChatInvitesQuery"); int32 total_count = result->count_; if (total_count < static_cast(result->invites_.size())) { @@ -1830,13 +1830,13 @@ class GetExportedChatInvitesQuery final : public Td::ResultHandler { total_count--; continue; } - invite_links.push_back(invite_link.get_chat_invite_link_object(td->contacts_manager_.get())); + invite_links.push_back(invite_link.get_chat_invite_link_object(td_->contacts_manager_.get())); } promise_.set_value(td_api::make_object(total_count, std::move(invite_links))); } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetExportedChatInvitesQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetExportedChatInvitesQuery"); promise_.set_error(std::move(status)); } }; @@ -1852,7 +1852,7 @@ class GetChatAdminWithInvitesQuery final : public Td::ResultHandler { void send(DialogId dialog_id) { dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); if (input_peer == nullptr) { return on_error(Status::Error(400, "Can't access the chat")); } @@ -1869,7 +1869,7 @@ class GetChatAdminWithInvitesQuery final : public Td::ResultHandler { auto result = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for GetChatAdminWithInvitesQuery: " << to_string(result); - td->contacts_manager_->on_get_users(std::move(result->users_), "GetChatAdminWithInvitesQuery"); + td_->contacts_manager_->on_get_users(std::move(result->users_), "GetChatAdminWithInvitesQuery"); vector> invite_link_counts; for (auto &admin : result->admins_) { @@ -1879,14 +1879,14 @@ class GetChatAdminWithInvitesQuery final : public Td::ResultHandler { continue; } invite_link_counts.push_back(td_api::make_object( - td->contacts_manager_->get_user_id_object(user_id, "chatInviteLinkCount"), admin->invites_count_, + td_->contacts_manager_->get_user_id_object(user_id, "chatInviteLinkCount"), admin->invites_count_, admin->revoked_invites_count_)); } promise_.set_value(td_api::make_object(std::move(invite_link_counts))); } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetChatAdminWithInvitesQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetChatAdminWithInvitesQuery"); promise_.set_error(std::move(status)); } }; @@ -1902,12 +1902,12 @@ class GetChatInviteImportersQuery final : public Td::ResultHandler { void send(DialogId dialog_id, const string &invite_link, int32 offset_date, UserId offset_user_id, int32 limit) { dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); if (input_peer == nullptr) { return on_error(Status::Error(400, "Can't access the chat")); } - auto input_user = td->contacts_manager_->get_input_user(offset_user_id); + auto input_user = td_->contacts_manager_->get_input_user(offset_user_id); if (input_user == nullptr) { input_user = make_tl_object(); } @@ -1927,7 +1927,7 @@ class GetChatInviteImportersQuery final : public Td::ResultHandler { auto result = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for GetChatInviteImportersQuery: " << to_string(result); - td->contacts_manager_->on_get_users(std::move(result->users_), "GetChatInviteImportersQuery"); + td_->contacts_manager_->on_get_users(std::move(result->users_), "GetChatInviteImportersQuery"); int32 total_count = result->count_; if (total_count < static_cast(result->importers_.size())) { @@ -1945,14 +1945,14 @@ class GetChatInviteImportersQuery final : public Td::ResultHandler { continue; } invite_link_members.push_back(td_api::make_object( - td->contacts_manager_->get_user_id_object(user_id, "chatInviteLinkMember"), importer->date_, - td->contacts_manager_->get_user_id_object(approver_user_id, "chatInviteLinkMember"))); + td_->contacts_manager_->get_user_id_object(user_id, "chatInviteLinkMember"), importer->date_, + td_->contacts_manager_->get_user_id_object(approver_user_id, "chatInviteLinkMember"))); } promise_.set_value(td_api::make_object(total_count, std::move(invite_link_members))); } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetChatInviteImportersQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetChatInviteImportersQuery"); promise_.set_error(std::move(status)); } }; @@ -1969,12 +1969,12 @@ class GetChatJoinRequestsQuery final : public Td::ResultHandler { void send(DialogId dialog_id, const string &invite_link, const string &query, int32 offset_date, UserId offset_user_id, int32 limit) { dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); if (input_peer == nullptr) { return on_error(Status::Error(400, "Can't access the chat")); } - auto input_user = td->contacts_manager_->get_input_user(offset_user_id); + auto input_user = td_->contacts_manager_->get_input_user(offset_user_id); if (input_user == nullptr) { input_user = make_tl_object(); } @@ -2000,7 +2000,7 @@ class GetChatJoinRequestsQuery final : public Td::ResultHandler { auto result = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for GetChatJoinRequestsQuery: " << to_string(result); - td->contacts_manager_->on_get_users(std::move(result->users_), "GetChatJoinRequestsQuery"); + td_->contacts_manager_->on_get_users(std::move(result->users_), "GetChatJoinRequestsQuery"); int32 total_count = result->count_; if (total_count < static_cast(result->importers_.size())) { @@ -2021,15 +2021,15 @@ class GetChatJoinRequestsQuery final : public Td::ResultHandler { recent_requesters.push_back(user_id.get()); } join_requests.push_back(td_api::make_object( - td->contacts_manager_->get_user_id_object(user_id, "chatJoinRequest"), request->date_, request->about_)); + td_->contacts_manager_->get_user_id_object(user_id, "chatJoinRequest"), request->date_, request->about_)); } - td->messages_manager_->on_update_dialog_pending_join_requests(dialog_id_, total_count, - std::move(recent_requesters)); + td_->messages_manager_->on_update_dialog_pending_join_requests(dialog_id_, total_count, + std::move(recent_requesters)); promise_.set_value(td_api::make_object(total_count, std::move(join_requests))); } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetChatJoinRequestsQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetChatJoinRequestsQuery"); promise_.set_error(std::move(status)); } }; @@ -2044,12 +2044,12 @@ class HideChatJoinRequestQuery final : public Td::ResultHandler { void send(DialogId dialog_id, UserId user_id, bool is_approved) { dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); if (input_peer == nullptr) { return on_error(Status::Error(400, "Can't access the chat")); } - auto input_user = td->contacts_manager_->get_input_user(user_id); + auto input_user = td_->contacts_manager_->get_input_user(user_id); if (input_user == nullptr) { return on_error(Status::Error(400, "Can't find user")); } @@ -2070,11 +2070,11 @@ class HideChatJoinRequestQuery final : public Td::ResultHandler { auto result = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for HideChatJoinRequestQuery: " << to_string(result); - td->updates_manager_->on_get_updates(std::move(result), std::move(promise_)); + td_->updates_manager_->on_get_updates(std::move(result), std::move(promise_)); } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "HideChatJoinRequestQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "HideChatJoinRequestQuery"); promise_.set_error(std::move(status)); } }; @@ -2090,7 +2090,7 @@ class RevokeChatInviteLinkQuery final : public Td::ResultHandler { void send(DialogId dialog_id, const string &invite_link) { dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); if (input_peer == nullptr) { return on_error(Status::Error(400, "Can't access the chat")); } @@ -2114,31 +2114,31 @@ class RevokeChatInviteLinkQuery final : public Td::ResultHandler { case telegram_api::messages_exportedChatInvite::ID: { auto invite = move_tl_object_as(result); - td->contacts_manager_->on_get_users(std::move(invite->users_), "RevokeChatInviteLinkQuery"); + td_->contacts_manager_->on_get_users(std::move(invite->users_), "RevokeChatInviteLinkQuery"); DialogInviteLink invite_link(std::move(invite->invite_)); if (!invite_link.is_valid()) { return on_error(Status::Error(500, "Receive invalid invite link")); } - links.push_back(invite_link.get_chat_invite_link_object(td->contacts_manager_.get())); + links.push_back(invite_link.get_chat_invite_link_object(td_->contacts_manager_.get())); break; } case telegram_api::messages_exportedChatInviteReplaced::ID: { auto invite = move_tl_object_as(result); - td->contacts_manager_->on_get_users(std::move(invite->users_), "RevokeChatInviteLinkQuery"); + td_->contacts_manager_->on_get_users(std::move(invite->users_), "RevokeChatInviteLinkQuery"); DialogInviteLink invite_link(std::move(invite->invite_)); DialogInviteLink new_invite_link(std::move(invite->new_invite_)); if (!invite_link.is_valid() || !new_invite_link.is_valid()) { return on_error(Status::Error(500, "Receive invalid invite link")); } - if (new_invite_link.get_creator_user_id() == td->contacts_manager_->get_my_id() && + if (new_invite_link.get_creator_user_id() == td_->contacts_manager_->get_my_id() && new_invite_link.is_permanent()) { - td->contacts_manager_->on_get_permanent_dialog_invite_link(dialog_id_, new_invite_link); + td_->contacts_manager_->on_get_permanent_dialog_invite_link(dialog_id_, new_invite_link); } - links.push_back(invite_link.get_chat_invite_link_object(td->contacts_manager_.get())); - links.push_back(new_invite_link.get_chat_invite_link_object(td->contacts_manager_.get())); + links.push_back(invite_link.get_chat_invite_link_object(td_->contacts_manager_.get())); + links.push_back(new_invite_link.get_chat_invite_link_object(td_->contacts_manager_.get())); break; } default: @@ -2149,7 +2149,7 @@ class RevokeChatInviteLinkQuery final : public Td::ResultHandler { } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "RevokeChatInviteLinkQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "RevokeChatInviteLinkQuery"); promise_.set_error(std::move(status)); } }; @@ -2164,7 +2164,7 @@ class DeleteExportedChatInviteQuery final : public Td::ResultHandler { void send(DialogId dialog_id, const string &invite_link) { dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); if (input_peer == nullptr) { return on_error(Status::Error(400, "Can't access the chat")); } @@ -2183,7 +2183,7 @@ class DeleteExportedChatInviteQuery final : public Td::ResultHandler { } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "DeleteExportedChatInviteQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "DeleteExportedChatInviteQuery"); promise_.set_error(std::move(status)); } }; @@ -2198,12 +2198,12 @@ class DeleteRevokedExportedChatInvitesQuery final : public Td::ResultHandler { void send(DialogId dialog_id, UserId creator_user_id) { dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); if (input_peer == nullptr) { return on_error(Status::Error(400, "Can't access the chat")); } - auto input_user = td->contacts_manager_->get_input_user(creator_user_id); + auto input_user = td_->contacts_manager_->get_input_user(creator_user_id); CHECK(input_user != nullptr); send_query(G()->net_query_creator().create( @@ -2220,7 +2220,7 @@ class DeleteRevokedExportedChatInvitesQuery final : public Td::ResultHandler { } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "DeleteRevokedExportedChatInvitesQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "DeleteRevokedExportedChatInvitesQuery"); promise_.set_error(std::move(status)); } }; @@ -2248,7 +2248,7 @@ class CheckChatInviteQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for CheckChatInviteQuery: " << to_string(ptr); - td->contacts_manager_->on_get_dialog_invite_link_info(invite_link_, std::move(ptr), std::move(promise_)); + td_->contacts_manager_->on_get_dialog_invite_link_info(invite_link_, std::move(ptr), std::move(promise_)); } void on_error(Status status) final { @@ -2287,15 +2287,15 @@ class ImportChatInviteQuery final : public Td::ResultHandler { } auto dialog_id = dialog_ids[0]; - td->contacts_manager_->invalidate_invite_link_info(invite_link_); - td->updates_manager_->on_get_updates( + td_->contacts_manager_->invalidate_invite_link_info(invite_link_); + td_->updates_manager_->on_get_updates( std::move(ptr), PromiseCreator::lambda([promise = std::move(promise_), dialog_id](Unit) mutable { promise.set_value(std::move(dialog_id)); })); } void on_error(Status status) final { - td->contacts_manager_->invalidate_invite_link_info(invite_link_); + td_->contacts_manager_->invalidate_invite_link_info(invite_link_); promise_.set_error(std::move(status)); } }; @@ -2324,12 +2324,12 @@ class DeleteChatUserQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for DeleteChatUserQuery: " << to_string(ptr); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { promise_.set_error(std::move(status)); - td->updates_manager_->get_difference("DeleteChatUserQuery"); + td_->updates_manager_->get_difference("DeleteChatUserQuery"); } }; @@ -2343,7 +2343,7 @@ class JoinChannelQuery final : public Td::ResultHandler { void send(ChannelId channel_id) { channel_id_ = channel_id; - auto input_channel = td->contacts_manager_->get_input_channel(channel_id); + auto input_channel = td_->contacts_manager_->get_input_channel(channel_id); CHECK(input_channel != nullptr); send_query(G()->net_query_creator().create(telegram_api::channels_joinChannel(std::move(input_channel)))); } @@ -2356,13 +2356,13 @@ class JoinChannelQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for JoinChannelQuery: " << to_string(ptr); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { - td->contacts_manager_->on_get_channel_error(channel_id_, status, "JoinChannelQuery"); + td_->contacts_manager_->on_get_channel_error(channel_id_, status, "JoinChannelQuery"); promise_.set_error(std::move(status)); - td->updates_manager_->get_difference("JoinChannelQuery"); + td_->updates_manager_->get_difference("JoinChannelQuery"); } }; @@ -2376,7 +2376,7 @@ class InviteToChannelQuery final : public Td::ResultHandler { void send(ChannelId channel_id, vector> &&input_users) { channel_id_ = channel_id; - auto input_channel = td->contacts_manager_->get_input_channel(channel_id); + auto input_channel = td_->contacts_manager_->get_input_channel(channel_id); CHECK(input_channel != nullptr); send_query(G()->net_query_creator().create( telegram_api::channels_inviteToChannel(std::move(input_channel), std::move(input_users)))); @@ -2390,14 +2390,14 @@ class InviteToChannelQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for InviteToChannelQuery: " << to_string(ptr); - td->contacts_manager_->invalidate_channel_full(channel_id_, false); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->contacts_manager_->invalidate_channel_full(channel_id_, false); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { - td->contacts_manager_->on_get_channel_error(channel_id_, status, "InviteToChannelQuery"); + td_->contacts_manager_->on_get_channel_error(channel_id_, status, "InviteToChannelQuery"); promise_.set_error(std::move(status)); - td->updates_manager_->get_difference("InviteToChannelQuery"); + td_->updates_manager_->get_difference("InviteToChannelQuery"); } }; @@ -2412,7 +2412,7 @@ class EditChannelAdminQuery final : public Td::ResultHandler { void send(ChannelId channel_id, tl_object_ptr &&input_user, const DialogParticipantStatus &status) { channel_id_ = channel_id; - auto input_channel = td->contacts_manager_->get_input_channel(channel_id); + auto input_channel = td_->contacts_manager_->get_input_channel(channel_id); CHECK(input_channel != nullptr); 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()))); @@ -2426,14 +2426,14 @@ class EditChannelAdminQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for EditChannelAdminQuery: " << to_string(ptr); - td->contacts_manager_->invalidate_channel_full(channel_id_, false); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->contacts_manager_->invalidate_channel_full(channel_id_, false); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { - td->contacts_manager_->on_get_channel_error(channel_id_, status, "EditChannelAdminQuery"); + td_->contacts_manager_->on_get_channel_error(channel_id_, status, "EditChannelAdminQuery"); promise_.set_error(std::move(status)); - td->updates_manager_->get_difference("EditChannelAdminQuery"); + td_->updates_manager_->get_difference("EditChannelAdminQuery"); } }; @@ -2448,7 +2448,7 @@ class EditChannelBannedQuery final : public Td::ResultHandler { void send(ChannelId channel_id, tl_object_ptr &&input_peer, const DialogParticipantStatus &status) { channel_id_ = channel_id; - auto input_channel = td->contacts_manager_->get_input_channel(channel_id); + auto input_channel = td_->contacts_manager_->get_input_channel(channel_id); CHECK(input_channel != nullptr); send_query(G()->net_query_creator().create(telegram_api::channels_editBanned( std::move(input_channel), std::move(input_peer), status.get_chat_banned_rights()))); @@ -2462,14 +2462,14 @@ class EditChannelBannedQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for EditChannelBannedQuery: " << to_string(ptr); - td->contacts_manager_->invalidate_channel_full(channel_id_, false); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->contacts_manager_->invalidate_channel_full(channel_id_, false); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { - td->contacts_manager_->on_get_channel_error(channel_id_, status, "EditChannelBannedQuery"); + td_->contacts_manager_->on_get_channel_error(channel_id_, status, "EditChannelBannedQuery"); promise_.set_error(std::move(status)); - td->updates_manager_->get_difference("EditChannelBannedQuery"); + td_->updates_manager_->get_difference("EditChannelBannedQuery"); } }; @@ -2483,7 +2483,7 @@ class LeaveChannelQuery final : public Td::ResultHandler { void send(ChannelId channel_id) { channel_id_ = channel_id; - auto input_channel = td->contacts_manager_->get_input_channel(channel_id); + auto input_channel = td_->contacts_manager_->get_input_channel(channel_id); CHECK(input_channel != nullptr); send_query(G()->net_query_creator().create(telegram_api::channels_leaveChannel(std::move(input_channel)))); } @@ -2496,13 +2496,13 @@ class LeaveChannelQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for LeaveChannelQuery: " << to_string(ptr); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { - td->contacts_manager_->on_get_channel_error(channel_id_, status, "LeaveChannelQuery"); + td_->contacts_manager_->on_get_channel_error(channel_id_, status, "LeaveChannelQuery"); promise_.set_error(std::move(status)); - td->updates_manager_->get_difference("LeaveChannelQuery"); + td_->updates_manager_->get_difference("LeaveChannelQuery"); } }; @@ -2514,7 +2514,7 @@ class CanEditChannelCreatorQuery final : public Td::ResultHandler { } void send() { - auto input_user = td->contacts_manager_->get_input_user(td->contacts_manager_->get_my_id()); + 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(telegram_api::channels_editCreator( telegram_api::make_object(), std::move(input_user), @@ -2548,11 +2548,11 @@ class EditChannelCreatorQuery final : public Td::ResultHandler { void send(ChannelId channel_id, UserId user_id, tl_object_ptr input_check_password) { channel_id_ = channel_id; - auto input_channel = td->contacts_manager_->get_input_channel(channel_id); + auto input_channel = td_->contacts_manager_->get_input_channel(channel_id); if (input_channel == nullptr) { return promise_.set_error(Status::Error(400, "Have no access to the chat")); } - auto input_user = td->contacts_manager_->get_input_user(user_id); + auto input_user = td_->contacts_manager_->get_input_user(user_id); if (input_user == nullptr) { return promise_.set_error(Status::Error(400, "Have no access to the user")); } @@ -2568,14 +2568,14 @@ class EditChannelCreatorQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for EditChannelCreatorQuery: " << to_string(ptr); - td->contacts_manager_->invalidate_channel_full(channel_id_, false); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->contacts_manager_->invalidate_channel_full(channel_id_, false); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { - td->contacts_manager_->on_get_channel_error(channel_id_, status, "EditChannelCreatorQuery"); + td_->contacts_manager_->on_get_channel_error(channel_id_, status, "EditChannelCreatorQuery"); promise_.set_error(std::move(status)); - td->updates_manager_->get_difference("EditChannelCreatorQuery"); + td_->updates_manager_->get_difference("EditChannelCreatorQuery"); } }; @@ -2598,12 +2598,12 @@ class MigrateChatQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for MigrateChatQuery: " << to_string(ptr); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { promise_.set_error(std::move(status)); - td->updates_manager_->get_difference("MigrateChatQuery"); + td_->updates_manager_->get_difference("MigrateChatQuery"); } }; @@ -2640,13 +2640,13 @@ class GetCreatedPublicChannelsQuery final : public Td::ResultHandler { switch (constructor_id) { case telegram_api::messages_chats::ID: { auto chats = move_tl_object_as(chats_ptr); - td->contacts_manager_->on_get_created_public_channels(type_, std::move(chats->chats_)); + td_->contacts_manager_->on_get_created_public_channels(type_, std::move(chats->chats_)); break; } case telegram_api::messages_chatsSlice::ID: { auto chats = move_tl_object_as(chats_ptr); LOG(ERROR) << "Receive chatsSlice in result of GetCreatedPublicChannelsQuery"; - td->contacts_manager_->on_get_created_public_channels(type_, std::move(chats->chats_)); + td_->contacts_manager_->on_get_created_public_channels(type_, std::move(chats->chats_)); break; } default: @@ -2684,13 +2684,13 @@ class GetGroupsForDiscussionQuery final : public Td::ResultHandler { switch (constructor_id) { case telegram_api::messages_chats::ID: { auto chats = move_tl_object_as(chats_ptr); - td->contacts_manager_->on_get_dialogs_for_discussion(std::move(chats->chats_)); + td_->contacts_manager_->on_get_dialogs_for_discussion(std::move(chats->chats_)); break; } case telegram_api::messages_chatsSlice::ID: { auto chats = move_tl_object_as(chats_ptr); LOG(ERROR) << "Receive chatsSlice in result of GetCreatedPublicChannelsQuery"; - td->contacts_manager_->on_get_dialogs_for_discussion(std::move(chats->chats_)); + td_->contacts_manager_->on_get_dialogs_for_discussion(std::move(chats->chats_)); break; } default: @@ -2725,8 +2725,8 @@ class GetInactiveChannelsQuery final : public Td::ResultHandler { auto result = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for GetInactiveChannelsQuery: " << to_string(result); // TODO use result->dates_ - td->contacts_manager_->on_get_users(std::move(result->users_), "GetInactiveChannelsQuery"); - td->contacts_manager_->on_get_inactive_channels(std::move(result->chats_)); + td_->contacts_manager_->on_get_users(std::move(result->users_), "GetInactiveChannelsQuery"); + td_->contacts_manager_->on_get_inactive_channels(std::move(result->chats_)); promise_.set_value(Unit()); } @@ -2753,7 +2753,7 @@ class GetUsersQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - td->contacts_manager_->on_get_users(result_ptr.move_as_ok(), "GetUsersQuery"); + td_->contacts_manager_->on_get_users(result_ptr.move_as_ok(), "GetUsersQuery"); promise_.set_value(Unit()); } @@ -2781,7 +2781,7 @@ class GetFullUserQuery final : public Td::ResultHandler { } LOG(DEBUG) << "Receive result for GetFullUserQuery: " << to_string(result_ptr.ok()); - td->contacts_manager_->on_get_user_full(result_ptr.move_as_ok()); + td_->contacts_manager_->on_get_user_full(result_ptr.move_as_ok()); promise_.set_value(Unit()); } @@ -2824,15 +2824,15 @@ class GetUserPhotosQuery final : public Td::ResultHandler { if (constructor_id == telegram_api::photos_photos::ID) { auto photos = move_tl_object_as(ptr); - td->contacts_manager_->on_get_users(std::move(photos->users_), "GetUserPhotosQuery"); + td_->contacts_manager_->on_get_users(std::move(photos->users_), "GetUserPhotosQuery"); auto photos_size = narrow_cast(photos->photos_.size()); - td->contacts_manager_->on_get_user_photos(user_id_, offset_, limit_, photos_size, std::move(photos->photos_)); + td_->contacts_manager_->on_get_user_photos(user_id_, offset_, limit_, photos_size, std::move(photos->photos_)); } else { CHECK(constructor_id == telegram_api::photos_photosSlice::ID); auto photos = move_tl_object_as(ptr); - td->contacts_manager_->on_get_users(std::move(photos->users_), "GetUserPhotosQuery"); - td->contacts_manager_->on_get_user_photos(user_id_, offset_, limit_, photos->count_, std::move(photos->photos_)); + td_->contacts_manager_->on_get_users(std::move(photos->users_), "GetUserPhotosQuery"); + td_->contacts_manager_->on_get_user_photos(user_id_, offset_, limit_, photos->count_, std::move(photos->photos_)); } promise_.set_value(Unit()); @@ -2865,13 +2865,13 @@ class GetChatsQuery final : public Td::ResultHandler { switch (constructor_id) { case telegram_api::messages_chats::ID: { auto chats = move_tl_object_as(chats_ptr); - td->contacts_manager_->on_get_chats(std::move(chats->chats_), "GetChatsQuery"); + td_->contacts_manager_->on_get_chats(std::move(chats->chats_), "GetChatsQuery"); break; } case telegram_api::messages_chatsSlice::ID: { auto chats = move_tl_object_as(chats_ptr); LOG(ERROR) << "Receive chatsSlice in result of GetChatsQuery"; - td->contacts_manager_->on_get_chats(std::move(chats->chats_), "GetChatsQuery"); + td_->contacts_manager_->on_get_chats(std::move(chats->chats_), "GetChatsQuery"); break; } default: @@ -2906,13 +2906,13 @@ class GetFullChatQuery final : public Td::ResultHandler { } auto ptr = result_ptr.move_as_ok(); - td->contacts_manager_->on_get_users(std::move(ptr->users_), "GetFullChatQuery"); - td->contacts_manager_->on_get_chats(std::move(ptr->chats_), "GetFullChatQuery"); - td->contacts_manager_->on_get_chat_full(std::move(ptr->full_chat_), std::move(promise_)); + td_->contacts_manager_->on_get_users(std::move(ptr->users_), "GetFullChatQuery"); + td_->contacts_manager_->on_get_chats(std::move(ptr->chats_), "GetFullChatQuery"); + td_->contacts_manager_->on_get_chat_full(std::move(ptr->full_chat_), std::move(promise_)); } void on_error(Status status) final { - td->contacts_manager_->on_get_chat_full_failed(chat_id_); + td_->contacts_manager_->on_get_chat_full_failed(chat_id_); promise_.set_error(std::move(status)); } }; @@ -2948,13 +2948,13 @@ class GetChannelsQuery final : public Td::ResultHandler { switch (constructor_id) { case telegram_api::messages_chats::ID: { auto chats = move_tl_object_as(chats_ptr); - td->contacts_manager_->on_get_chats(std::move(chats->chats_), "GetChannelsQuery"); + td_->contacts_manager_->on_get_chats(std::move(chats->chats_), "GetChannelsQuery"); break; } case telegram_api::messages_chatsSlice::ID: { auto chats = move_tl_object_as(chats_ptr); LOG(ERROR) << "Receive chatsSlice in result of GetChannelsQuery"; - td->contacts_manager_->on_get_chats(std::move(chats->chats_), "GetChannelsQuery"); + td_->contacts_manager_->on_get_chats(std::move(chats->chats_), "GetChannelsQuery"); break; } default: @@ -2965,7 +2965,7 @@ class GetChannelsQuery final : public Td::ResultHandler { } void on_error(Status status) final { - td->contacts_manager_->on_get_channel_error(channel_id_, status, "GetChannelsQuery"); + td_->contacts_manager_->on_get_channel_error(channel_id_, status, "GetChannelsQuery"); promise_.set_error(std::move(status)); } }; @@ -2990,14 +2990,14 @@ class GetFullChannelQuery final : public Td::ResultHandler { } auto ptr = result_ptr.move_as_ok(); - td->contacts_manager_->on_get_users(std::move(ptr->users_), "GetFullChannelQuery"); - td->contacts_manager_->on_get_chats(std::move(ptr->chats_), "GetFullChannelQuery"); - td->contacts_manager_->on_get_chat_full(std::move(ptr->full_chat_), std::move(promise_)); + td_->contacts_manager_->on_get_users(std::move(ptr->users_), "GetFullChannelQuery"); + td_->contacts_manager_->on_get_chats(std::move(ptr->chats_), "GetFullChannelQuery"); + td_->contacts_manager_->on_get_chat_full(std::move(ptr->full_chat_), std::move(promise_)); } void on_error(Status status) final { - td->contacts_manager_->on_get_channel_error(channel_id_, status, "GetFullChannelQuery"); - td->contacts_manager_->on_get_channel_full_failed(channel_id_); + td_->contacts_manager_->on_get_channel_error(channel_id_, status, "GetFullChannelQuery"); + td_->contacts_manager_->on_get_channel_full_failed(channel_id_); promise_.set_error(std::move(status)); } }; @@ -3012,7 +3012,7 @@ class GetChannelParticipantQuery final : public Td::ResultHandler { } void send(ChannelId channel_id, DialogId participant_dialog_id, tl_object_ptr &&input_peer) { - auto input_channel = td->contacts_manager_->get_input_channel(channel_id); + auto input_channel = td_->contacts_manager_->get_input_channel(channel_id); if (input_channel == nullptr) { return promise_.set_error(Status::Error(400, "Supergroup not found")); } @@ -3034,8 +3034,8 @@ class GetChannelParticipantQuery final : public Td::ResultHandler { auto participant = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for GetChannelParticipantQuery: " << to_string(participant); - td->contacts_manager_->on_get_users(std::move(participant->users_), "GetChannelParticipantQuery"); - td->contacts_manager_->on_get_chats(std::move(participant->chats_), "GetChannelParticipantQuery"); + td_->contacts_manager_->on_get_users(std::move(participant->users_), "GetChannelParticipantQuery"); + td_->contacts_manager_->on_get_chats(std::move(participant->chats_), "GetChannelParticipantQuery"); DialogParticipant result(std::move(participant->participant_)); if (!result.is_valid()) { LOG(ERROR) << "Receive invalid " << result; @@ -3050,7 +3050,7 @@ class GetChannelParticipantQuery final : public Td::ResultHandler { return; } - // td->contacts_manager_->on_get_channel_error(channel_id_, status, "GetChannelParticipantQuery"); + // td_->contacts_manager_->on_get_channel_error(channel_id_, status, "GetChannelParticipantQuery"); promise_.set_error(std::move(status)); } }; @@ -3065,7 +3065,7 @@ class GetChannelParticipantsQuery final : public Td::ResultHandler { } void send(ChannelId channel_id, const ChannelParticipantsFilter &filter, int32 offset, int32 limit) { - auto input_channel = td->contacts_manager_->get_input_channel(channel_id); + auto input_channel = td_->contacts_manager_->get_input_channel(channel_id); if (input_channel == nullptr) { return promise_.set_error(Status::Error(400, "Supergroup not found")); } @@ -3097,7 +3097,7 @@ class GetChannelParticipantsQuery final : public Td::ResultHandler { } void on_error(Status status) final { - td->contacts_manager_->on_get_channel_error(channel_id_, status, "GetChannelParticipantsQuery"); + td_->contacts_manager_->on_get_channel_error(channel_id_, status, "GetChannelParticipantsQuery"); promise_.set_error(std::move(status)); } }; @@ -3111,7 +3111,7 @@ class GetChannelAdministratorsQuery final : public Td::ResultHandler { } void send(ChannelId channel_id, int64 hash) { - auto input_channel = td->contacts_manager_->get_input_channel(channel_id); + auto input_channel = td_->contacts_manager_->get_input_channel(channel_id); if (input_channel == nullptr) { return promise_.set_error(Status::Error(400, "Supergroup not found")); } @@ -3135,8 +3135,8 @@ class GetChannelAdministratorsQuery final : public Td::ResultHandler { switch (participants_ptr->get_id()) { case telegram_api::channels_channelParticipants::ID: { auto participants = telegram_api::move_object_as(participants_ptr); - td->contacts_manager_->on_get_users(std::move(participants->users_), "GetChannelAdministratorsQuery"); - td->contacts_manager_->on_get_chats(std::move(participants->chats_), "GetChannelAdministratorsQuery"); + td_->contacts_manager_->on_get_users(std::move(participants->users_), "GetChannelAdministratorsQuery"); + td_->contacts_manager_->on_get_chats(std::move(participants->chats_), "GetChannelAdministratorsQuery"); vector administrators; administrators.reserve(participants->participants_.size()); for (auto &participant : participants->participants_) { @@ -3150,10 +3150,10 @@ class GetChannelAdministratorsQuery final : public Td::ResultHandler { dialog_participant.status_.get_rank(), dialog_participant.status_.is_creator()); } - td->contacts_manager_->on_update_channel_administrator_count(channel_id_, - narrow_cast(administrators.size())); - td->contacts_manager_->on_update_dialog_administrators(DialogId(channel_id_), std::move(administrators), true, - false); + td_->contacts_manager_->on_update_channel_administrator_count(channel_id_, + narrow_cast(administrators.size())); + td_->contacts_manager_->on_update_dialog_administrators(DialogId(channel_id_), std::move(administrators), true, + false); break; } @@ -3167,7 +3167,7 @@ class GetChannelAdministratorsQuery final : public Td::ResultHandler { } void on_error(Status status) final { - td->contacts_manager_->on_get_channel_error(channel_id_, status, "GetChannelAdministratorsQuery"); + td_->contacts_manager_->on_get_channel_error(channel_id_, status, "GetChannelAdministratorsQuery"); promise_.set_error(std::move(status)); } }; @@ -3192,7 +3192,7 @@ class GetSupportUserQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for GetSupportUserQuery: " << to_string(ptr); - td->contacts_manager_->on_get_user(std::move(ptr->user_), "GetSupportUserQuery", false, true); + td_->contacts_manager_->on_get_user(std::move(ptr->user_), "GetSupportUserQuery", false, true); promise_.set_value(Unit()); } @@ -3329,7 +3329,7 @@ class GetMegagroupStatsQuery final : public Td::ResultHandler { void send(ChannelId channel_id, bool is_dark, DcId dc_id) { channel_id_ = channel_id; - auto input_channel = td->contacts_manager_->get_input_channel(channel_id); + auto input_channel = td_->contacts_manager_->get_input_channel(channel_id); CHECK(input_channel != nullptr); int32 flags = 0; @@ -3346,11 +3346,11 @@ class GetMegagroupStatsQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - promise_.set_value(td->contacts_manager_->convert_megagroup_stats(result_ptr.move_as_ok())); + promise_.set_value(td_->contacts_manager_->convert_megagroup_stats(result_ptr.move_as_ok())); } void on_error(Status status) final { - td->contacts_manager_->on_get_channel_error(channel_id_, status, "GetMegagroupStatsQuery"); + td_->contacts_manager_->on_get_channel_error(channel_id_, status, "GetMegagroupStatsQuery"); promise_.set_error(std::move(status)); } }; @@ -3367,7 +3367,7 @@ class GetBroadcastStatsQuery final : public Td::ResultHandler { void send(ChannelId channel_id, bool is_dark, DcId dc_id) { channel_id_ = channel_id; - auto input_channel = td->contacts_manager_->get_input_channel(channel_id); + auto input_channel = td_->contacts_manager_->get_input_channel(channel_id); CHECK(input_channel != nullptr); int32 flags = 0; @@ -3386,15 +3386,15 @@ class GetBroadcastStatsQuery final : public Td::ResultHandler { auto result = ContactsManager::convert_broadcast_stats(result_ptr.move_as_ok()); for (auto &info : result->recent_message_interactions_) { - td->messages_manager_->on_update_message_interaction_info({DialogId(channel_id_), MessageId(info->message_id_)}, - info->view_count_, info->forward_count_, false, - nullptr); + td_->messages_manager_->on_update_message_interaction_info({DialogId(channel_id_), MessageId(info->message_id_)}, + info->view_count_, info->forward_count_, false, + nullptr); } promise_.set_value(std::move(result)); } void on_error(Status status) final { - td->contacts_manager_->on_get_channel_error(channel_id_, status, "GetBroadcastStatsQuery"); + td_->contacts_manager_->on_get_channel_error(channel_id_, status, "GetBroadcastStatsQuery"); promise_.set_error(std::move(status)); } }; @@ -3416,7 +3416,7 @@ class GetMessageStatsQuery final : public Td::ResultHandler { void send(ChannelId channel_id, MessageId message_id, bool is_dark, DcId dc_id) { channel_id_ = channel_id; - auto input_channel = td->contacts_manager_->get_input_channel(channel_id); + auto input_channel = td_->contacts_manager_->get_input_channel(channel_id); CHECK(input_channel != nullptr); int32 flags = 0; @@ -3435,11 +3435,11 @@ class GetMessageStatsQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - promise_.set_value(td->contacts_manager_->convert_message_stats(result_ptr.move_as_ok())); + promise_.set_value(td_->contacts_manager_->convert_message_stats(result_ptr.move_as_ok())); } void on_error(Status status) final { - td->contacts_manager_->on_get_channel_error(channel_id_, status, "GetMessageStatsQuery"); + td_->contacts_manager_->on_get_channel_error(channel_id_, status, "GetMessageStatsQuery"); promise_.set_error(std::move(status)); } }; diff --git a/td/telegram/GameManager.cpp b/td/telegram/GameManager.cpp index 266193d8c..ec0e28167 100644 --- a/td/telegram/GameManager.cpp +++ b/td/telegram/GameManager.cpp @@ -48,7 +48,7 @@ class SetGameScoreActor final : public NetActorOnce { dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Edit); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Edit); if (input_peer == nullptr) { on_error(Status::Error(400, "Can't access the chat")); stop(); @@ -63,7 +63,7 @@ class SetGameScoreActor final : public NetActorOnce { LOG(INFO) << "Set game score to " << score; query->debug("send to MultiSequenceDispatcher"); - send_closure(td->messages_manager_->sequence_dispatcher_, &MultiSequenceDispatcher::send_with_callback, + send_closure(td_->messages_manager_->sequence_dispatcher_, &MultiSequenceDispatcher::send_with_callback, std::move(query), actor_shared(this), sequence_dispatcher_id); } @@ -75,12 +75,12 @@ class SetGameScoreActor final : public NetActorOnce { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for SetGameScore: " << to_string(ptr); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { LOG(INFO) << "Receive error for SetGameScore: " << status; - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "SetGameScoreActor"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "SetGameScoreActor"); promise_.set_error(std::move(status)); } }; @@ -141,7 +141,7 @@ class GetGameHighScoresQuery final : public Td::ResultHandler { void send(DialogId dialog_id, MessageId message_id, tl_object_ptr input_user) { dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); CHECK(input_peer != nullptr); CHECK(input_user != nullptr); @@ -155,11 +155,11 @@ class GetGameHighScoresQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - promise_.set_value(td->game_manager_->get_game_high_scores_object(result_ptr.move_as_ok())); + promise_.set_value(td_->game_manager_->get_game_high_scores_object(result_ptr.move_as_ok())); } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetGameHighScoresQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetGameHighScoresQuery"); promise_.set_error(std::move(status)); } }; @@ -189,7 +189,7 @@ class GetInlineGameHighScoresQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - promise_.set_value(td->game_manager_->get_game_high_scores_object(result_ptr.move_as_ok())); + promise_.set_value(td_->game_manager_->get_game_high_scores_object(result_ptr.move_as_ok())); } void on_error(Status status) final { diff --git a/td/telegram/GroupCallManager.cpp b/td/telegram/GroupCallManager.cpp index b55ce18ca..c187ebd49 100644 --- a/td/telegram/GroupCallManager.cpp +++ b/td/telegram/GroupCallManager.cpp @@ -84,7 +84,7 @@ class GetGroupCallJoinAsQuery final : public Td::ResultHandler { void send(DialogId dialog_id) { dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); CHECK(input_peer != nullptr); send_query(G()->net_query_creator().create(telegram_api::phone_getGroupCallJoinAs(std::move(input_peer)))); @@ -99,8 +99,8 @@ class GetGroupCallJoinAsQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for GetGroupCallJoinAsQuery: " << to_string(ptr); - td->contacts_manager_->on_get_users(std::move(ptr->users_), "GetGroupCallJoinAsQuery"); - td->contacts_manager_->on_get_chats(std::move(ptr->chats_), "GetGroupCallJoinAsQuery"); + td_->contacts_manager_->on_get_users(std::move(ptr->users_), "GetGroupCallJoinAsQuery"); + td_->contacts_manager_->on_get_chats(std::move(ptr->chats_), "GetGroupCallJoinAsQuery"); vector> participant_aliaces; for (auto &peer : ptr->peers_) { @@ -110,11 +110,11 @@ class GetGroupCallJoinAsQuery final : public Td::ResultHandler { continue; } if (dialog_id.get_type() != DialogType::User) { - td->messages_manager_->force_create_dialog(dialog_id, "GetGroupCallJoinAsQuery"); + td_->messages_manager_->force_create_dialog(dialog_id, "GetGroupCallJoinAsQuery"); } participant_aliaces.push_back( - td->messages_manager_->get_message_sender_object(dialog_id, "GetGroupCallJoinAsQuery")); + td_->messages_manager_->get_message_sender_object(dialog_id, "GetGroupCallJoinAsQuery")); } promise_.set_value(td_api::make_object(static_cast(participant_aliaces.size()), @@ -122,7 +122,7 @@ class GetGroupCallJoinAsQuery final : public Td::ResultHandler { } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetGroupCallJoinAsQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetGroupCallJoinAsQuery"); promise_.set_error(std::move(status)); } }; @@ -135,10 +135,10 @@ class SaveDefaultGroupCallJoinAsQuery final : public Td::ResultHandler { } void send(DialogId dialog_id, DialogId as_dialog_id) { - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); CHECK(input_peer != nullptr); - auto as_input_peer = td->messages_manager_->get_input_peer(as_dialog_id, AccessRights::Read); + auto as_input_peer = td_->messages_manager_->get_input_peer(as_dialog_id, AccessRights::Read); CHECK(as_input_peer != nullptr); send_query(G()->net_query_creator().create( @@ -158,7 +158,7 @@ class SaveDefaultGroupCallJoinAsQuery final : public Td::ResultHandler { } void on_error(Status status) final { - // td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetGroupCallJoinAsQuery"); + // td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetGroupCallJoinAsQuery"); promise_.set_error(std::move(status)); } }; @@ -174,7 +174,7 @@ class CreateGroupCallQuery final : public Td::ResultHandler { void send(DialogId dialog_id, const string &title, int32 start_date) { dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); CHECK(input_peer != nullptr); int32 flags = 0; @@ -197,7 +197,7 @@ class CreateGroupCallQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for CreateGroupCallQuery: " << to_string(ptr); - auto group_call_ids = td->updates_manager_->get_update_new_group_call_ids(ptr.get()); + auto group_call_ids = td_->updates_manager_->get_update_new_group_call_ids(ptr.get()); if (group_call_ids.empty()) { LOG(ERROR) << "Receive wrong CreateGroupCallQuery response " << to_string(ptr); return on_error(Status::Error(500, "Receive wrong response")); @@ -210,14 +210,14 @@ class CreateGroupCallQuery final : public Td::ResultHandler { } } - td->updates_manager_->on_get_updates( + td_->updates_manager_->on_get_updates( std::move(ptr), PromiseCreator::lambda([promise = std::move(promise_), group_call_id](Unit) mutable { promise.set_value(std::move(group_call_id)); })); } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "CreateGroupCallQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "CreateGroupCallQuery"); promise_.set_error(std::move(status)); } }; @@ -274,8 +274,8 @@ class GetGroupCallParticipantQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - td->group_call_manager_->on_get_group_call_participants(input_group_call_id_, result_ptr.move_as_ok(), false, - string()); + td_->group_call_manager_->on_get_group_call_participants(input_group_call_id_, result_ptr.move_as_ok(), false, + string()); promise_.set_value(Unit()); } @@ -308,8 +308,8 @@ class GetGroupCallParticipantsQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - td->group_call_manager_->on_get_group_call_participants(input_group_call_id_, result_ptr.move_as_ok(), true, - offset_); + td_->group_call_manager_->on_get_group_call_participants(input_group_call_id_, result_ptr.move_as_ok(), true, + offset_); promise_.set_value(Unit()); } @@ -339,7 +339,7 @@ class StartScheduledGroupCallQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for StartScheduledGroupCallQuery: " << to_string(ptr); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { @@ -369,7 +369,7 @@ class JoinGroupCallQuery final : public Td::ResultHandler { tl_object_ptr join_as_input_peer; if (as_dialog_id.is_valid()) { - join_as_input_peer = td->messages_manager_->get_input_peer(as_dialog_id, AccessRights::Read); + join_as_input_peer = td_->messages_manager_->get_input_peer(as_dialog_id, AccessRights::Read); } else { join_as_input_peer = make_tl_object(); } @@ -401,8 +401,8 @@ class JoinGroupCallQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for JoinGroupCallQuery with generation " << generation_ << ": " << to_string(ptr); - td->group_call_manager_->process_join_group_call_response(input_group_call_id_, generation_, std::move(ptr), - std::move(promise_)); + td_->group_call_manager_->process_join_group_call_response(input_group_call_id_, generation_, std::move(ptr), + std::move(promise_)); } void on_error(Status status) final { @@ -435,13 +435,13 @@ class JoinGroupCallPresentationQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for JoinGroupCallPresentationQuery with generation " << generation_ << ": " << to_string(ptr); - td->group_call_manager_->process_join_group_call_presentation_response(input_group_call_id_, generation_, - std::move(ptr), Status::OK()); + td_->group_call_manager_->process_join_group_call_presentation_response(input_group_call_id_, generation_, + std::move(ptr), Status::OK()); } void on_error(Status status) final { - td->group_call_manager_->process_join_group_call_presentation_response(input_group_call_id_, generation_, nullptr, - std::move(status)); + td_->group_call_manager_->process_join_group_call_presentation_response(input_group_call_id_, generation_, nullptr, + std::move(status)); } }; @@ -465,7 +465,7 @@ class LeaveGroupCallPresentationQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for LeaveGroupCallPresentationQuery: " << to_string(ptr); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { @@ -497,7 +497,7 @@ class EditGroupCallTitleQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for EditGroupCallTitleQuery: " << to_string(ptr); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { @@ -529,7 +529,7 @@ class ToggleGroupCallStartSubscriptionQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for ToggleGroupCallStartSubscriptionQuery: " << to_string(ptr); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { @@ -561,7 +561,7 @@ class ToggleGroupCallSettingsQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for ToggleGroupCallSettingsQuery: " << to_string(ptr); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { @@ -593,7 +593,7 @@ class InviteToGroupCallQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for InviteToGroupCallQuery: " << to_string(ptr); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { @@ -664,7 +664,7 @@ class ToggleGroupCallRecordQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for ToggleGroupCallRecordQuery: " << to_string(ptr); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { @@ -687,7 +687,7 @@ class EditGroupCallParticipantQuery final : public Td::ResultHandler { int32 volume_level, bool set_raise_hand, bool raise_hand, bool set_video_is_stopped, bool video_is_stopped, bool set_video_is_paused, bool video_is_paused, bool set_presentation_is_paused, bool presentation_is_paused) { - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Know); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Know); if (input_peer == nullptr) { return on_error(Status::Error(400, "Can't access the chat")); } @@ -720,7 +720,7 @@ class EditGroupCallParticipantQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for EditGroupCallParticipantQuery: " << to_string(ptr); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { @@ -784,7 +784,7 @@ class LeaveGroupCallQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for LeaveGroupCallQuery: " << to_string(ptr); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { @@ -812,7 +812,7 @@ class DiscardGroupCallQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for DiscardGroupCallQuery: " << to_string(ptr); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { diff --git a/td/telegram/InlineQueriesManager.cpp b/td/telegram/InlineQueriesManager.cpp index c771645a4..3de99c5f3 100644 --- a/td/telegram/InlineQueriesManager.cpp +++ b/td/telegram/InlineQueriesManager.cpp @@ -95,8 +95,8 @@ class GetInlineBotResultsQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - td->inline_queries_manager_->on_get_inline_query_results(dialog_id_, bot_user_id_, query_hash_, - result_ptr.move_as_ok()); + td_->inline_queries_manager_->on_get_inline_query_results(dialog_id_, bot_user_id_, query_hash_, + result_ptr.move_as_ok()); promise_.set_value(Unit()); } @@ -108,7 +108,7 @@ class GetInlineBotResultsQuery final : public Td::ResultHandler { } LOG(INFO) << "Inline query returned error " << status; - td->inline_queries_manager_->on_get_inline_query_results(dialog_id_, bot_user_id_, query_hash_, nullptr); + td_->inline_queries_manager_->on_get_inline_query_results(dialog_id_, bot_user_id_, query_hash_, nullptr); promise_.set_error(std::move(status)); } }; diff --git a/td/telegram/LinkManager.cpp b/td/telegram/LinkManager.cpp index 383de3cc1..91f54c2e6 100644 --- a/td/telegram/LinkManager.cpp +++ b/td/telegram/LinkManager.cpp @@ -440,7 +440,7 @@ class RequestUrlAuthQuery final : public Td::ResultHandler { tl_object_ptr input_peer; if (full_message_id.get_dialog_id().is_valid()) { dialog_id_ = full_message_id.get_dialog_id(); - input_peer = td->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read); + input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read); CHECK(input_peer != nullptr); flags |= telegram_api::messages_requestUrlAuth::PEER_MASK; } else { @@ -466,9 +466,9 @@ class RequestUrlAuthQuery final : public Td::ResultHandler { if (!bot_user_id.is_valid()) { return on_error(Status::Error(500, "Receive invalid bot_user_id")); } - td->contacts_manager_->on_get_user(std::move(request->bot_), "RequestUrlAuthQuery"); + td_->contacts_manager_->on_get_user(std::move(request->bot_), "RequestUrlAuthQuery"); promise_.set_value(td_api::make_object( - url_, request->domain_, td->contacts_manager_->get_user_id_object(bot_user_id, "RequestUrlAuthQuery"), + url_, request->domain_, td_->contacts_manager_->get_user_id_object(bot_user_id, "RequestUrlAuthQuery"), request->request_write_access_)); break; } @@ -485,7 +485,7 @@ class RequestUrlAuthQuery final : public Td::ResultHandler { void on_error(Status status) final { if (!dialog_id_.is_valid() || - !td->messages_manager_->on_get_dialog_error(dialog_id_, status, "RequestUrlAuthQuery")) { + !td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "RequestUrlAuthQuery")) { LOG(INFO) << "RequestUrlAuthQuery returned " << status; } promise_.set_value(td_api::make_object(url_, false)); @@ -507,7 +507,7 @@ class AcceptUrlAuthQuery final : public Td::ResultHandler { tl_object_ptr input_peer; if (full_message_id.get_dialog_id().is_valid()) { dialog_id_ = full_message_id.get_dialog_id(); - input_peer = td->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read); + input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read); CHECK(input_peer != nullptr); flags |= telegram_api::messages_acceptUrlAuth::PEER_MASK; } else { @@ -546,7 +546,7 @@ class AcceptUrlAuthQuery final : public Td::ResultHandler { void on_error(Status status) final { if (!dialog_id_.is_valid() || - !td->messages_manager_->on_get_dialog_error(dialog_id_, status, "AcceptUrlAuthQuery")) { + !td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "AcceptUrlAuthQuery")) { LOG(INFO) << "AcceptUrlAuthQuery returned " << status; } promise_.set_error(std::move(status)); diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 5906b6b34..94e4ca608 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -203,7 +203,7 @@ class GetOnlinesQuery final : public Td::ResultHandler { void send(DialogId dialog_id) { dialog_id_ = dialog_id; CHECK(dialog_id.get_type() == DialogType::Channel); - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); if (input_peer == nullptr) { return on_error(Status::Error(400, "Can't access the chat")); } @@ -218,12 +218,12 @@ class GetOnlinesQuery final : public Td::ResultHandler { } auto result = result_ptr.move_as_ok(); - td->messages_manager_->on_update_dialog_online_member_count(dialog_id_, result->onlines_, true); + td_->messages_manager_->on_update_dialog_online_member_count(dialog_id_, result->onlines_, true); } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetOnlinesQuery"); - td->messages_manager_->on_update_dialog_online_member_count(dialog_id_, 0, true); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetOnlinesQuery"); + td_->messages_manager_->on_update_dialog_online_member_count(dialog_id_, 0, true); } }; @@ -241,7 +241,7 @@ class GetAllDraftsQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for GetAllDraftsQuery: " << to_string(ptr); - td->updates_manager_->on_get_updates(std::move(ptr), Promise()); + td_->updates_manager_->on_get_updates(std::move(ptr), Promise()); } void on_error(Status status) final { @@ -259,7 +259,7 @@ class GetDialogQuery final : public Td::ResultHandler { void send(DialogId dialog_id) { dialog_id_ = dialog_id; send_query(G()->net_query_creator().create(telegram_api::messages_getPeerDialogs( - td->messages_manager_->get_input_dialog_peers({dialog_id}, AccessRights::Read)))); + td_->messages_manager_->get_input_dialog_peers({dialog_id}, AccessRights::Read)))); } void on_result(BufferSlice packet) final { @@ -271,19 +271,20 @@ class GetDialogQuery final : public Td::ResultHandler { auto result = result_ptr.move_as_ok(); LOG(INFO) << "Receive chat: " << to_string(result); - td->contacts_manager_->on_get_users(std::move(result->users_), "GetDialogQuery"); - td->contacts_manager_->on_get_chats(std::move(result->chats_), "GetDialogQuery"); - td->messages_manager_->on_get_dialogs( - FolderId(), std::move(result->dialogs_), -1, std::move(result->messages_), - PromiseCreator::lambda([actor_id = td->messages_manager_actor_.get(), dialog_id = dialog_id_](Result<> result) { - send_closure(actor_id, &MessagesManager::on_get_dialog_query_finished, dialog_id, - result.is_error() ? result.move_as_error() : Status::OK()); - })); + td_->contacts_manager_->on_get_users(std::move(result->users_), "GetDialogQuery"); + td_->contacts_manager_->on_get_chats(std::move(result->chats_), "GetDialogQuery"); + td_->messages_manager_->on_get_dialogs(FolderId(), std::move(result->dialogs_), -1, std::move(result->messages_), + PromiseCreator::lambda([actor_id = td_->messages_manager_actor_.get(), + dialog_id = dialog_id_](Result<> result) { + send_closure(actor_id, &MessagesManager::on_get_dialog_query_finished, + dialog_id, + result.is_error() ? result.move_as_error() : Status::OK()); + })); } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetDialogQuery"); - td->messages_manager_->on_get_dialog_query_finished(dialog_id_, std::move(status)); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetDialogQuery"); + td_->messages_manager_->on_get_dialog_query_finished(dialog_id_, std::move(status)); } }; @@ -312,10 +313,10 @@ class GetDialogsQuery final : public Td::ResultHandler { auto result = result_ptr.move_as_ok(); LOG(INFO) << "Receive chats: " << to_string(result); - td->contacts_manager_->on_get_users(std::move(result->users_), "GetDialogsQuery"); - td->contacts_manager_->on_get_chats(std::move(result->chats_), "GetDialogsQuery"); - td->messages_manager_->on_get_dialogs(FolderId(), std::move(result->dialogs_), -1, std::move(result->messages_), - std::move(promise_)); + td_->contacts_manager_->on_get_users(std::move(result->users_), "GetDialogsQuery"); + td_->contacts_manager_->on_get_chats(std::move(result->chats_), "GetDialogsQuery"); + td_->messages_manager_->on_get_dialogs(FolderId(), std::move(result->dialogs_), -1, std::move(result->messages_), + std::move(promise_)); } void on_error(Status status) final { @@ -335,7 +336,7 @@ class GetPinnedDialogsActor final : public NetActorOnce { folder_id_ = folder_id; 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, + send_closure(td_->messages_manager_->sequence_dispatcher_, &MultiSequenceDispatcher::send_with_callback, std::move(query), actor_shared(this), sequence_id); return result; } @@ -349,10 +350,10 @@ class GetPinnedDialogsActor final : public NetActorOnce { auto result = result_ptr.move_as_ok(); LOG(INFO) << "Receive pinned chats in " << folder_id_ << ": " << to_string(result); - td->contacts_manager_->on_get_users(std::move(result->users_), "GetPinnedDialogsActor"); - td->contacts_manager_->on_get_chats(std::move(result->chats_), "GetPinnedDialogsActor"); - td->messages_manager_->on_get_dialogs(folder_id_, std::move(result->dialogs_), -2, std::move(result->messages_), - std::move(promise_)); + td_->contacts_manager_->on_get_users(std::move(result->users_), "GetPinnedDialogsActor"); + td_->contacts_manager_->on_get_chats(std::move(result->chats_), "GetPinnedDialogsActor"); + td_->messages_manager_->on_get_dialogs(folder_id_, std::move(result->dialogs_), -2, std::move(result->messages_), + std::move(promise_)); } void on_error(Status status) final { @@ -374,7 +375,7 @@ class GetDialogUnreadMarksQuery final : public Td::ResultHandler { auto results = result_ptr.move_as_ok(); for (auto &result : results) { - td->messages_manager_->on_update_dialog_is_marked_as_unread(DialogId(result), true); + td_->messages_manager_->on_update_dialog_is_marked_as_unread(DialogId(result), true); } G()->td_db()->get_binlog_pmc()->set("fetched_marks_as_unread", "1"); @@ -405,7 +406,7 @@ class GetDiscussionMessageQuery final : public Td::ResultHandler { expected_dialog_id_ = expected_dialog_id; expected_message_id_ = expected_message_id; CHECK(expected_dialog_id_.is_valid()); - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); CHECK(input_peer != nullptr); send_query(G()->net_query_creator().create( telegram_api::messages_getDiscussionMessage(std::move(input_peer), message_id.get_server_message_id().get()))); @@ -417,13 +418,13 @@ class GetDiscussionMessageQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - td->messages_manager_->process_discussion_message(result_ptr.move_as_ok(), dialog_id_, message_id_, - expected_dialog_id_, expected_message_id_, std::move(promise_)); + td_->messages_manager_->process_discussion_message(result_ptr.move_as_ok(), dialog_id_, message_id_, + expected_dialog_id_, expected_message_id_, std::move(promise_)); } void on_error(Status status) final { if (expected_dialog_id_ == dialog_id_) { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetDiscussionMessageQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetDiscussionMessageQuery"); } promise_.set_error(std::move(status)); } @@ -446,10 +447,10 @@ class GetMessagesQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - auto info = td->messages_manager_->get_messages_info(result_ptr.move_as_ok(), "GetMessagesQuery"); + auto info = td_->messages_manager_->get_messages_info(result_ptr.move_as_ok(), "GetMessagesQuery"); LOG_IF(ERROR, info.is_channel_messages) << "Receive channel messages in GetMessagesQuery"; - td->messages_manager_->on_get_messages(std::move(info.messages), info.is_channel_messages, false, - std::move(promise_), "GetMessagesQuery"); + td_->messages_manager_->on_get_messages(std::move(info.messages), info.is_channel_messages, false, + std::move(promise_), "GetMessagesQuery"); } void on_error(Status status) final { @@ -485,11 +486,11 @@ class GetChannelMessagesQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - auto info = td->messages_manager_->get_messages_info(result_ptr.move_as_ok(), "GetChannelMessagesQuery"); + auto info = td_->messages_manager_->get_messages_info(result_ptr.move_as_ok(), "GetChannelMessagesQuery"); LOG_IF(ERROR, !info.is_channel_messages) << "Receive ordinary messages in GetChannelMessagesQuery"; // messages with invalid big identifiers can be received as messageEmpty // bots can receive messageEmpty because of their privacy mode - if (last_new_message_id_.is_valid() && !td->auth_manager_->is_bot()) { + if (last_new_message_id_.is_valid() && !td_->auth_manager_->is_bot()) { vector empty_message_ids; for (auto &message : info.messages) { if (message->get_id() == telegram_api::messageEmpty::ID) { @@ -499,11 +500,11 @@ class GetChannelMessagesQuery final : public Td::ResultHandler { } } } - td->messages_manager_->on_get_empty_messages(DialogId(channel_id_), empty_message_ids); + td_->messages_manager_->on_get_empty_messages(DialogId(channel_id_), empty_message_ids); } - td->messages_manager_->get_channel_difference_if_needed( + td_->messages_manager_->get_channel_difference_if_needed( DialogId(channel_id_), std::move(info), - PromiseCreator::lambda([actor_id = td->messages_manager_actor_.get(), + PromiseCreator::lambda([actor_id = td_->messages_manager_actor_.get(), promise = std::move(promise_)](Result &&result) mutable { if (result.is_error()) { promise.set_error(result.move_as_error()); @@ -520,7 +521,7 @@ class GetChannelMessagesQuery final : public Td::ResultHandler { promise_.set_value(Unit()); return; } - td->contacts_manager_->on_get_channel_error(channel_id_, status, "GetChannelMessagesQuery"); + td_->contacts_manager_->on_get_channel_error(channel_id_, status, "GetChannelMessagesQuery"); promise_.set_error(std::move(status)); } }; @@ -546,11 +547,11 @@ class GetScheduledMessagesQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - auto info = td->messages_manager_->get_messages_info(result_ptr.move_as_ok(), "GetScheduledMessagesQuery"); + auto info = td_->messages_manager_->get_messages_info(result_ptr.move_as_ok(), "GetScheduledMessagesQuery"); LOG_IF(ERROR, info.is_channel_messages != (dialog_id_.get_type() == DialogType::Channel)) << "Receive wrong messages constructor in GetScheduledMessagesQuery"; - td->messages_manager_->on_get_messages(std::move(info.messages), info.is_channel_messages, true, - std::move(promise_), "GetScheduledMessagesQuery"); + td_->messages_manager_->on_get_messages(std::move(info.messages), info.is_channel_messages, true, + std::move(promise_), "GetScheduledMessagesQuery"); } void on_error(Status status) final { @@ -558,7 +559,7 @@ class GetScheduledMessagesQuery final : public Td::ResultHandler { promise_.set_value(Unit()); return; } - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetScheduledMessagesQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetScheduledMessagesQuery"); promise_.set_error(std::move(status)); } }; @@ -573,7 +574,7 @@ class UpdateDialogPinnedMessageQuery final : public Td::ResultHandler { void send(DialogId dialog_id, MessageId message_id, bool is_unpin, bool disable_notification, bool only_for_self) { dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); if (input_peer == nullptr) { LOG(INFO) << "Can't update pinned message in " << dialog_id; return on_error(Status::Error(400, "Can't update pinned message")); @@ -602,11 +603,11 @@ class UpdateDialogPinnedMessageQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for UpdateDialogPinnedMessageQuery: " << to_string(ptr); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "UpdateDialogPinnedMessageQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "UpdateDialogPinnedMessageQuery"); promise_.set_error(std::move(status)); } }; @@ -616,7 +617,7 @@ class UnpinAllMessagesQuery final : public Td::ResultHandler { DialogId dialog_id_; void send_request() { - auto input_peer = td->messages_manager_->get_input_peer(dialog_id_, AccessRights::Write); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Write); if (input_peer == nullptr) { LOG(INFO) << "Can't unpin all messages in " << dialog_id_; return on_error(Status::Error(400, "Can't unpin all messages")); @@ -648,13 +649,13 @@ class UnpinAllMessagesQuery final : public Td::ResultHandler { affected_history->pts_count_ = 0; // force receiving real updates from the server auto promise = affected_history->offset_ > 0 ? Promise() : std::move(promise_); if (dialog_id_.get_type() == DialogType::Channel) { - td->messages_manager_->add_pending_channel_update(dialog_id_, make_tl_object(), - affected_history->pts_, affected_history->pts_count_, - std::move(promise), "unpin all messages"); + td_->messages_manager_->add_pending_channel_update(dialog_id_, make_tl_object(), + affected_history->pts_, affected_history->pts_count_, + std::move(promise), "unpin all messages"); } else { - td->updates_manager_->add_pending_pts_update(make_tl_object(), affected_history->pts_, - affected_history->pts_count_, Time::now(), std::move(promise), - "unpin all messages"); + td_->updates_manager_->add_pending_pts_update(make_tl_object(), affected_history->pts_, + affected_history->pts_count_, Time::now(), std::move(promise), + "unpin all messages"); } } else if (affected_history->offset_ <= 0) { promise_.set_value(Unit()); @@ -667,7 +668,7 @@ class UnpinAllMessagesQuery final : public Td::ResultHandler { } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "UnpinAllMessagesQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "UnpinAllMessagesQuery"); promise_.set_error(std::move(status)); } }; @@ -682,7 +683,7 @@ class GetMessageReadParticipantsQuery final : public Td::ResultHandler { void send(DialogId dialog_id, MessageId message_id) { dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); CHECK(input_peer != nullptr); send_query(G()->net_query_creator().create(telegram_api::messages_getMessageReadParticipants( std::move(input_peer), message_id.get_server_message_id().get()))); @@ -698,7 +699,7 @@ class GetMessageReadParticipantsQuery final : public Td::ResultHandler { } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetMessageReadParticipantsQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetMessageReadParticipantsQuery"); promise_.set_error(std::move(status)); } }; @@ -719,7 +720,7 @@ class ExportChannelMessageLinkQuery final : public Td::ResultHandler { message_id_ = message_id; for_group_ = for_group; ignore_result_ = ignore_result; - auto input_channel = td->contacts_manager_->get_input_channel(channel_id); + auto input_channel = td_->contacts_manager_->get_input_channel(channel_id); if (input_channel == nullptr) { return on_error(Status::Error(400, "Can't access the chat")); } @@ -741,8 +742,8 @@ class ExportChannelMessageLinkQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(DEBUG) << "Receive result for ExportChannelMessageLinkQuery: " << to_string(ptr); if (!ignore_result_) { - td->messages_manager_->on_get_public_message_link({DialogId(channel_id_), message_id_}, for_group_, - std::move(ptr->link_), std::move(ptr->html_)); + td_->messages_manager_->on_get_public_message_link({DialogId(channel_id_), message_id_}, for_group_, + std::move(ptr->link_), std::move(ptr->html_)); } promise_.set_value(Unit()); @@ -750,7 +751,7 @@ class ExportChannelMessageLinkQuery final : public Td::ResultHandler { void on_error(Status status) final { if (!ignore_result_) { - td->contacts_manager_->on_get_channel_error(channel_id_, status, "ExportChannelMessageLinkQuery"); + td_->contacts_manager_->on_get_channel_error(channel_id_, status, "ExportChannelMessageLinkQuery"); } promise_.set_error(std::move(status)); } @@ -775,7 +776,7 @@ class GetDialogListActor final : public NetActorOnce { auto query = G()->net_query_creator().create( 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, + send_closure(td_->messages_manager_->sequence_dispatcher_, &MultiSequenceDispatcher::send_with_callback, std::move(query), actor_shared(this), sequence_id); } @@ -790,19 +791,19 @@ class GetDialogListActor final : public NetActorOnce { switch (ptr->get_id()) { case telegram_api::messages_dialogs::ID: { auto dialogs = move_tl_object_as(ptr); - td->contacts_manager_->on_get_users(std::move(dialogs->users_), "GetDialogListActor"); - td->contacts_manager_->on_get_chats(std::move(dialogs->chats_), "GetDialogListActor"); - td->messages_manager_->on_get_dialogs(folder_id_, std::move(dialogs->dialogs_), - narrow_cast(dialogs->dialogs_.size()), - std::move(dialogs->messages_), std::move(promise_)); + td_->contacts_manager_->on_get_users(std::move(dialogs->users_), "GetDialogListActor"); + td_->contacts_manager_->on_get_chats(std::move(dialogs->chats_), "GetDialogListActor"); + td_->messages_manager_->on_get_dialogs(folder_id_, std::move(dialogs->dialogs_), + narrow_cast(dialogs->dialogs_.size()), + std::move(dialogs->messages_), std::move(promise_)); break; } case telegram_api::messages_dialogsSlice::ID: { auto dialogs = move_tl_object_as(ptr); - td->contacts_manager_->on_get_users(std::move(dialogs->users_), "GetDialogListActor"); - td->contacts_manager_->on_get_chats(std::move(dialogs->chats_), "GetDialogListActor"); - td->messages_manager_->on_get_dialogs(folder_id_, std::move(dialogs->dialogs_), max(dialogs->count_, 0), - std::move(dialogs->messages_), std::move(promise_)); + td_->contacts_manager_->on_get_users(std::move(dialogs->users_), "GetDialogListActor"); + td_->contacts_manager_->on_get_chats(std::move(dialogs->chats_), "GetDialogListActor"); + td_->messages_manager_->on_get_dialogs(folder_id_, std::move(dialogs->dialogs_), max(dialogs->count_, 0), + std::move(dialogs->messages_), std::move(promise_)); break; } case telegram_api::messages_dialogsNotModified::ID: @@ -835,17 +836,17 @@ class SearchPublicDialogsQuery final : public Td::ResultHandler { auto dialogs = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for SearchPublicDialogsQuery: " << to_string(dialogs); - td->contacts_manager_->on_get_users(std::move(dialogs->users_), "SearchPublicDialogsQuery"); - td->contacts_manager_->on_get_chats(std::move(dialogs->chats_), "SearchPublicDialogsQuery"); - td->messages_manager_->on_get_public_dialogs_search_result(query_, std::move(dialogs->my_results_), - std::move(dialogs->results_)); + td_->contacts_manager_->on_get_users(std::move(dialogs->users_), "SearchPublicDialogsQuery"); + td_->contacts_manager_->on_get_chats(std::move(dialogs->chats_), "SearchPublicDialogsQuery"); + td_->messages_manager_->on_get_public_dialogs_search_result(query_, std::move(dialogs->my_results_), + std::move(dialogs->results_)); } void on_error(Status status) final { if (!G()->is_expected_error(status)) { LOG(ERROR) << "Receive error for SearchPublicDialogsQuery: " << status; } - td->messages_manager_->on_failed_public_dialogs_search(query_, std::move(status)); + td_->messages_manager_->on_failed_public_dialogs_search(query_, std::move(status)); } }; @@ -863,7 +864,7 @@ class GetCommonDialogsQuery final : public Td::ResultHandler { offset_chat_id_ = offset_chat_id; LOG(INFO) << "Get common dialogs with " << user_id << " from " << offset_chat_id << " with limit " << limit; - auto input_user = td->contacts_manager_->get_input_user(user_id); + auto input_user = td_->contacts_manager_->get_input_user(user_id); CHECK(input_user != nullptr); send_query(G()->net_query_creator().create( @@ -881,14 +882,14 @@ class GetCommonDialogsQuery final : public Td::ResultHandler { switch (chats_ptr->get_id()) { case telegram_api::messages_chats::ID: { auto chats = move_tl_object_as(chats_ptr); - td->messages_manager_->on_get_common_dialogs(user_id_, offset_chat_id_, std::move(chats->chats_), - narrow_cast(chats->chats_.size())); + td_->messages_manager_->on_get_common_dialogs(user_id_, offset_chat_id_, std::move(chats->chats_), + narrow_cast(chats->chats_.size())); break; } case telegram_api::messages_chatsSlice::ID: { auto chats = move_tl_object_as(chats_ptr); - td->messages_manager_->on_get_common_dialogs(user_id_, offset_chat_id_, std::move(chats->chats_), - chats->count_); + td_->messages_manager_->on_get_common_dialogs(user_id_, offset_chat_id_, std::move(chats->chats_), + chats->count_); break; } default: @@ -933,20 +934,20 @@ class GetBlockedDialogsQuery final : public Td::ResultHandler { case telegram_api::contacts_blocked::ID: { auto blocked_peers = move_tl_object_as(ptr); - td->contacts_manager_->on_get_users(std::move(blocked_peers->users_), "GetBlockedDialogsQuery"); - td->contacts_manager_->on_get_chats(std::move(blocked_peers->chats_), "GetBlockedDialogsQuery"); - td->messages_manager_->on_get_blocked_dialogs(offset_, limit_, - narrow_cast(blocked_peers->blocked_.size()), - std::move(blocked_peers->blocked_), std::move(promise_)); + td_->contacts_manager_->on_get_users(std::move(blocked_peers->users_), "GetBlockedDialogsQuery"); + td_->contacts_manager_->on_get_chats(std::move(blocked_peers->chats_), "GetBlockedDialogsQuery"); + td_->messages_manager_->on_get_blocked_dialogs(offset_, limit_, + narrow_cast(blocked_peers->blocked_.size()), + std::move(blocked_peers->blocked_), std::move(promise_)); break; } case telegram_api::contacts_blockedSlice::ID: { auto blocked_peers = move_tl_object_as(ptr); - td->contacts_manager_->on_get_users(std::move(blocked_peers->users_), "GetBlockedDialogsQuery"); - td->contacts_manager_->on_get_chats(std::move(blocked_peers->chats_), "GetBlockedDialogsQuery"); - td->messages_manager_->on_get_blocked_dialogs(offset_, limit_, blocked_peers->count_, - std::move(blocked_peers->blocked_), std::move(promise_)); + td_->contacts_manager_->on_get_users(std::move(blocked_peers->users_), "GetBlockedDialogsQuery"); + td_->contacts_manager_->on_get_chats(std::move(blocked_peers->chats_), "GetBlockedDialogsQuery"); + td_->messages_manager_->on_get_blocked_dialogs(offset_, limit_, blocked_peers->count_, + std::move(blocked_peers->blocked_), std::move(promise_)); break; } default: @@ -980,12 +981,12 @@ class CreateChatQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for CreateChatQuery: " << to_string(ptr); - td->messages_manager_->on_create_new_dialog_success(random_id_, std::move(ptr), DialogType::Chat, - std::move(promise_)); + td_->messages_manager_->on_create_new_dialog_success(random_id_, std::move(ptr), DialogType::Chat, + std::move(promise_)); } void on_error(Status status) final { - td->messages_manager_->on_create_new_dialog_fail(random_id_, std::move(status), std::move(promise_)); + td_->messages_manager_->on_create_new_dialog_fail(random_id_, std::move(status), std::move(promise_)); } }; @@ -1026,12 +1027,12 @@ class CreateChannelQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for CreateChannelQuery: " << to_string(ptr); - td->messages_manager_->on_create_new_dialog_success(random_id_, std::move(ptr), DialogType::Channel, - std::move(promise_)); + td_->messages_manager_->on_create_new_dialog_success(random_id_, std::move(ptr), DialogType::Channel, + std::move(promise_)); } void on_error(Status status) final { - td->messages_manager_->on_create_new_dialog_fail(random_id_, std::move(status), std::move(promise_)); + td_->messages_manager_->on_create_new_dialog_fail(random_id_, std::move(status), std::move(promise_)); } }; @@ -1082,7 +1083,7 @@ class CheckHistoryImportPeerQuery final : public Td::ResultHandler { void send(DialogId dialog_id) { dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); CHECK(input_peer != nullptr); send_query(G()->net_query_creator().create(telegram_api::messages_checkHistoryImportPeer(std::move(input_peer)))); } @@ -1099,7 +1100,7 @@ class CheckHistoryImportPeerQuery final : public Td::ResultHandler { } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "CheckHistoryImportPeerQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "CheckHistoryImportPeerQuery"); promise_.set_error(std::move(status)); } }; @@ -1121,7 +1122,7 @@ class InitHistoryImportQuery final : public Td::ResultHandler { dialog_id_ = dialog_id; attached_file_ids_ = std::move(attached_file_ids); - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); CHECK(input_peer != nullptr); send_query(G()->net_query_creator().create(telegram_api::messages_initHistoryImport( std::move(input_peer), std::move(input_file), narrow_cast(attached_file_ids_.size())))); @@ -1133,11 +1134,11 @@ class InitHistoryImportQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - td->file_manager_->delete_partial_remote_location(file_id_); + td_->file_manager_->delete_partial_remote_location(file_id_); auto ptr = result_ptr.move_as_ok(); - td->messages_manager_->start_import_messages(dialog_id_, ptr->id_, std::move(attached_file_ids_), - std::move(promise_)); + td_->messages_manager_->start_import_messages(dialog_id_, ptr->id_, std::move(attached_file_ids_), + std::move(promise_)); } void on_error(Status status) final { @@ -1148,9 +1149,9 @@ class InitHistoryImportQuery final : public Td::ResultHandler { // TODO support FILE_PART_*_MISSING } - td->file_manager_->delete_partial_remote_location(file_id_); + td_->file_manager_->delete_partial_remote_location(file_id_); - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "InitHistoryImportQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "InitHistoryImportQuery"); promise_.set_error(std::move(status)); } }; @@ -1172,7 +1173,7 @@ class UploadImportedMediaQuery final : public Td::ResultHandler { import_id_ = import_id; file_id_ = file_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); if (input_peer == nullptr) { return on_error(Status::Error(400, "Can't access the chat")); } @@ -1187,7 +1188,7 @@ class UploadImportedMediaQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - td->file_manager_->delete_partial_remote_location(file_id_); + td_->file_manager_->delete_partial_remote_location(file_id_); // ignore response @@ -1202,8 +1203,8 @@ class UploadImportedMediaQuery final : public Td::ResultHandler { // TODO support FILE_PART_*_MISSING } - td->file_manager_->delete_partial_remote_location(file_id_); - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "UploadImportedMediaQuery"); + td_->file_manager_->delete_partial_remote_location(file_id_); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "UploadImportedMediaQuery"); promise_.set_error(std::move(status)); } }; @@ -1219,7 +1220,7 @@ class StartImportHistoryQuery final : public Td::ResultHandler { void send(DialogId dialog_id, int64 import_id) { dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); CHECK(input_peer != nullptr); send_query( @@ -1239,7 +1240,7 @@ class StartImportHistoryQuery final : public Td::ResultHandler { } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "StartImportHistoryQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "StartImportHistoryQuery"); promise_.set_error(std::move(status)); } }; @@ -1269,7 +1270,7 @@ class EditDialogPhotoQuery final : public Td::ResultHandler { break; case DialogType::Channel: { auto channel_id = dialog_id.get_channel_id(); - auto input_channel = td->contacts_manager_->get_input_channel(channel_id); + auto input_channel = td_->contacts_manager_->get_input_channel(channel_id); CHECK(input_channel != nullptr); send_query(G()->net_query_creator().create( telegram_api::channels_editPhoto(std::move(input_channel), std::move(input_chat_photo)))); @@ -1293,21 +1294,21 @@ class EditDialogPhotoQuery final : public Td::ResultHandler { LOG(INFO) << "Receive result for EditDialogPhotoQuery: " << to_string(ptr); if (file_id_.is_valid() && was_uploaded_) { - td->file_manager_->delete_partial_remote_location(file_id_); + td_->file_manager_->delete_partial_remote_location(file_id_); } - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { if (file_id_.is_valid() && was_uploaded_) { - td->file_manager_->delete_partial_remote_location(file_id_); + td_->file_manager_->delete_partial_remote_location(file_id_); } - if (!td->auth_manager_->is_bot() && FileReferenceManager::is_file_reference_error(status)) { + if (!td_->auth_manager_->is_bot() && FileReferenceManager::is_file_reference_error(status)) { if (file_id_.is_valid() && !was_uploaded_) { VLOG(file_references) << "Receive " << status << " for " << file_id_; - td->file_manager_->delete_file_reference(file_id_, file_reference_); - td->messages_manager_->upload_dialog_photo(dialog_id_, file_id_, false, 0.0, false, std::move(promise_), {-1}); + td_->file_manager_->delete_file_reference(file_id_, file_reference_); + td_->messages_manager_->upload_dialog_photo(dialog_id_, file_id_, false, 0.0, false, std::move(promise_), {-1}); return; } else { LOG(ERROR) << "Receive file reference error, but file_id = " << file_id_ @@ -1316,14 +1317,14 @@ class EditDialogPhotoQuery final : public Td::ResultHandler { } if (status.message() == "CHAT_NOT_MODIFIED") { - if (!td->auth_manager_->is_bot()) { + if (!td_->auth_manager_->is_bot()) { promise_.set_value(Unit()); return; } } else { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "EditDialogPhotoQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "EditDialogPhotoQuery"); } - td->updates_manager_->get_difference("EditDialogPhotoQuery"); + td_->updates_manager_->get_difference("EditDialogPhotoQuery"); promise_.set_error(std::move(status)); } }; @@ -1345,7 +1346,7 @@ class EditDialogTitleQuery final : public Td::ResultHandler { break; case DialogType::Channel: { auto channel_id = dialog_id.get_channel_id(); - auto input_channel = td->contacts_manager_->get_input_channel(channel_id); + auto input_channel = td_->contacts_manager_->get_input_channel(channel_id); CHECK(input_channel != nullptr); send_query(G()->net_query_creator().create(telegram_api::channels_editTitle(std::move(input_channel), title))); break; @@ -1366,19 +1367,19 @@ class EditDialogTitleQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for EditDialogTitleQuery: " << to_string(ptr); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { - td->updates_manager_->get_difference("EditDialogTitleQuery"); + td_->updates_manager_->get_difference("EditDialogTitleQuery"); if (status.message() == "CHAT_NOT_MODIFIED") { - if (!td->auth_manager_->is_bot()) { + if (!td_->auth_manager_->is_bot()) { promise_.set_value(Unit()); return; } } else { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "EditDialogTitleQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "EditDialogTitleQuery"); } promise_.set_error(std::move(status)); } @@ -1394,7 +1395,7 @@ class SetChatThemeQuery final : public Td::ResultHandler { void send(DialogId dialog_id, const string &theme_name) { dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); CHECK(input_peer != nullptr); send_query(G()->net_query_creator().create(telegram_api::messages_setChatTheme(std::move(input_peer), theme_name))); } @@ -1407,17 +1408,17 @@ class SetChatThemeQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for SetChatThemeQuery: " << to_string(ptr); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { if (status.message() == "CHAT_NOT_MODIFIED") { - if (!td->auth_manager_->is_bot()) { + if (!td_->auth_manager_->is_bot()) { promise_.set_value(Unit()); return; } } else { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "SetChatThemeQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "SetChatThemeQuery"); } promise_.set_error(std::move(status)); } @@ -1434,7 +1435,7 @@ class SetHistoryTtlQuery final : public Td::ResultHandler { void send(DialogId dialog_id, int32 period) { dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); CHECK(input_peer != nullptr); send_query(G()->net_query_creator().create(telegram_api::messages_setHistoryTTL(std::move(input_peer), period))); @@ -1448,17 +1449,17 @@ class SetHistoryTtlQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for SetHistoryTtlQuery: " << to_string(ptr); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { if (status.message() == "CHAT_NOT_MODIFIED") { - if (!td->auth_manager_->is_bot()) { + if (!td_->auth_manager_->is_bot()) { promise_.set_value(Unit()); return; } } else { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "SetHistoryTtlQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "SetHistoryTtlQuery"); } promise_.set_error(std::move(status)); } @@ -1474,7 +1475,7 @@ class EditChatDefaultBannedRightsQuery final : public Td::ResultHandler { void send(DialogId dialog_id, RestrictedRights permissions) { dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); CHECK(input_peer != nullptr); send_query(G()->net_query_creator().create(telegram_api::messages_editChatDefaultBannedRights( std::move(input_peer), permissions.get_chat_banned_rights()))); @@ -1488,17 +1489,17 @@ class EditChatDefaultBannedRightsQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for EditChatDefaultBannedRightsQuery: " << to_string(ptr); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { if (status.message() == "CHAT_NOT_MODIFIED") { - if (!td->auth_manager_->is_bot()) { + if (!td_->auth_manager_->is_bot()) { promise_.set_value(Unit()); return; } } else { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "EditChatDefaultBannedRightsQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "EditChatDefaultBannedRightsQuery"); } promise_.set_error(std::move(status)); } @@ -1516,7 +1517,7 @@ class SaveDraftMessageQuery final : public Td::ResultHandler { LOG(INFO) << "Save draft in " << dialog_id; dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); if (input_peer == nullptr) { LOG(INFO) << "Can't update draft message because have no write access to " << dialog_id; return on_error(Status::Error(400, "Can't save draft message")); @@ -1542,7 +1543,7 @@ class SaveDraftMessageQuery final : public Td::ResultHandler { draft_message == nullptr ? "" : draft_message->input_message_text.text.text, draft_message == nullptr ? vector>() - : get_input_message_entities(td->contacts_manager_.get(), draft_message->input_message_text.text.entities, + : get_input_message_entities(td_->contacts_manager_.get(), draft_message->input_message_text.text.entities, "SaveDraftMessageQuery")))); } @@ -1561,7 +1562,7 @@ class SaveDraftMessageQuery final : public Td::ResultHandler { } void on_error(Status status) final { - if (!td->messages_manager_->on_get_dialog_error(dialog_id_, status, "SaveDraftMessageQuery")) { + if (!td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "SaveDraftMessageQuery")) { LOG(ERROR) << "Receive error for SaveDraftMessageQuery: " << status; } promise_.set_error(std::move(status)); @@ -1616,7 +1617,7 @@ class ToggleDialogPinQuery final : public Td::ResultHandler { dialog_id_ = dialog_id; is_pinned_ = is_pinned; - auto input_peer = td->messages_manager_->get_input_dialog_peer(dialog_id, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_dialog_peer(dialog_id, AccessRights::Read); if (input_peer == nullptr) { return on_error(Status::Error(400, "Can't access the chat")); } @@ -1644,11 +1645,11 @@ class ToggleDialogPinQuery final : public Td::ResultHandler { } void on_error(Status status) final { - if (!td->messages_manager_->on_get_dialog_error(dialog_id_, status, "ToggleDialogPinQuery")) { + if (!td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "ToggleDialogPinQuery")) { LOG(ERROR) << "Receive error for ToggleDialogPinQuery: " << status; } - td->messages_manager_->on_update_pinned_dialogs(FolderId::main()); - td->messages_manager_->on_update_pinned_dialogs(FolderId::archive()); + td_->messages_manager_->on_update_pinned_dialogs(FolderId::main()); + td_->messages_manager_->on_update_pinned_dialogs(FolderId::archive()); promise_.set_error(std::move(status)); } }; @@ -1666,7 +1667,7 @@ class ReorderPinnedDialogsQuery final : public Td::ResultHandler { int32 flags = telegram_api::messages_reorderPinnedDialogs::FORCE_MASK; 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(BufferSlice packet) final { @@ -1688,7 +1689,7 @@ class ReorderPinnedDialogsQuery final : public Td::ResultHandler { if (!G()->is_expected_error(status)) { LOG(ERROR) << "Receive error for ReorderPinnedDialogsQuery: " << status; } - td->messages_manager_->on_update_pinned_dialogs(folder_id_); + td_->messages_manager_->on_update_pinned_dialogs(folder_id_); promise_.set_error(std::move(status)); } }; @@ -1706,7 +1707,7 @@ class ToggleDialogUnreadMarkQuery final : public Td::ResultHandler { dialog_id_ = dialog_id; is_marked_as_unread_ = is_marked_as_unread; - auto input_peer = td->messages_manager_->get_input_dialog_peer(dialog_id, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_dialog_peer(dialog_id, AccessRights::Read); if (input_peer == nullptr) { return on_error(Status::Error(400, "Can't access the chat")); } @@ -1734,11 +1735,11 @@ class ToggleDialogUnreadMarkQuery final : public Td::ResultHandler { } void on_error(Status status) final { - if (!td->messages_manager_->on_get_dialog_error(dialog_id_, status, "ToggleDialogUnreadMarkQuery")) { + if (!td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "ToggleDialogUnreadMarkQuery")) { LOG(ERROR) << "Receive error for ToggleDialogUnreadMarkQuery: " << status; } if (!G()->close_flag()) { - td->messages_manager_->on_update_dialog_is_marked_as_unread(dialog_id_, !is_marked_as_unread_); + td_->messages_manager_->on_update_dialog_is_marked_as_unread(dialog_id_, !is_marked_as_unread_); } promise_.set_error(std::move(status)); } @@ -1757,11 +1758,11 @@ class ToggleDialogIsBlockedActor final : public NetActorOnce { dialog_id_ = dialog_id; is_blocked_ = is_blocked; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Know); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Know); CHECK(input_peer != nullptr && input_peer->get_id() != telegram_api::inputPeerEmpty::ID); auto query = is_blocked ? G()->net_query_creator().create(telegram_api::contacts_block(std::move(input_peer))) : G()->net_query_creator().create(telegram_api::contacts_unblock(std::move(input_peer))); - send_closure(td->messages_manager_->sequence_dispatcher_, &MultiSequenceDispatcher::send_with_callback, + send_closure(td_->messages_manager_->sequence_dispatcher_, &MultiSequenceDispatcher::send_with_callback, std::move(query), actor_shared(this), sequence_dispatcher_id); } @@ -1780,13 +1781,13 @@ class ToggleDialogIsBlockedActor final : public NetActorOnce { } void on_error(Status status) final { - if (!td->messages_manager_->on_get_dialog_error(dialog_id_, status, "ToggleDialogIsBlockedActor")) { + if (!td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "ToggleDialogIsBlockedActor")) { LOG(ERROR) << "Receive error for ToggleDialogIsBlockedActor: " << status; } if (!G()->close_flag()) { - td->messages_manager_->on_update_dialog_is_blocked(dialog_id_, !is_blocked_); - td->messages_manager_->get_dialog_info_full(dialog_id_, Auto(), "ToggleDialogIsBlockedActor"); - td->messages_manager_->reget_dialog_action_bar(dialog_id_, "ToggleDialogIsBlockedActor"); + td_->messages_manager_->on_update_dialog_is_blocked(dialog_id_, !is_blocked_); + td_->messages_manager_->get_dialog_info_full(dialog_id_, Auto(), "ToggleDialogIsBlockedActor"); + td_->messages_manager_->reget_dialog_action_bar(dialog_id_, "ToggleDialogIsBlockedActor"); } promise_.set_error(std::move(status)); } @@ -1801,7 +1802,7 @@ class GetMessagesViewsQuery final : public Td::ResultHandler { dialog_id_ = dialog_id; message_ids_ = std::move(message_ids); - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); if (input_peer == nullptr) { return on_error(Status::Error(400, "Can't access the chat")); } @@ -1823,8 +1824,8 @@ class GetMessagesViewsQuery final : public Td::ResultHandler { if (message_ids_.size() != interaction_infos.size()) { return on_error(Status::Error(500, "Wrong number of message views returned")); } - td->contacts_manager_->on_get_users(std::move(result->users_), "GetMessagesViewsQuery"); - td->contacts_manager_->on_get_chats(std::move(result->chats_), "GetMessagesViewsQuery"); + td_->contacts_manager_->on_get_users(std::move(result->users_), "GetMessagesViewsQuery"); + td_->contacts_manager_->on_get_chats(std::move(result->chats_), "GetMessagesViewsQuery"); for (size_t i = 0; i < message_ids_.size(); i++) { FullMessageId full_message_id{dialog_id_, message_ids_[i]}; @@ -1832,13 +1833,13 @@ class GetMessagesViewsQuery final : public Td::ResultHandler { auto flags = info->flags_; auto view_count = (flags & telegram_api::messageViews::VIEWS_MASK) != 0 ? info->views_ : 0; auto forward_count = (flags & telegram_api::messageViews::FORWARDS_MASK) != 0 ? info->forwards_ : 0; - td->messages_manager_->on_update_message_interaction_info(full_message_id, view_count, forward_count, true, - std::move(info->replies_)); + td_->messages_manager_->on_update_message_interaction_info(full_message_id, view_count, forward_count, true, + std::move(info->replies_)); } } void on_error(Status status) final { - if (!td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetMessagesViewsQuery")) { + if (!td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetMessagesViewsQuery")) { LOG(ERROR) << "Receive error for GetMessagesViewsQuery: " << status; } } @@ -1868,9 +1869,9 @@ class ReadMessagesContentsQuery final : public Td::ResultHandler { CHECK(affected_messages->get_id() == telegram_api::messages_affectedMessages::ID); if (affected_messages->pts_count_ > 0) { - td->updates_manager_->add_pending_pts_update(make_tl_object(), affected_messages->pts_, - affected_messages->pts_count_, Time::now(), Promise(), - "read messages content query"); + td_->updates_manager_->add_pending_pts_update(make_tl_object(), affected_messages->pts_, + affected_messages->pts_count_, Time::now(), Promise(), + "read messages content query"); } promise_.set_value(Unit()); @@ -1895,7 +1896,7 @@ class ReadChannelMessagesContentsQuery final : public Td::ResultHandler { void send(ChannelId channel_id, vector &&message_ids) { channel_id_ = channel_id; - auto input_channel = td->contacts_manager_->get_input_channel(channel_id); + auto input_channel = td_->contacts_manager_->get_input_channel(channel_id); if (input_channel == nullptr) { LOG(ERROR) << "Have no input channel for " << channel_id; return on_error(Status::Error(500, "Can't read channel message contents")); @@ -1921,7 +1922,7 @@ class ReadChannelMessagesContentsQuery final : public Td::ResultHandler { } void on_error(Status status) final { - if (!td->contacts_manager_->on_get_channel_error(channel_id_, status, "ReadChannelMessagesContentsQuery")) { + if (!td_->contacts_manager_->on_get_channel_error(channel_id_, status, "ReadChannelMessagesContentsQuery")) { LOG(ERROR) << "Receive error for read messages contents in " << channel_id_ << ": " << status; } promise_.set_error(std::move(status)); @@ -1939,7 +1940,7 @@ class GetDialogMessageByDateQuery final : public Td::ResultHandler { } void send(DialogId dialog_id, int32 date, int64 random_id) { - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); if (input_peer == nullptr) { return promise_.set_error(Status::Error(400, "Can't access the chat")); } @@ -1958,10 +1959,10 @@ class GetDialogMessageByDateQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - auto info = td->messages_manager_->get_messages_info(result_ptr.move_as_ok(), "GetDialogMessageByDateQuery"); - td->messages_manager_->get_channel_difference_if_needed( + auto info = td_->messages_manager_->get_messages_info(result_ptr.move_as_ok(), "GetDialogMessageByDateQuery"); + td_->messages_manager_->get_channel_difference_if_needed( dialog_id_, std::move(info), - PromiseCreator::lambda([actor_id = td->messages_manager_actor_.get(), dialog_id = dialog_id_, date = date_, + PromiseCreator::lambda([actor_id = td_->messages_manager_actor_.get(), dialog_id = dialog_id_, date = date_, random_id = random_id_, promise = std::move(promise_)](Result &&result) mutable { if (result.is_error()) { @@ -1975,11 +1976,11 @@ class GetDialogMessageByDateQuery final : public Td::ResultHandler { } void on_error(Status status) final { - if (!td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetDialogMessageByDateQuery")) { + if (!td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetDialogMessageByDateQuery")) { LOG(ERROR) << "Receive error for GetDialogMessageByDateQuery in " << dialog_id_ << ": " << status; } promise_.set_error(std::move(status)); - td->messages_manager_->on_get_dialog_message_by_date_fail(random_id_); + td_->messages_manager_->on_get_dialog_message_by_date_fail(random_id_); } }; @@ -1998,7 +1999,7 @@ class GetHistoryQuery final : public Td::ResultHandler { void send(DialogId dialog_id, MessageId from_message_id, MessageId old_last_new_message_id, int32 offset, int32 limit) { - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); if (input_peer == nullptr) { return promise_.set_error(Status::Error(400, "Can't access the chat")); } @@ -2015,7 +2016,7 @@ class GetHistoryQuery final : public Td::ResultHandler { } void send_get_from_the_end(DialogId dialog_id, MessageId old_last_new_message_id, int32 limit) { - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); if (input_peer == nullptr) { return promise_.set_error(Status::Error(400, "Can't access the chat")); } @@ -2035,10 +2036,10 @@ class GetHistoryQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - auto info = td->messages_manager_->get_messages_info(result_ptr.move_as_ok(), "GetHistoryQuery"); - td->messages_manager_->get_channel_difference_if_needed( + auto info = td_->messages_manager_->get_messages_info(result_ptr.move_as_ok(), "GetHistoryQuery"); + td_->messages_manager_->get_channel_difference_if_needed( dialog_id_, std::move(info), - PromiseCreator::lambda([actor_id = td->messages_manager_actor_.get(), dialog_id = dialog_id_, + PromiseCreator::lambda([actor_id = td_->messages_manager_actor_.get(), dialog_id = dialog_id_, from_message_id = from_message_id_, old_last_new_message_id = old_last_new_message_id_, offset = offset_, limit = limit_, from_the_end = from_the_end_, promise = std::move(promise_)](Result &&result) mutable { @@ -2055,7 +2056,7 @@ class GetHistoryQuery final : public Td::ResultHandler { } void on_error(Status status) final { - if (!td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetHistoryQuery")) { + if (!td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetHistoryQuery")) { LOG(ERROR) << "Receive error for GetHistoryQuery in " << dialog_id_ << ": " << status; } promise_.set_error(std::move(status)); @@ -2072,7 +2073,7 @@ class ReadHistoryQuery final : public Td::ResultHandler { void send(DialogId dialog_id, MessageId max_message_id) { dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); CHECK(input_peer != nullptr); send_query(G()->net_query_creator().create( telegram_api::messages_readHistory(std::move(input_peer), max_message_id.get_server_message_id().get()))); @@ -2089,16 +2090,16 @@ class ReadHistoryQuery final : public Td::ResultHandler { LOG(INFO) << "Receive result for ReadHistoryQuery: " << to_string(affected_messages); if (affected_messages->pts_count_ > 0) { - td->updates_manager_->add_pending_pts_update(make_tl_object(), affected_messages->pts_, - affected_messages->pts_count_, Time::now(), Promise(), - "read history query"); + td_->updates_manager_->add_pending_pts_update(make_tl_object(), affected_messages->pts_, + affected_messages->pts_count_, Time::now(), Promise(), + "read history query"); } promise_.set_value(Unit()); } void on_error(Status status) final { - if (!td->messages_manager_->on_get_dialog_error(dialog_id_, status, "ReadHistoryQuery")) { + if (!td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "ReadHistoryQuery")) { LOG(ERROR) << "Receive error for ReadHistoryQuery: " << status; } promise_.set_error(std::move(status)); @@ -2115,7 +2116,7 @@ class ReadChannelHistoryQuery final : public Td::ResultHandler { void send(ChannelId channel_id, MessageId max_message_id) { channel_id_ = channel_id; - auto input_channel = td->contacts_manager_->get_input_channel(channel_id); + auto input_channel = td_->contacts_manager_->get_input_channel(channel_id); CHECK(input_channel != nullptr); send_query(G()->net_query_creator().create( @@ -2132,7 +2133,7 @@ class ReadChannelHistoryQuery final : public Td::ResultHandler { } void on_error(Status status) final { - if (!td->contacts_manager_->on_get_channel_error(channel_id_, status, "ReadChannelHistoryQuery")) { + if (!td_->contacts_manager_->on_get_channel_error(channel_id_, status, "ReadChannelHistoryQuery")) { LOG(ERROR) << "Receive error for ReadChannelHistoryQuery: " << status; } promise_.set_error(std::move(status)); @@ -2149,7 +2150,7 @@ class ReadDiscussionQuery final : public Td::ResultHandler { void send(DialogId dialog_id, MessageId top_thread_message_id, MessageId max_message_id) { dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); CHECK(input_peer != nullptr); send_query(G()->net_query_creator().create(telegram_api::messages_readDiscussion( std::move(input_peer), top_thread_message_id.get_server_message_id().get(), @@ -2166,7 +2167,7 @@ class ReadDiscussionQuery final : public Td::ResultHandler { } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "ReadDiscussionQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "ReadDiscussionQuery"); promise_.set_error(std::move(status)); } }; @@ -2183,7 +2184,7 @@ class GetSearchResultCalendarQuery final : public Td::ResultHandler { } void send(DialogId dialog_id, MessageId from_message_id, MessageSearchFilter filter, int64 random_id) { - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); CHECK(input_peer != nullptr); dialog_id_ = dialog_id; @@ -2203,17 +2204,17 @@ class GetSearchResultCalendarQuery final : public Td::ResultHandler { auto result = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for GetSearchResultCalendarQuery: " << to_string(result); - td->contacts_manager_->on_get_users(std::move(result->users_), "GetSearchResultCalendarQuery"); - td->contacts_manager_->on_get_chats(std::move(result->chats_), "GetSearchResultCalendarQuery"); + td_->contacts_manager_->on_get_users(std::move(result->users_), "GetSearchResultCalendarQuery"); + td_->contacts_manager_->on_get_chats(std::move(result->chats_), "GetSearchResultCalendarQuery"); MessagesManager::MessagesInfo info; info.messages = std::move(result->messages_); info.total_count = result->count_; info.is_channel_messages = dialog_id_.get_type() == DialogType::Channel; - td->messages_manager_->get_channel_difference_if_needed( + td_->messages_manager_->get_channel_difference_if_needed( dialog_id_, std::move(info), - PromiseCreator::lambda([actor_id = td->messages_manager_actor_.get(), dialog_id = dialog_id_, + PromiseCreator::lambda([actor_id = td_->messages_manager_actor_.get(), dialog_id = dialog_id_, from_message_id = from_message_id_, filter = filter_, random_id = random_id_, periods = std::move(result->periods_), promise = std::move(promise_)](Result &&result) mutable { @@ -2229,8 +2230,8 @@ class GetSearchResultCalendarQuery final : public Td::ResultHandler { } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "SearchMessagesQuery"); - td->messages_manager_->on_failed_get_message_search_result_calendar(dialog_id_, random_id_); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "SearchMessagesQuery"); + td_->messages_manager_->on_failed_get_message_search_result_calendar(dialog_id_, random_id_); promise_.set_error(std::move(status)); } }; @@ -2254,7 +2255,7 @@ class SearchMessagesQuery final : public Td::ResultHandler { void send(DialogId dialog_id, const string &query, DialogId sender_dialog_id, MessageId from_message_id, int32 offset, int32 limit, MessageSearchFilter filter, MessageId top_thread_message_id, int64 random_id) { - auto input_peer = dialog_id.is_valid() ? td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read) + auto input_peer = dialog_id.is_valid() ? td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read) : make_tl_object(); CHECK(input_peer != nullptr); @@ -2275,7 +2276,7 @@ class SearchMessagesQuery final : public Td::ResultHandler { } else if (top_thread_message_id.is_valid() && query.empty() && !sender_dialog_id.is_valid() && filter == MessageSearchFilter::Empty) { handle_errors_ = dialog_id.get_type() != DialogType::Channel || - td->contacts_manager_->get_channel_type(dialog_id.get_channel_id()) != + td_->contacts_manager_->get_channel_type(dialog_id.get_channel_id()) != ContactsManager::ChannelType::Broadcast; send_query(G()->net_query_creator().create(telegram_api::messages_getReplies( std::move(input_peer), top_thread_message_id.get_server_message_id().get(), @@ -2285,7 +2286,7 @@ class SearchMessagesQuery final : public Td::ResultHandler { tl_object_ptr sender_input_peer; if (sender_dialog_id.is_valid()) { flags |= telegram_api::messages_search::FROM_ID_MASK; - sender_input_peer = td->messages_manager_->get_input_peer(sender_dialog_id, AccessRights::Read); + sender_input_peer = td_->messages_manager_->get_input_peer(sender_dialog_id, AccessRights::Read); CHECK(sender_input_peer != nullptr); } if (top_thread_message_id.is_valid()) { @@ -2312,10 +2313,10 @@ class SearchMessagesQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - auto info = td->messages_manager_->get_messages_info(result_ptr.move_as_ok(), "SearchMessagesQuery"); - td->messages_manager_->get_channel_difference_if_needed( + auto info = td_->messages_manager_->get_messages_info(result_ptr.move_as_ok(), "SearchMessagesQuery"); + td_->messages_manager_->get_channel_difference_if_needed( dialog_id_, std::move(info), - PromiseCreator::lambda([actor_id = td->messages_manager_actor_.get(), dialog_id = dialog_id_, + PromiseCreator::lambda([actor_id = td_->messages_manager_actor_.get(), dialog_id = dialog_id_, query = std::move(query_), sender_dialog_id = sender_dialog_id_, from_message_id = from_message_id_, offset = offset_, limit = limit_, filter = filter_, top_thread_message_id = top_thread_message_id_, random_id = random_id_, @@ -2333,9 +2334,9 @@ class SearchMessagesQuery final : public Td::ResultHandler { void on_error(Status status) final { if (handle_errors_) { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "SearchMessagesQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "SearchMessagesQuery"); } - td->messages_manager_->on_failed_dialog_messages_search(dialog_id_, random_id_); + td_->messages_manager_->on_failed_dialog_messages_search(dialog_id_, random_id_); promise_.set_error(std::move(status)); } }; @@ -2351,7 +2352,7 @@ class GetSearchResultPositionsQuery final : public Td::ResultHandler { } void send(DialogId dialog_id, MessageSearchFilter filter, MessageId from_message_id, int32 limit) { - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); if (input_peer == nullptr) { return promise_.set_error(Status::Error(400, "Can't access the chat")); } @@ -2369,12 +2370,12 @@ class GetSearchResultPositionsQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - td->messages_manager_->on_get_dialog_sparse_message_positions(dialog_id_, filter_, result_ptr.move_as_ok(), - std::move(promise_)); + td_->messages_manager_->on_get_dialog_sparse_message_positions(dialog_id_, filter_, result_ptr.move_as_ok(), + std::move(promise_)); } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetSearchResultPositionsQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetSearchResultPositionsQuery"); promise_.set_error(std::move(status)); } }; @@ -2389,7 +2390,7 @@ class GetSearchCountersQuery final : public Td::ResultHandler { } void send(DialogId dialog_id, MessageSearchFilter filter) { - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); if (input_peer == nullptr) { return promise_.set_error(Status::Error(400, "Can't access the chat")); } @@ -2419,11 +2420,11 @@ class GetSearchCountersQuery final : public Td::ResultHandler { return on_error(Status::Error(500, "Receive wrong response")); } - td->messages_manager_->on_get_dialog_message_count(dialog_id_, filter_, result[0]->count_, std::move(promise_)); + td_->messages_manager_->on_get_dialog_message_count(dialog_id_, filter_, result[0]->count_, std::move(promise_)); } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetSearchCountersQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetSearchCountersQuery"); promise_.set_error(std::move(status)); } }; @@ -2475,10 +2476,10 @@ class SearchMessagesGlobalQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - auto info = td->messages_manager_->get_messages_info(result_ptr.move_as_ok(), "SearchMessagesGlobalQuery"); - td->messages_manager_->get_channel_differences_if_needed( + auto info = td_->messages_manager_->get_messages_info(result_ptr.move_as_ok(), "SearchMessagesGlobalQuery"); + td_->messages_manager_->get_channel_differences_if_needed( std::move(info), - PromiseCreator::lambda([actor_id = td->messages_manager_actor_.get(), query = std::move(query_), + PromiseCreator::lambda([actor_id = td_->messages_manager_actor_.get(), query = std::move(query_), offset_date = offset_date_, offset_dialog_id = offset_dialog_id_, offset_message_id = offset_message_id_, limit = limit_, filter = std::move(filter_), min_date = min_date_, max_date = max_date_, random_id = random_id_, @@ -2495,7 +2496,7 @@ class SearchMessagesGlobalQuery final : public Td::ResultHandler { } void on_error(Status status) final { - td->messages_manager_->on_failed_messages_search(random_id_); + td_->messages_manager_->on_failed_messages_search(random_id_); promise_.set_error(std::move(status)); } }; @@ -2510,7 +2511,7 @@ class GetAllScheduledMessagesQuery final : public Td::ResultHandler { } void send(DialogId dialog_id, int64 hash, uint32 generation) { - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); CHECK(input_peer != nullptr); dialog_id_ = dialog_id; @@ -2527,17 +2528,18 @@ class GetAllScheduledMessagesQuery final : public Td::ResultHandler { } if (result_ptr.ok()->get_id() == telegram_api::messages_messagesNotModified::ID) { - td->messages_manager_->on_get_scheduled_server_messages(dialog_id_, generation_, Auto(), true); + td_->messages_manager_->on_get_scheduled_server_messages(dialog_id_, generation_, Auto(), true); } else { - auto info = td->messages_manager_->get_messages_info(result_ptr.move_as_ok(), "GetAllScheduledMessagesQuery"); - td->messages_manager_->on_get_scheduled_server_messages(dialog_id_, generation_, std::move(info.messages), false); + auto info = td_->messages_manager_->get_messages_info(result_ptr.move_as_ok(), "GetAllScheduledMessagesQuery"); + td_->messages_manager_->on_get_scheduled_server_messages(dialog_id_, generation_, std::move(info.messages), + false); } promise_.set_value(Unit()); } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetAllScheduledMessagesQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetAllScheduledMessagesQuery"); promise_.set_error(std::move(status)); } }; @@ -2553,7 +2555,7 @@ class GetRecentLocationsQuery final : public Td::ResultHandler { } void send(DialogId dialog_id, int32 limit) { - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); if (input_peer == nullptr) { return on_error(Status::Error(400, "Have no info about the chat")); } @@ -2571,10 +2573,10 @@ class GetRecentLocationsQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - auto info = td->messages_manager_->get_messages_info(result_ptr.move_as_ok(), "GetRecentLocationsQuery"); - td->messages_manager_->get_channel_difference_if_needed( + auto info = td_->messages_manager_->get_messages_info(result_ptr.move_as_ok(), "GetRecentLocationsQuery"); + td_->messages_manager_->get_channel_difference_if_needed( dialog_id_, std::move(info), - PromiseCreator::lambda([actor_id = td->messages_manager_actor_.get(), dialog_id = dialog_id_, limit = limit_, + PromiseCreator::lambda([actor_id = td_->messages_manager_actor_.get(), dialog_id = dialog_id_, limit = limit_, promise = std::move(promise_)](Result &&result) mutable { if (result.is_error()) { promise.set_error(result.move_as_error()); @@ -2587,7 +2589,7 @@ class GetRecentLocationsQuery final : public Td::ResultHandler { } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetRecentLocationsQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetRecentLocationsQuery"); promise_.set_error(std::move(status)); } }; @@ -2612,7 +2614,7 @@ class GetMessagePublicForwardsQuery final : public Td::ResultHandler { send_query( G()->net_query_creator().create(telegram_api::stats_getMessagePublicForwards( - td->contacts_manager_->get_input_channel(dialog_id_.get_channel_id()), + td_->contacts_manager_->get_input_channel(dialog_id_.get_channel_id()), full_message_id.get_message_id().get_server_message_id().get(), offset_date, std::move(input_peer), offset_message_id.get(), limit), dc_id)); @@ -2624,10 +2626,10 @@ class GetMessagePublicForwardsQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - auto info = td->messages_manager_->get_messages_info(result_ptr.move_as_ok(), "GetMessagePublicForwardsQuery"); - td->messages_manager_->get_channel_differences_if_needed( + auto info = td_->messages_manager_->get_messages_info(result_ptr.move_as_ok(), "GetMessagePublicForwardsQuery"); + td_->messages_manager_->get_channel_differences_if_needed( std::move(info), - PromiseCreator::lambda([actor_id = td->messages_manager_actor_.get(), + PromiseCreator::lambda([actor_id = td_->messages_manager_actor_.get(), promise = std::move(promise_)](Result &&result) mutable { if (result.is_error()) { promise.set_error(result.move_as_error()); @@ -2640,7 +2642,7 @@ class GetMessagePublicForwardsQuery final : public Td::ResultHandler { } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetMessagePublicForwardsQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetMessagePublicForwardsQuery"); promise_.set_error(std::move(status)); } }; @@ -2651,7 +2653,7 @@ class HidePromoDataQuery final : public Td::ResultHandler { public: void send(DialogId dialog_id) { dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); CHECK(input_peer != nullptr); send_query(G()->net_query_creator().create(telegram_api::help_hidePromoData(std::move(input_peer)))); } @@ -2666,7 +2668,7 @@ class HidePromoDataQuery final : public Td::ResultHandler { } void on_error(Status status) final { - if (!td->messages_manager_->on_get_dialog_error(dialog_id_, status, "HidePromoDataQuery")) { + if (!td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "HidePromoDataQuery")) { LOG(ERROR) << "Receive error for sponsored chat hiding: " << status; } } @@ -2680,7 +2682,7 @@ class DeleteHistoryQuery final : public Td::ResultHandler { bool revoke_; void send_request() { - auto input_peer = td->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read); if (input_peer == nullptr) { return promise_.set_error(Status::Error(400, "Chat is not accessible")); } @@ -2722,9 +2724,9 @@ class DeleteHistoryQuery final : public Td::ResultHandler { CHECK(affected_history->get_id() == telegram_api::messages_affectedHistory::ID); if (affected_history->pts_count_ > 0) { - td->updates_manager_->add_pending_pts_update(make_tl_object(), affected_history->pts_, - affected_history->pts_count_, Time::now(), Promise(), - "delete history query"); + td_->updates_manager_->add_pending_pts_update(make_tl_object(), affected_history->pts_, + affected_history->pts_count_, Time::now(), Promise(), + "delete history query"); } if (affected_history->offset_ > 0) { @@ -2736,7 +2738,7 @@ class DeleteHistoryQuery final : public Td::ResultHandler { } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "DeleteHistoryQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "DeleteHistoryQuery"); promise_.set_error(std::move(status)); } }; @@ -2755,7 +2757,7 @@ class DeleteChannelHistoryQuery final : public Td::ResultHandler { channel_id_ = channel_id; max_message_id_ = max_message_id; allow_error_ = allow_error; - auto input_channel = td->contacts_manager_->get_input_channel(channel_id); + auto input_channel = td_->contacts_manager_->get_input_channel(channel_id); CHECK(input_channel != nullptr); send_query(G()->net_query_creator().create( @@ -2776,7 +2778,7 @@ class DeleteChannelHistoryQuery final : public Td::ResultHandler { } void on_error(Status status) final { - if (!td->contacts_manager_->on_get_channel_error(channel_id_, status, "DeleteChannelHistoryQuery")) { + if (!td_->contacts_manager_->on_get_channel_error(channel_id_, status, "DeleteChannelHistoryQuery")) { LOG(ERROR) << "Receive error for DeleteChannelHistoryQuery: " << status; } promise_.set_error(std::move(status)); @@ -2791,7 +2793,7 @@ class DeleteMessagesByDateQuery final : public Td::ResultHandler { bool revoke_; void send_request() { - auto input_peer = td->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read); if (input_peer == nullptr) { return promise_.set_error(Status::Error(400, "Chat is not accessible")); } @@ -2832,9 +2834,9 @@ class DeleteMessagesByDateQuery final : public Td::ResultHandler { if (affected_history->pts_count_ > 0) { affected_history->pts_count_ = 0; // force receiving real updates from the server auto promise = affected_history->offset_ > 0 ? Promise() : std::move(promise_); - td->updates_manager_->add_pending_pts_update(make_tl_object(), affected_history->pts_, - affected_history->pts_count_, Time::now(), std::move(promise), - "DeleteMessagesByDateQuery"); + td_->updates_manager_->add_pending_pts_update(make_tl_object(), affected_history->pts_, + affected_history->pts_count_, Time::now(), std::move(promise), + "DeleteMessagesByDateQuery"); } else if (affected_history->offset_ <= 0) { promise_.set_value(Unit()); } @@ -2846,7 +2848,7 @@ class DeleteMessagesByDateQuery final : public Td::ResultHandler { } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "DeleteMessagesByDateQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "DeleteMessagesByDateQuery"); promise_.set_error(std::move(status)); } }; @@ -2889,8 +2891,8 @@ class DeletePhoneCallHistoryQuery final : public Td::ResultHandler { auto pts_count = affected_messages->pts_count_; auto update = make_tl_object(std::move(affected_messages->messages_), pts, pts_count); - td->updates_manager_->add_pending_pts_update(std::move(update), pts, pts_count, Time::now(), std::move(promise), - "delete phone call history query"); + td_->updates_manager_->add_pending_pts_update(std::move(update), pts, pts_count, Time::now(), std::move(promise), + "delete phone call history query"); } else if (affected_messages->offset_ <= 0) { promise_.set_value(Unit()); } @@ -2936,7 +2938,7 @@ class BlockFromRepliesQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for BlockFromRepliesQuery: " << to_string(ptr); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { @@ -2950,11 +2952,11 @@ class DeleteUserHistoryQuery final : public Td::ResultHandler { UserId user_id_; void send_request() { - auto input_channel = td->contacts_manager_->get_input_channel(channel_id_); + auto input_channel = td_->contacts_manager_->get_input_channel(channel_id_); if (input_channel == nullptr) { return promise_.set_error(Status::Error(400, "Chat is not accessible")); } - auto input_user = td->contacts_manager_->get_input_user(user_id_); + auto input_user = td_->contacts_manager_->get_input_user(user_id_); if (input_user == nullptr) { return promise_.set_error(Status::Error(400, "Usat is not accessible")); } @@ -2986,7 +2988,7 @@ class DeleteUserHistoryQuery final : public Td::ResultHandler { CHECK(affected_history->get_id() == telegram_api::messages_affectedHistory::ID); if (affected_history->pts_count_ > 0) { - td->messages_manager_->add_pending_channel_update( + td_->messages_manager_->add_pending_channel_update( DialogId(channel_id_), make_tl_object(), affected_history->pts_, affected_history->pts_count_, affected_history->offset_ > 0 ? Promise() : std::move(promise_), "delete user history query"); } else if (affected_history->offset_ <= 0) { @@ -3000,7 +3002,7 @@ class DeleteUserHistoryQuery final : public Td::ResultHandler { } void on_error(Status status) final { - td->contacts_manager_->on_get_channel_error(channel_id_, status, "DeleteUserHistoryQuery"); + td_->contacts_manager_->on_get_channel_error(channel_id_, status, "DeleteUserHistoryQuery"); promise_.set_error(std::move(status)); } }; @@ -3010,7 +3012,7 @@ class ReadMentionsQuery final : public Td::ResultHandler { DialogId dialog_id_; void send_request() { - auto input_peer = td->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read); if (input_peer == nullptr) { return promise_.set_error(Status::Error(400, "Chat is not accessible")); } @@ -3043,11 +3045,11 @@ class ReadMentionsQuery final : public Td::ResultHandler { if (dialog_id_.get_type() == DialogType::Channel) { LOG(ERROR) << "Receive pts_count " << affected_history->pts_count_ << " in result of ReadMentionsQuery in " << dialog_id_; - td->updates_manager_->get_difference("Wrong messages_readMentions result"); + td_->updates_manager_->get_difference("Wrong messages_readMentions result"); } else { - td->updates_manager_->add_pending_pts_update(make_tl_object(), affected_history->pts_, - affected_history->pts_count_, Time::now(), Promise(), - "read all mentions query"); + td_->updates_manager_->add_pending_pts_update(make_tl_object(), affected_history->pts_, + affected_history->pts_count_, Time::now(), Promise(), + "read all mentions query"); } } @@ -3060,7 +3062,7 @@ class ReadMentionsQuery final : public Td::ResultHandler { } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "ReadMentionsQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "ReadMentionsQuery"); promise_.set_error(std::move(status)); } }; @@ -3073,7 +3075,8 @@ class SendSecretMessageActor final : public NetActor { vector> &&entities, UserId via_bot_user_id, int64 media_album_id, bool disable_notification, int64 random_id) { if (false && !media.empty()) { - td->messages_manager_->on_send_secret_message_error(random_id, Status::Error(400, "FILE_PART_1_MISSING"), Auto()); + td_->messages_manager_->on_send_secret_message_error(random_id, Status::Error(400, "FILE_PART_1_MISSING"), + Auto()); stop(); return; } @@ -3106,7 +3109,7 @@ class SendSecretMessageActor final : public NetActor { G()->secret_chats_manager(), &SecretChatsManager::send_message, dialog_id.get_secret_chat_id(), make_tl_object( flags, false /*ignored*/, random_id, ttl, text, std::move(media.decrypted_media_), std::move(entities), - td->contacts_manager_->get_user_username(via_bot_user_id), reply_to_random_id, -media_album_id), + td_->contacts_manager_->get_user_username(via_bot_user_id), reply_to_random_id, -media_album_id), std::move(media.input_file_), PromiseCreator::event(self_closure(this, &SendSecretMessageActor::done))); } @@ -3127,7 +3130,7 @@ class SendMessageActor final : public NetActorOnce { random_id_ = random_id; dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); if (input_peer == nullptr) { on_error(Status::Error(400, "Have no write access to the chat")); stop(); @@ -3151,7 +3154,7 @@ class SendMessageActor final : public NetActorOnce { } *send_query_ref = query.get_weak(); query->debug("send to MessagesManager::MultiSequenceDispatcher"); - send_closure(td->messages_manager_->sequence_dispatcher_, &MultiSequenceDispatcher::send_with_callback, + send_closure(td_->messages_manager_->sequence_dispatcher_, &MultiSequenceDispatcher::send_with_callback, std::move(query), actor_shared(this), sequence_dispatcher_id); } @@ -3166,12 +3169,12 @@ class SendMessageActor final : public NetActorOnce { auto constructor_id = ptr->get_id(); if (constructor_id != telegram_api::updateShortSentMessage::ID) { - td->messages_manager_->check_send_message_result(random_id_, dialog_id_, ptr.get(), "SendMessage"); - return td->updates_manager_->on_get_updates(std::move(ptr), Promise()); + td_->messages_manager_->check_send_message_result(random_id_, dialog_id_, ptr.get(), "SendMessage"); + return td_->updates_manager_->on_get_updates(std::move(ptr), Promise()); } auto sent_message = move_tl_object_as(ptr); - td->messages_manager_->on_update_sent_text_message(random_id_, std::move(sent_message->media_), - std::move(sent_message->entities_)); + td_->messages_manager_->on_update_sent_text_message(random_id_, std::move(sent_message->media_), + std::move(sent_message->entities_)); auto message_id = MessageId(ServerMessageId(sent_message->id_)); auto ttl_period = (sent_message->flags_ & telegram_api::updateShortSentMessage::TTL_PERIOD_MASK) != 0 @@ -3179,14 +3182,14 @@ class SendMessageActor final : public NetActorOnce { : 0; auto update = make_tl_object(random_id_, message_id, sent_message->date_, ttl_period); if (dialog_id_.get_type() == DialogType::Channel) { - td->messages_manager_->add_pending_channel_update(dialog_id_, std::move(update), sent_message->pts_, - sent_message->pts_count_, Promise(), - "send message actor"); + td_->messages_manager_->add_pending_channel_update(dialog_id_, std::move(update), sent_message->pts_, + sent_message->pts_count_, Promise(), + "send message actor"); return; } - td->updates_manager_->add_pending_pts_update(std::move(update), sent_message->pts_, sent_message->pts_count_, - Time::now(), Promise(), "send message actor"); + td_->updates_manager_->add_pending_pts_update(std::move(update), sent_message->pts_, sent_message->pts_count_, + Time::now(), Promise(), "send message actor"); } void on_error(Status status) final { @@ -3195,8 +3198,8 @@ class SendMessageActor final : public NetActorOnce { // do not send error, message will be re-sent return; } - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "SendMessageActor"); - td->messages_manager_->on_send_message_fail(random_id_, std::move(status)); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "SendMessageActor"); + td_->messages_manager_->on_send_message_fail(random_id_, std::move(status)); } }; @@ -3235,8 +3238,8 @@ class StartBotQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for StartBotQuery for " << random_id_ << ": " << to_string(ptr); // Result may contain messageActionChatAddUser - // td->messages_manager_->check_send_message_result(random_id_, dialog_id_, ptr.get(), "StartBot"); - td->updates_manager_->on_get_updates(std::move(ptr), Promise()); + // td_->messages_manager_->check_send_message_result(random_id_, dialog_id_, ptr.get(), "StartBot"); + td_->updates_manager_->on_get_updates(std::move(ptr), Promise()); } void on_error(Status status) final { @@ -3245,8 +3248,8 @@ class StartBotQuery final : public Td::ResultHandler { // do not send error, message should be re-sent return; } - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "StartBotQuery"); - td->messages_manager_->on_send_message_fail(random_id_, std::move(status)); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "StartBotQuery"); + td_->messages_manager_->on_send_message_fail(random_id_, std::move(status)); } }; @@ -3260,7 +3263,7 @@ class SendInlineBotResultQuery final : public Td::ResultHandler { random_id_ = random_id; dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); CHECK(input_peer != nullptr); auto query = G()->net_query_creator().create(telegram_api::messages_sendInlineBotResult( @@ -3279,8 +3282,8 @@ class SendInlineBotResultQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for SendInlineBotResultQuery for " << random_id_ << ": " << to_string(ptr); - td->messages_manager_->check_send_message_result(random_id_, dialog_id_, ptr.get(), "SendInlineBotResult"); - td->updates_manager_->on_get_updates(std::move(ptr), Promise()); + td_->messages_manager_->check_send_message_result(random_id_, dialog_id_, ptr.get(), "SendInlineBotResult"); + td_->updates_manager_->on_get_updates(std::move(ptr), Promise()); } void on_error(Status status) final { @@ -3289,8 +3292,8 @@ class SendInlineBotResultQuery final : public Td::ResultHandler { // do not send error, message will be re-sent return; } - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "SendInlineBotResultQuery"); - td->messages_manager_->on_send_message_fail(random_id_, std::move(status)); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "SendInlineBotResultQuery"); + td_->messages_manager_->on_send_message_fail(random_id_, std::move(status)); } }; @@ -3313,7 +3316,7 @@ class SendMultiMediaActor final : public NetActorOnce { file_ids_ = std::move(file_ids); CHECK(file_ids_.size() == random_ids_.size()); - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); if (input_peer == nullptr) { on_error(Status::Error(400, "Have no write access to the chat")); stop(); @@ -3325,7 +3328,7 @@ class SendMultiMediaActor final : public NetActorOnce { 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, + send_closure(td_->messages_manager_->sequence_dispatcher_, &MultiSequenceDispatcher::send_with_callback, std::move(query), actor_shared(this), sequence_dispatcher_id); } @@ -3347,7 +3350,7 @@ class SendMultiMediaActor final : public NetActorOnce { if (random_ids_.size() == 1) { is_result_wrong = true; } - td->messages_manager_->on_send_message_fail(random_id, Status::Error(400, "Message was not sent")); + td_->messages_manager_->on_send_message_fail(random_id, Status::Error(400, "Message was not sent")); } else { sent_random_ids.erase(it); } @@ -3369,10 +3372,10 @@ class SendMultiMediaActor final : public NetActorOnce { if (is_result_wrong) { LOG(ERROR) << "Receive wrong result for SendMultiMedia with random_ids " << format::as_array(random_ids_) << " to " << dialog_id_ << ": " << oneline(to_string(ptr)); - td->updates_manager_->schedule_get_difference("Wrong sendMultiMedia result"); + td_->updates_manager_->schedule_get_difference("Wrong sendMultiMedia result"); } - td->updates_manager_->on_get_updates(std::move(ptr), Promise()); + td_->updates_manager_->on_get_updates(std::move(ptr), Promise()); } void on_error(Status status) final { @@ -3381,21 +3384,21 @@ class SendMultiMediaActor final : public NetActorOnce { // do not send error, message will be re-sent return; } - if (!td->auth_manager_->is_bot() && FileReferenceManager::is_file_reference_error(status)) { + if (!td_->auth_manager_->is_bot() && FileReferenceManager::is_file_reference_error(status)) { auto pos = FileReferenceManager::get_file_reference_error_pos(status); if (1 <= pos && pos <= file_ids_.size() && file_ids_[pos - 1].is_valid()) { VLOG(file_references) << "Receive " << status << " for " << file_ids_[pos - 1]; - td->file_manager_->delete_file_reference(file_ids_[pos - 1], file_references_[pos - 1]); - td->messages_manager_->on_send_media_group_file_reference_error(dialog_id_, std::move(random_ids_)); + td_->file_manager_->delete_file_reference(file_ids_[pos - 1], file_references_[pos - 1]); + td_->messages_manager_->on_send_media_group_file_reference_error(dialog_id_, std::move(random_ids_)); return; } else { LOG(ERROR) << "Receive file reference error " << status << ", but file_ids = " << file_ids_ << ", message_count = " << file_ids_.size(); } } - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "SendMultiMediaActor"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "SendMultiMediaActor"); for (auto &random_id : random_ids_) { - td->messages_manager_->on_send_message_fail(random_id, status.clone()); + td_->messages_manager_->on_send_message_fail(random_id, status.clone()); } } }; @@ -3423,7 +3426,7 @@ class SendMediaActor final : public NetActorOnce { was_uploaded_ = FileManager::extract_was_uploaded(input_media); was_thumbnail_uploaded_ = FileManager::extract_was_thumbnail_uploaded(input_media); - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); if (input_peer == nullptr) { on_error(Status::Error(400, "Have no write access to the chat")); stop(); @@ -3446,7 +3449,7 @@ class SendMediaActor final : public NetActorOnce { } *send_query_ref = query.get_weak(); query->debug("send to MessagesManager::MultiSequenceDispatcher"); - send_closure(td->messages_manager_->sequence_dispatcher_, &MultiSequenceDispatcher::send_with_callback, + send_closure(td_->messages_manager_->sequence_dispatcher_, &MultiSequenceDispatcher::send_with_callback, std::move(query), actor_shared(this), sequence_dispatcher_id); } @@ -3460,13 +3463,13 @@ class SendMediaActor final : public NetActorOnce { CHECK(thumbnail_file_id_.is_valid()); // always delete partial remote location for the thumbnail, because it can't be reused anyway // TODO delete it only in the case it can't be merged with file thumbnail - td->file_manager_->delete_partial_remote_location(thumbnail_file_id_); + td_->file_manager_->delete_partial_remote_location(thumbnail_file_id_); } auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for SendMedia for " << random_id_ << ": " << to_string(ptr); - td->messages_manager_->check_send_message_result(random_id_, dialog_id_, ptr.get(), "SendMedia"); - td->updates_manager_->on_get_updates(std::move(ptr), Promise()); + td_->messages_manager_->check_send_message_result(random_id_, dialog_id_, ptr.get(), "SendMedia"); + td_->updates_manager_->on_get_updates(std::move(ptr), Promise()); } void on_error(Status status) final { @@ -3479,24 +3482,24 @@ class SendMediaActor final : public NetActorOnce { if (was_thumbnail_uploaded_) { CHECK(thumbnail_file_id_.is_valid()); // always delete partial remote location for the thumbnail, because it can't be reused anyway - td->file_manager_->delete_partial_remote_location(thumbnail_file_id_); + td_->file_manager_->delete_partial_remote_location(thumbnail_file_id_); } CHECK(file_id_.is_valid()); if (begins_with(status.message(), "FILE_PART_") && ends_with(status.message(), "_MISSING")) { - td->messages_manager_->on_send_message_file_part_missing(random_id_, - to_integer(status.message().substr(10))); + td_->messages_manager_->on_send_message_file_part_missing(random_id_, + to_integer(status.message().substr(10))); return; } else { if (status.code() != 429 && status.code() < 500 && !G()->close_flag()) { - td->file_manager_->delete_partial_remote_location(file_id_); + td_->file_manager_->delete_partial_remote_location(file_id_); } } - } else if (!td->auth_manager_->is_bot() && FileReferenceManager::is_file_reference_error(status)) { + } else if (!td_->auth_manager_->is_bot() && FileReferenceManager::is_file_reference_error(status)) { if (file_id_.is_valid() && !was_uploaded_) { VLOG(file_references) << "Receive " << status << " for " << file_id_; - td->file_manager_->delete_file_reference(file_id_, file_reference_); - td->messages_manager_->on_send_message_file_reference_error(random_id_); + td_->file_manager_->delete_file_reference(file_id_, file_reference_); + td_->messages_manager_->on_send_message_file_reference_error(random_id_); return; } else { LOG(ERROR) << "Receive file reference error, but file_id = " << file_id_ @@ -3504,8 +3507,8 @@ class SendMediaActor final : public NetActorOnce { } } - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "SendMediaActor"); - td->messages_manager_->on_send_message_fail(random_id_, std::move(status)); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "SendMediaActor"); + td_->messages_manager_->on_send_message_fail(random_id_, std::move(status)); } }; @@ -3530,7 +3533,7 @@ class UploadMediaQuery final : public Td::ResultHandler { was_uploaded_ = FileManager::extract_was_uploaded(input_media); was_thumbnail_uploaded_ = FileManager::extract_was_thumbnail_uploaded(input_media); - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); if (input_peer == nullptr) { return on_error(Status::Error(400, "Have no write access to the chat")); } @@ -3548,13 +3551,13 @@ class UploadMediaQuery final : public Td::ResultHandler { if (was_thumbnail_uploaded_) { CHECK(thumbnail_file_id_.is_valid()); // always delete partial remote location for the thumbnail, because it can't be reused anyway - td->file_manager_->delete_partial_remote_location(thumbnail_file_id_); + td_->file_manager_->delete_partial_remote_location(thumbnail_file_id_); } auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for UploadMediaQuery for " << message_id_ << " in " << dialog_id_ << ": " << to_string(ptr); - td->messages_manager_->on_upload_message_media_success(dialog_id_, message_id_, std::move(ptr)); + td_->messages_manager_->on_upload_message_media_success(dialog_id_, message_id_, std::move(ptr)); } void on_error(Status status) final { @@ -3563,28 +3566,28 @@ class UploadMediaQuery final : public Td::ResultHandler { // do not send error, message will be re-sent return; } - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "UploadMediaQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "UploadMediaQuery"); if (was_uploaded_) { if (was_thumbnail_uploaded_) { CHECK(thumbnail_file_id_.is_valid()); // always delete partial remote location for the thumbnail, because it can't be reused anyway - td->file_manager_->delete_partial_remote_location(thumbnail_file_id_); + td_->file_manager_->delete_partial_remote_location(thumbnail_file_id_); } CHECK(file_id_.is_valid()); if (begins_with(status.message(), "FILE_PART_") && ends_with(status.message(), "_MISSING")) { - td->messages_manager_->on_upload_message_media_file_part_missing( + td_->messages_manager_->on_upload_message_media_file_part_missing( dialog_id_, message_id_, to_integer(status.message().substr(10))); return; } else { if (status.code() != 429 && status.code() < 500 && !G()->close_flag()) { - td->file_manager_->delete_partial_remote_location(file_id_); + td_->file_manager_->delete_partial_remote_location(file_id_); } } } else if (FileReferenceManager::is_file_reference_error(status)) { LOG(ERROR) << "Receive file reference error for UploadMediaQuery"; } - td->messages_manager_->on_upload_message_media_fail(dialog_id_, message_id_, std::move(status)); + td_->messages_manager_->on_upload_message_media_fail(dialog_id_, message_id_, std::move(status)); } }; @@ -3599,7 +3602,7 @@ class SendScheduledMessageActor final : public NetActorOnce { void send(DialogId dialog_id, MessageId message_id, uint64 sequence_dispatcher_id) { dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Edit); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Edit); if (input_peer == nullptr) { on_error(Status::Error(400, "Can't access the chat")); stop(); @@ -3613,7 +3616,7 @@ class SendScheduledMessageActor final : public NetActorOnce { 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, + send_closure(td_->messages_manager_->sequence_dispatcher_, &MultiSequenceDispatcher::send_with_callback, std::move(query), actor_shared(this), sequence_dispatcher_id); } @@ -3625,12 +3628,12 @@ class SendScheduledMessageActor final : public NetActorOnce { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for SendScheduledMessageActor: " << to_string(ptr); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { LOG(INFO) << "Receive error for SendScheduledMessageActor: " << status; - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "SendScheduledMessageActor"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "SendScheduledMessageActor"); promise_.set_error(std::move(status)); } }; @@ -3665,7 +3668,7 @@ class EditMessageActor final : public NetActorOnce { return; } - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Edit); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Edit); if (input_peer == nullptr) { on_error(Status::Error(400, "Can't access the chat")); stop(); @@ -3696,7 +3699,7 @@ class EditMessageActor final : public NetActorOnce { 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, + send_closure(td_->messages_manager_->sequence_dispatcher_, &MultiSequenceDispatcher::send_with_callback, std::move(query), actor_shared(this), sequence_dispatcher_id); } @@ -3708,18 +3711,18 @@ class EditMessageActor final : public NetActorOnce { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for EditMessageActor: " << to_string(ptr); - auto pts = td->updates_manager_->get_update_edit_message_pts(ptr.get()); + auto pts = td_->updates_manager_->get_update_edit_message_pts(ptr.get()); auto promise = PromiseCreator::lambda( [promise = std::move(promise_), pts](Result result) mutable { promise.set_value(std::move(pts)); }); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise)); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise)); } void on_error(Status status) final { LOG(INFO) << "Receive error for EditMessage: " << status; - if (!td->auth_manager_->is_bot() && status.message() == "MESSAGE_NOT_MODIFIED") { + if (!td_->auth_manager_->is_bot() && status.message() == "MESSAGE_NOT_MODIFIED") { return promise_.set_value(0); } - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "EditMessageActor"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "EditMessageActor"); promise_.set_error(std::move(status)); } }; @@ -3796,14 +3799,14 @@ class ForwardMessagesActor final : public NetActorOnce { random_ids_ = random_ids; to_dialog_id_ = to_dialog_id; - auto to_input_peer = td->messages_manager_->get_input_peer(to_dialog_id, AccessRights::Write); + auto to_input_peer = td_->messages_manager_->get_input_peer(to_dialog_id, AccessRights::Write); if (to_input_peer == nullptr) { on_error(Status::Error(400, "Have no write access to the chat")); stop(); return; } - auto from_input_peer = td->messages_manager_->get_input_peer(from_dialog_id, AccessRights::Read); + auto from_input_peer = td_->messages_manager_->get_input_peer(from_dialog_id, AccessRights::Read); if (from_input_peer == nullptr) { on_error(Status::Error(400, "Can't access the chat to forward messages from")); stop(); @@ -3823,7 +3826,7 @@ class ForwardMessagesActor final : public NetActorOnce { }, PromiseCreator::Ignore()); } - send_closure(td->messages_manager_->sequence_dispatcher_, &MultiSequenceDispatcher::send_with_callback, + send_closure(td_->messages_manager_->sequence_dispatcher_, &MultiSequenceDispatcher::send_with_callback, std::move(query), actor_shared(this), sequence_dispatcher_id); } @@ -3844,7 +3847,7 @@ class ForwardMessagesActor final : public NetActorOnce { if (random_ids_.size() == 1) { is_result_wrong = true; } - td->messages_manager_->on_send_message_fail(random_id, Status::Error(400, "Message was not forwarded")); + td_->messages_manager_->on_send_message_fail(random_id, Status::Error(400, "Message was not forwarded")); } else { sent_random_ids.erase(it); } @@ -3866,10 +3869,10 @@ class ForwardMessagesActor final : public NetActorOnce { if (is_result_wrong) { LOG(ERROR) << "Receive wrong result for forwarding messages with random_ids " << format::as_array(random_ids_) << " to " << to_dialog_id_ << ": " << oneline(to_string(ptr)); - td->updates_manager_->schedule_get_difference("Wrong forwardMessages result"); + td_->updates_manager_->schedule_get_difference("Wrong forwardMessages result"); } - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { @@ -3880,7 +3883,7 @@ class ForwardMessagesActor final : public NetActorOnce { } // no on_get_dialog_error call, because two dialogs are involved for (auto &random_id : random_ids_) { - td->messages_manager_->on_send_message_fail(random_id, status.clone()); + td_->messages_manager_->on_send_message_fail(random_id, status.clone()); } promise_.set_error(std::move(status)); } @@ -3899,7 +3902,7 @@ class SendScreenshotNotificationQuery final : public Td::ResultHandler { random_id_ = random_id; dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write); CHECK(input_peer != nullptr); auto query = G()->net_query_creator().create( @@ -3915,9 +3918,9 @@ class SendScreenshotNotificationQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for SendScreenshotNotificationQuery for " << random_id_ << ": " << to_string(ptr); - td->messages_manager_->check_send_message_result(random_id_, dialog_id_, ptr.get(), - "SendScreenshotNotificationQuery"); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->messages_manager_->check_send_message_result(random_id_, dialog_id_, ptr.get(), + "SendScreenshotNotificationQuery"); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { @@ -3926,8 +3929,8 @@ class SendScreenshotNotificationQuery final : public Td::ResultHandler { // do not send error, messages should be re-sent return; } - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "SendScreenshotNotificationQuery"); - td->messages_manager_->on_send_message_fail(random_id_, status.clone()); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "SendScreenshotNotificationQuery"); + td_->messages_manager_->on_send_message_fail(random_id_, status.clone()); promise_.set_error(std::move(status)); } }; @@ -3975,7 +3978,7 @@ class SetTypingQuery final : public Td::ResultHandler { return promise_.set_value(Unit()); } - if (!td->messages_manager_->on_get_dialog_error(dialog_id_, status, "SetTypingQuery")) { + if (!td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "SetTypingQuery")) { LOG(INFO) << "Receive error for set typing: " << status; } promise_.set_error(std::move(status)); @@ -4025,9 +4028,9 @@ class DeleteMessagesQuery final : public Td::ResultHandler { CHECK(affected_messages->get_id() == telegram_api::messages_affectedMessages::ID); if (affected_messages->pts_count_ > 0) { - td->updates_manager_->add_pending_pts_update(make_tl_object(), affected_messages->pts_, - affected_messages->pts_count_, Time::now(), Promise(), - "delete messages query"); + td_->updates_manager_->add_pending_pts_update(make_tl_object(), affected_messages->pts_, + affected_messages->pts_count_, Time::now(), Promise(), + "delete messages query"); } if (--query_count_ == 0) { promise_.set_value(Unit()); @@ -4039,7 +4042,7 @@ class DeleteMessagesQuery final : public Td::ResultHandler { // MESSAGE_DELETE_FORBIDDEN can be returned in group chats when administrator rights was removed // MESSAGE_DELETE_FORBIDDEN can be returned in private chats for bots when revoke time limit exceeded if (status.message() != "MESSAGE_DELETE_FORBIDDEN" || - (dialog_id_.get_type() == DialogType::User && !td->auth_manager_->is_bot())) { + (dialog_id_.get_type() == DialogType::User && !td_->auth_manager_->is_bot())) { LOG(ERROR) << "Receive error for delete messages: " << status; } } @@ -4070,7 +4073,7 @@ class DeleteChannelMessagesQuery final : public Td::ResultHandler { vector slice(server_message_ids.begin() + i, end); query_count_++; - auto input_channel = td->contacts_manager_->get_input_channel(channel_id); + auto input_channel = td_->contacts_manager_->get_input_channel(channel_id); CHECK(input_channel != nullptr); send_query(G()->net_query_creator().create( telegram_api::channels_deleteMessages(std::move(input_channel), std::move(slice)))); @@ -4088,9 +4091,9 @@ class DeleteChannelMessagesQuery final : public Td::ResultHandler { CHECK(affected_messages->get_id() == telegram_api::messages_affectedMessages::ID); if (affected_messages->pts_count_ > 0) { - td->messages_manager_->add_pending_channel_update(DialogId(channel_id_), make_tl_object(), - affected_messages->pts_, affected_messages->pts_count_, - Promise(), "DeleteChannelMessagesQuery"); + td_->messages_manager_->add_pending_channel_update(DialogId(channel_id_), make_tl_object(), + affected_messages->pts_, affected_messages->pts_count_, + Promise(), "DeleteChannelMessagesQuery"); } if (--query_count_ == 0) { promise_.set_value(Unit()); @@ -4098,7 +4101,7 @@ class DeleteChannelMessagesQuery final : public Td::ResultHandler { } void on_error(Status status) final { - if (!td->contacts_manager_->on_get_channel_error(channel_id_, status, "DeleteChannelMessagesQuery") && + if (!td_->contacts_manager_->on_get_channel_error(channel_id_, status, "DeleteChannelMessagesQuery") && status.message() != "MESSAGE_DELETE_FORBIDDEN") { LOG(ERROR) << "Receive error for delete channel messages: " << status; } @@ -4118,7 +4121,7 @@ class DeleteScheduledMessagesQuery final : public Td::ResultHandler { dialog_id_ = dialog_id; LOG(INFO) << "Send deleteScheduledMessagesQuery to delete " << format::as_array(message_ids); - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); if (input_peer == nullptr) { return on_error(Status::Error(400, "Can't access the chat")); } @@ -4134,11 +4137,11 @@ class DeleteScheduledMessagesQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for DeleteScheduledMessagesQuery: " << to_string(ptr); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { - if (!td->messages_manager_->on_get_dialog_error(dialog_id_, status, "DeleteScheduledMessagesQuery")) { + if (!td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "DeleteScheduledMessagesQuery")) { LOG(ERROR) << "Receive error for delete scheduled messages: " << status; } promise_.set_error(std::move(status)); @@ -4151,7 +4154,7 @@ class GetDialogNotifySettingsQuery final : public Td::ResultHandler { public: void send(DialogId dialog_id) { dialog_id_ = dialog_id; - auto input_notify_peer = td->messages_manager_->get_input_notify_peer(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(telegram_api::account_getNotifySettings(std::move(input_notify_peer)))); } @@ -4163,13 +4166,14 @@ class GetDialogNotifySettingsQuery final : public Td::ResultHandler { } auto ptr = result_ptr.move_as_ok(); - td->messages_manager_->on_update_dialog_notify_settings(dialog_id_, std::move(ptr), "GetDialogNotifySettingsQuery"); - td->messages_manager_->on_get_dialog_notification_settings_query_finished(dialog_id_, Status::OK()); + td_->messages_manager_->on_update_dialog_notify_settings(dialog_id_, std::move(ptr), + "GetDialogNotifySettingsQuery"); + td_->messages_manager_->on_get_dialog_notification_settings_query_finished(dialog_id_, Status::OK()); } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetDialogNotifySettingsQuery"); - td->messages_manager_->on_get_dialog_notification_settings_query_finished(dialog_id_, std::move(status)); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetDialogNotifySettingsQuery"); + td_->messages_manager_->on_get_dialog_notification_settings_query_finished(dialog_id_, std::move(status)); } }; @@ -4222,12 +4226,12 @@ class GetNotifySettingsExceptionsQuery final : public Td::ResultHandler { break; } } - td->contacts_manager_->on_get_users(std::move(users), "GetNotifySettingsExceptionsQuery"); - td->contacts_manager_->on_get_chats(std::move(chats), "GetNotifySettingsExceptionsQuery"); + td_->contacts_manager_->on_get_users(std::move(users), "GetNotifySettingsExceptionsQuery"); + td_->contacts_manager_->on_get_chats(std::move(chats), "GetNotifySettingsExceptionsQuery"); for (auto &dialog_id : dialog_ids) { - td->messages_manager_->force_create_dialog(dialog_id, "GetNotifySettingsExceptionsQuery"); + td_->messages_manager_->force_create_dialog(dialog_id, "GetNotifySettingsExceptionsQuery"); } - td->updates_manager_->on_get_updates(std::move(updates_ptr), std::move(promise_)); + td_->updates_manager_->on_get_updates(std::move(updates_ptr), std::move(promise_)); } void on_error(Status status) final { @@ -4257,7 +4261,7 @@ class GetScopeNotifySettingsQuery final : public Td::ResultHandler { } auto ptr = result_ptr.move_as_ok(); - td->messages_manager_->on_update_scope_notify_settings(scope_, std::move(ptr)); + td_->messages_manager_->on_update_scope_notify_settings(scope_, std::move(ptr)); promise_.set_value(Unit()); } @@ -4278,7 +4282,7 @@ class UpdateDialogNotifySettingsQuery final : public Td::ResultHandler { void send(DialogId dialog_id, const DialogNotificationSettings &new_settings) { dialog_id_ = dialog_id; - auto input_notify_peer = td->messages_manager_->get_input_notify_peer(dialog_id); + auto input_notify_peer = td_->messages_manager_->get_input_notify_peer(dialog_id); if (input_notify_peer == nullptr) { return on_error(Status::Error(500, "Can't update chat notification settings")); } @@ -4317,13 +4321,13 @@ class UpdateDialogNotifySettingsQuery final : public Td::ResultHandler { } void on_error(Status status) final { - if (!td->messages_manager_->on_get_dialog_error(dialog_id_, status, "UpdateDialogNotifySettingsQuery")) { + if (!td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "UpdateDialogNotifySettingsQuery")) { LOG(INFO) << "Receive error for set chat notification settings: " << status; } - if (!td->auth_manager_->is_bot() && td->messages_manager_->get_input_notify_peer(dialog_id_) != nullptr) { + if (!td_->auth_manager_->is_bot() && td_->messages_manager_->get_input_notify_peer(dialog_id_) != nullptr) { // trying to repair notification settings for this dialog - td->messages_manager_->send_get_dialog_notification_settings_query(dialog_id_, Promise<>()); + td_->messages_manager_->send_get_dialog_notification_settings_query(dialog_id_, Promise<>()); } promise_.set_error(std::move(status)); @@ -4368,9 +4372,9 @@ class UpdateScopeNotifySettingsQuery final : public Td::ResultHandler { void on_error(Status status) final { LOG(INFO) << "Receive error for set notification settings: " << status; - if (!td->auth_manager_->is_bot()) { + if (!td_->auth_manager_->is_bot()) { // trying to repair notification settings for this scope - td->messages_manager_->send_get_scope_notification_settings_query(scope_, Promise<>()); + td_->messages_manager_->send_get_scope_notification_settings_query(scope_, Promise<>()); } promise_.set_error(std::move(status)); @@ -4417,7 +4421,7 @@ class GetPeerSettingsQuery final : public Td::ResultHandler { void send(DialogId dialog_id) { dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); CHECK(input_peer != nullptr); send_query(G()->net_query_creator().create(telegram_api::messages_getPeerSettings(std::move(input_peer)))); @@ -4429,12 +4433,12 @@ class GetPeerSettingsQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - td->messages_manager_->on_get_peer_settings(dialog_id_, result_ptr.move_as_ok()); + td_->messages_manager_->on_get_peer_settings(dialog_id_, result_ptr.move_as_ok()); } void on_error(Status status) final { LOG(INFO) << "Receive error for get peer settings: " << status; - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetPeerSettingsQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetPeerSettingsQuery"); } }; @@ -4449,7 +4453,7 @@ class UpdatePeerSettingsQuery final : public Td::ResultHandler { void send(DialogId dialog_id, bool is_spam_dialog) { dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); if (input_peer == nullptr) { return promise_.set_value(Unit()); } @@ -4470,15 +4474,15 @@ class UpdatePeerSettingsQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - td->messages_manager_->on_get_peer_settings(dialog_id_, make_tl_object(), true); + td_->messages_manager_->on_get_peer_settings(dialog_id_, make_tl_object(), true); promise_.set_value(Unit()); } void on_error(Status status) final { LOG(INFO) << "Receive error for update peer settings: " << status; - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "UpdatePeerSettingsQuery"); - td->messages_manager_->reget_dialog_action_bar(dialog_id_, "UpdatePeerSettingsQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "UpdatePeerSettingsQuery"); + td_->messages_manager_->reget_dialog_action_bar(dialog_id_, "UpdatePeerSettingsQuery"); promise_.set_error(std::move(status)); } }; @@ -4494,7 +4498,7 @@ class ReportEncryptedSpamQuery final : public Td::ResultHandler { void send(DialogId dialog_id) { dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_encrypted_chat(dialog_id, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_encrypted_chat(dialog_id, AccessRights::Read); CHECK(input_peer != nullptr); LOG(INFO) << "Report spam in " << to_string(input_peer); @@ -4507,16 +4511,16 @@ class ReportEncryptedSpamQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - td->messages_manager_->on_get_peer_settings(dialog_id_, make_tl_object(), true); + td_->messages_manager_->on_get_peer_settings(dialog_id_, make_tl_object(), true); promise_.set_value(Unit()); } void on_error(Status status) final { LOG(INFO) << "Receive error for report encrypted spam: " << status; - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "ReportEncryptedSpamQuery"); - td->messages_manager_->reget_dialog_action_bar( - DialogId(td->contacts_manager_->get_secret_chat_user_id(dialog_id_.get_secret_chat_id())), + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "ReportEncryptedSpamQuery"); + td_->messages_manager_->reget_dialog_action_bar( + DialogId(td_->contacts_manager_->get_secret_chat_user_id(dialog_id_.get_secret_chat_id())), "ReportEncryptedSpamQuery"); promise_.set_error(std::move(status)); } @@ -4533,7 +4537,7 @@ class ReportPeerQuery final : public Td::ResultHandler { void send(DialogId dialog_id, const vector &message_ids, ReportReason &&report_reason) { dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); CHECK(input_peer != nullptr); if (message_ids.empty()) { @@ -4565,8 +4569,8 @@ class ReportPeerQuery final : public Td::ResultHandler { void on_error(Status status) final { LOG(INFO) << "Receive error for report peer: " << status; - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "ReportPeerQuery"); - td->messages_manager_->reget_dialog_action_bar(dialog_id_, "ReportPeerQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "ReportPeerQuery"); + td_->messages_manager_->reget_dialog_action_bar(dialog_id_, "ReportPeerQuery"); promise_.set_error(std::move(status)); } }; @@ -4589,7 +4593,7 @@ class ReportProfilePhotoQuery final : public Td::ResultHandler { file_reference_ = FileManager::extract_file_reference(input_photo); report_reason_ = std::move(report_reason); - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); CHECK(input_peer != nullptr); send_query(G()->net_query_creator().create(telegram_api::account_reportProfilePhoto( @@ -4613,10 +4617,10 @@ class ReportProfilePhotoQuery final : public Td::ResultHandler { void on_error(Status status) final { LOG(INFO) << "Receive error for report chat photo: " << status; - if (!td->auth_manager_->is_bot() && FileReferenceManager::is_file_reference_error(status)) { + if (!td_->auth_manager_->is_bot() && FileReferenceManager::is_file_reference_error(status)) { VLOG(file_references) << "Receive " << status << " for " << file_id_; - td->file_manager_->delete_file_reference(file_id_, file_reference_); - td->file_reference_manager_->repair_file_reference( + td_->file_manager_->delete_file_reference(file_id_, file_reference_); + td_->file_reference_manager_->repair_file_reference( file_id_, PromiseCreator::lambda([dialog_id = dialog_id_, file_id = file_id_, report_reason = std::move(report_reason_), promise = std::move(promise_)](Result result) mutable { @@ -4630,7 +4634,7 @@ class ReportProfilePhotoQuery final : public Td::ResultHandler { return; } - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "ReportProfilePhotoQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "ReportProfilePhotoQuery"); promise_.set_error(std::move(status)); } }; @@ -4646,7 +4650,7 @@ class EditPeerFoldersQuery final : public Td::ResultHandler { void send(DialogId dialog_id, FolderId folder_id) { dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); CHECK(input_peer != nullptr); vector> input_folder_peers; @@ -4663,16 +4667,16 @@ class EditPeerFoldersQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for EditPeerFoldersQuery: " << to_string(ptr); - td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); + td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); } void on_error(Status status) final { - if (!td->messages_manager_->on_get_dialog_error(dialog_id_, status, "EditPeerFoldersQuery")) { + if (!td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "EditPeerFoldersQuery")) { LOG(INFO) << "Receive error for EditPeerFoldersQuery: " << status; } // trying to repair folder ID for this dialog - td->messages_manager_->get_dialog_info_full(dialog_id_, Auto(), "EditPeerFoldersQuery"); + td_->messages_manager_->get_dialog_info_full(dialog_id_, Auto(), "EditPeerFoldersQuery"); promise_.set_error(std::move(status)); } @@ -4707,15 +4711,15 @@ class GetChannelDifferenceQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - td->messages_manager_->on_get_channel_difference(dialog_id_, pts_, limit_, result_ptr.move_as_ok()); + td_->messages_manager_->on_get_channel_difference(dialog_id_, pts_, limit_, result_ptr.move_as_ok()); } void on_error(Status status) final { - if (!td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetChannelDifferenceQuery")) { + if (!td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetChannelDifferenceQuery")) { LOG(ERROR) << "Receive updates.getChannelDifference error for " << dialog_id_ << " with pts " << pts_ << " and limit " << limit_ << ": " << status; } - td->messages_manager_->on_get_channel_difference(dialog_id_, pts_, limit_, nullptr); + td_->messages_manager_->on_get_channel_difference(dialog_id_, pts_, limit_, nullptr); } }; @@ -4742,17 +4746,17 @@ class ResolveUsernameQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(DEBUG) << "Receive result for ResolveUsernameQuery: " << to_string(ptr); - td->contacts_manager_->on_get_users(std::move(ptr->users_), "ResolveUsernameQuery"); - td->contacts_manager_->on_get_chats(std::move(ptr->chats_), "ResolveUsernameQuery"); + td_->contacts_manager_->on_get_users(std::move(ptr->users_), "ResolveUsernameQuery"); + td_->contacts_manager_->on_get_chats(std::move(ptr->chats_), "ResolveUsernameQuery"); - td->messages_manager_->on_resolved_username(username_, DialogId(ptr->peer_)); + td_->messages_manager_->on_resolved_username(username_, DialogId(ptr->peer_)); promise_.set_value(Unit()); } void on_error(Status status) final { if (status.message() == Slice("USERNAME_NOT_OCCUPIED")) { - td->messages_manager_->drop_username(username_); + td_->messages_manager_->drop_username(username_); } promise_.set_error(std::move(status)); } @@ -4773,7 +4777,7 @@ class GetChannelAdminLogQuery final : public Td::ResultHandler { channel_id_ = channel_id; random_id_ = random_id; - auto input_channel = td->contacts_manager_->get_input_channel(channel_id); + auto input_channel = td_->contacts_manager_->get_input_channel(channel_id); CHECK(input_channel != nullptr); int32 flags = 0; @@ -4794,13 +4798,13 @@ class GetChannelAdminLogQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - td->messages_manager_->on_get_event_log(channel_id_, random_id_, result_ptr.move_as_ok()); + td_->messages_manager_->on_get_event_log(channel_id_, random_id_, result_ptr.move_as_ok()); promise_.set_value(Unit()); } void on_error(Status status) final { - td->contacts_manager_->on_get_channel_error(channel_id_, status, "GetChannelAdminLogQuery"); - td->messages_manager_->on_get_event_log(channel_id_, random_id_, nullptr); + td_->contacts_manager_->on_get_channel_error(channel_id_, status, "GetChannelAdminLogQuery"); + td_->messages_manager_->on_get_event_log(channel_id_, random_id_, nullptr); promise_.set_error(std::move(status)); } }; diff --git a/td/telegram/NotificationManager.cpp b/td/telegram/NotificationManager.cpp index 9ed150ffd..429cbd37f 100644 --- a/td/telegram/NotificationManager.cpp +++ b/td/telegram/NotificationManager.cpp @@ -113,7 +113,7 @@ class GetContactSignUpNotificationQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - td->notification_manager_->on_get_disable_contact_registered_notifications(result_ptr.ok()); + td_->notification_manager_->on_get_disable_contact_registered_notifications(result_ptr.ok()); promise_.set_value(Unit()); } diff --git a/td/telegram/Payments.cpp b/td/telegram/Payments.cpp index 6e4e9d89d..3537a3fa0 100644 --- a/td/telegram/Payments.cpp +++ b/td/telegram/Payments.cpp @@ -270,7 +270,7 @@ class GetPaymentFormQuery final : public Td::ResultHandler { void send(DialogId dialog_id, ServerMessageId server_message_id, tl_object_ptr &&theme_parameters) { dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); if (input_peer == nullptr) { return on_error(Status::Error(400, "Can't access the chat")); } @@ -292,7 +292,7 @@ class GetPaymentFormQuery final : public Td::ResultHandler { auto payment_form = result_ptr.move_as_ok(); LOG(INFO) << "Receive payment form: " << to_string(payment_form); - td->contacts_manager_->on_get_users(std::move(payment_form->users_), "GetPaymentFormQuery"); + td_->contacts_manager_->on_get_users(std::move(payment_form->users_), "GetPaymentFormQuery"); UserId payments_provider_user_id(payment_form->provider_id_); if (!payments_provider_user_id.is_valid()) { @@ -308,15 +308,15 @@ class GetPaymentFormQuery final : public Td::ResultHandler { bool need_password = payment_form->password_missing_; promise_.set_value(make_tl_object( payment_form->form_id_, convert_invoice(std::move(payment_form->invoice_)), std::move(payment_form->url_), - td->contacts_manager_->get_user_id_object(seller_bot_user_id, "paymentForm seller"), - td->contacts_manager_->get_user_id_object(payments_provider_user_id, "paymentForm provider"), + td_->contacts_manager_->get_user_id_object(seller_bot_user_id, "paymentForm seller"), + td_->contacts_manager_->get_user_id_object(payments_provider_user_id, "paymentForm provider"), convert_payment_provider(payment_form->native_provider_, std::move(payment_form->native_params_)), convert_order_info(std::move(payment_form->saved_info_)), convert_saved_credentials(std::move(payment_form->saved_credentials_)), can_save_credentials, need_password)); } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetPaymentFormQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetPaymentFormQuery"); promise_.set_error(std::move(status)); } }; @@ -333,7 +333,7 @@ class ValidateRequestedInfoQuery final : public Td::ResultHandler { void send(DialogId dialog_id, ServerMessageId server_message_id, tl_object_ptr requested_info, bool allow_save) { dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); if (input_peer == nullptr) { return on_error(Status::Error(400, "Can't access the chat")); } @@ -365,7 +365,7 @@ class ValidateRequestedInfoQuery final : public Td::ResultHandler { } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "ValidateRequestedInfoQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "ValidateRequestedInfoQuery"); promise_.set_error(std::move(status)); } }; @@ -385,7 +385,7 @@ class SendPaymentFormQuery final : public Td::ResultHandler { CHECK(input_credentials != nullptr); dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); if (input_peer == nullptr) { return on_error(Status::Error(400, "Can't access the chat")); } @@ -417,10 +417,10 @@ class SendPaymentFormQuery final : public Td::ResultHandler { switch (payment_result->get_id()) { case telegram_api::payments_paymentResult::ID: { auto result = move_tl_object_as(payment_result); - td->updates_manager_->on_get_updates(std::move(result->updates_), - PromiseCreator::lambda([promise = std::move(promise_)](Unit) mutable { - promise.set_value(make_tl_object(true, string())); - })); + td_->updates_manager_->on_get_updates( + std::move(result->updates_), PromiseCreator::lambda([promise = std::move(promise_)](Unit) mutable { + promise.set_value(make_tl_object(true, string())); + })); return; } case telegram_api::payments_paymentVerificationNeeded::ID: { @@ -434,7 +434,7 @@ class SendPaymentFormQuery final : public Td::ResultHandler { } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "SendPaymentFormQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "SendPaymentFormQuery"); promise_.set_error(std::move(status)); } }; @@ -450,7 +450,7 @@ class GetPaymentReceiptQuery final : public Td::ResultHandler { void send(DialogId dialog_id, ServerMessageId server_message_id) { dialog_id_ = dialog_id; - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); if (input_peer == nullptr) { return on_error(Status::Error(400, "Can't access the chat")); } @@ -468,7 +468,7 @@ class GetPaymentReceiptQuery final : public Td::ResultHandler { auto payment_receipt = result_ptr.move_as_ok(); LOG(INFO) << "Receive payment receipt: " << to_string(payment_receipt); - td->contacts_manager_->on_get_users(std::move(payment_receipt->users_), "GetPaymentReceiptQuery"); + td_->contacts_manager_->on_get_users(std::move(payment_receipt->users_), "GetPaymentReceiptQuery"); UserId payments_provider_user_id(payment_receipt->provider_id_); if (!payments_provider_user_id.is_valid()) { @@ -480,19 +480,19 @@ class GetPaymentReceiptQuery final : public Td::ResultHandler { LOG(ERROR) << "Receive invalid seller " << seller_bot_user_id; return on_error(Status::Error(500, "Receive invalid seller identifier")); } - auto photo = get_web_document_photo(td->file_manager_.get(), std::move(payment_receipt->photo_), dialog_id_); + auto photo = get_web_document_photo(td_->file_manager_.get(), std::move(payment_receipt->photo_), dialog_id_); promise_.set_value(make_tl_object( - payment_receipt->title_, payment_receipt->description_, get_photo_object(td->file_manager_.get(), photo), - payment_receipt->date_, td->contacts_manager_->get_user_id_object(seller_bot_user_id, "paymentReceipt seller"), - td->contacts_manager_->get_user_id_object(payments_provider_user_id, "paymentReceipt provider"), + payment_receipt->title_, payment_receipt->description_, get_photo_object(td_->file_manager_.get(), photo), + payment_receipt->date_, td_->contacts_manager_->get_user_id_object(seller_bot_user_id, "paymentReceipt seller"), + td_->contacts_manager_->get_user_id_object(payments_provider_user_id, "paymentReceipt provider"), convert_invoice(std::move(payment_receipt->invoice_)), convert_order_info(std::move(payment_receipt->info_)), convert_shipping_option(std::move(payment_receipt->shipping_)), std::move(payment_receipt->credentials_title_), payment_receipt->tip_amount_)); } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetPaymentReceiptQuery"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetPaymentReceiptQuery"); promise_.set_error(std::move(status)); } }; diff --git a/td/telegram/PollManager.cpp b/td/telegram/PollManager.cpp index 74065f72f..ba6c67769 100644 --- a/td/telegram/PollManager.cpp +++ b/td/telegram/PollManager.cpp @@ -61,7 +61,7 @@ class GetPollResultsQuery final : public Td::ResultHandler { void send(PollId poll_id, FullMessageId full_message_id) { poll_id_ = poll_id; dialog_id_ = full_message_id.get_dialog_id(); - auto input_peer = td->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read); if (input_peer == nullptr) { LOG(INFO) << "Can't reget poll, because have no read access to " << dialog_id_; return promise_.set_value(nullptr); @@ -82,7 +82,7 @@ class GetPollResultsQuery final : public Td::ResultHandler { } void on_error(Status status) final { - if (!td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetPollResultsQuery") && + if (!td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetPollResultsQuery") && status.message() != "MESSAGE_ID_INVALID") { LOG(ERROR) << "Receive " << status << ", while trying to get results of " << poll_id_; } @@ -103,7 +103,7 @@ class GetPollVotersQuery final : public Td::ResultHandler { void send(PollId poll_id, FullMessageId full_message_id, BufferSlice &&option, const string &offset, int32 limit) { poll_id_ = poll_id; dialog_id_ = full_message_id.get_dialog_id(); - auto input_peer = td->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read); if (input_peer == nullptr) { LOG(INFO) << "Can't get poll, because have no read access to " << dialog_id_; return promise_.set_error(Status::Error(400, "Chat is not accessible")); @@ -130,7 +130,7 @@ class GetPollVotersQuery final : public Td::ResultHandler { } void on_error(Status status) final { - if (!td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetPollVotersQuery") && + if (!td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetPollVotersQuery") && status.message() != "MESSAGE_ID_INVALID") { LOG(ERROR) << "Receive " << status << ", while trying to get voters of " << poll_id_; } @@ -148,7 +148,7 @@ class SetPollAnswerActor final : public NetActorOnce { void send(FullMessageId full_message_id, vector &&options, uint64 generation, NetQueryRef *query_ref) { dialog_id_ = full_message_id.get_dialog_id(); - auto input_peer = td->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read); if (input_peer == nullptr) { LOG(INFO) << "Can't set poll answer, because have no read access to " << dialog_id_; return on_error(Status::Error(400, "Can't access the chat")); @@ -159,7 +159,7 @@ class SetPollAnswerActor final : public NetActorOnce { 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, + send_closure(td_->messages_manager_->sequence_dispatcher_, &MultiSequenceDispatcher::send_with_callback, std::move(query), actor_shared(this), sequence_id); } @@ -175,7 +175,7 @@ class SetPollAnswerActor final : public NetActorOnce { } void on_error(Status status) final { - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "SetPollAnswerActor"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "SetPollAnswerActor"); promise_.set_error(std::move(status)); } }; @@ -190,7 +190,7 @@ class StopPollActor final : public NetActorOnce { void send(FullMessageId full_message_id, unique_ptr &&reply_markup) { dialog_id_ = full_message_id.get_dialog_id(); - auto input_peer = td->messages_manager_->get_input_peer(dialog_id_, AccessRights::Edit); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Edit); if (input_peer == nullptr) { LOG(INFO) << "Can't close poll, because have no edit access to " << dialog_id_; return on_error(Status::Error(400, "Can't access the chat")); @@ -210,11 +210,11 @@ class StopPollActor final : public NetActorOnce { 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>(), 0)); - if (td->auth_manager_->is_bot()) { + if (td_->auth_manager_->is_bot()) { send_query(std::move(query)); } else { auto sequence_id = -1; - send_closure(td->messages_manager_->sequence_dispatcher_, &MultiSequenceDispatcher::send_with_callback, + send_closure(td_->messages_manager_->sequence_dispatcher_, &MultiSequenceDispatcher::send_with_callback, std::move(query), actor_shared(this), sequence_id); } } @@ -227,14 +227,14 @@ class StopPollActor final : public NetActorOnce { auto result = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for StopPoll: " << to_string(result); - td->updates_manager_->on_get_updates(std::move(result), std::move(promise_)); + td_->updates_manager_->on_get_updates(std::move(result), std::move(promise_)); } void on_error(Status status) final { - if (!td->auth_manager_->is_bot() && status.message() == "MESSAGE_NOT_MODIFIED") { + if (!td_->auth_manager_->is_bot() && status.message() == "MESSAGE_NOT_MODIFIED") { return promise_.set_value(Unit()); } - td->messages_manager_->on_get_dialog_error(dialog_id_, status, "StopPollActor"); + td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "StopPollActor"); promise_.set_error(std::move(status)); } }; diff --git a/td/telegram/SponsoredMessageManager.cpp b/td/telegram/SponsoredMessageManager.cpp index cd735e7b5..080a9543b 100644 --- a/td/telegram/SponsoredMessageManager.cpp +++ b/td/telegram/SponsoredMessageManager.cpp @@ -40,7 +40,7 @@ class GetSponsoredMessagesQuery final : public Td::ResultHandler { void send(ChannelId channel_id) { channel_id_ = channel_id; - auto input_channel = td->contacts_manager_->get_input_channel(channel_id); + auto input_channel = td_->contacts_manager_->get_input_channel(channel_id); if (input_channel == nullptr) { return promise_.set_error(Status::Error(400, "Chat info not found")); } @@ -57,7 +57,7 @@ class GetSponsoredMessagesQuery final : public Td::ResultHandler { } void on_error(Status status) final { - td->contacts_manager_->on_get_channel_error(channel_id_, status, "GetSponsoredMessagesQuery"); + td_->contacts_manager_->on_get_channel_error(channel_id_, status, "GetSponsoredMessagesQuery"); promise_.set_error(std::move(status)); } }; @@ -72,7 +72,7 @@ class ViewSponsoredMessageQuery final : public Td::ResultHandler { void send(ChannelId channel_id, const string &message_id) { channel_id_ = channel_id; - auto input_channel = td->contacts_manager_->get_input_channel(channel_id); + auto input_channel = td_->contacts_manager_->get_input_channel(channel_id); if (input_channel == nullptr) { return promise_.set_error(Status::Error(400, "Chat info not found")); } @@ -90,7 +90,7 @@ class ViewSponsoredMessageQuery final : public Td::ResultHandler { } void on_error(Status status) final { - td->contacts_manager_->on_get_channel_error(channel_id_, status, "ViewSponsoredMessageQuery"); + td_->contacts_manager_->on_get_channel_error(channel_id_, status, "ViewSponsoredMessageQuery"); promise_.set_error(std::move(status)); } }; diff --git a/td/telegram/StickersManager.cpp b/td/telegram/StickersManager.cpp index 04a01dfd8..50f2df5c5 100644 --- a/td/telegram/StickersManager.cpp +++ b/td/telegram/StickersManager.cpp @@ -93,14 +93,14 @@ class GetAllStickersQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(DEBUG) << "Receive result for get all " << (is_masks_ ? "masks" : "stickers") << ": " << to_string(ptr); - td->stickers_manager_->on_get_installed_sticker_sets(is_masks_, std::move(ptr)); + td_->stickers_manager_->on_get_installed_sticker_sets(is_masks_, std::move(ptr)); } void on_error(Status status) final { if (!G()->is_expected_error(status)) { LOG(ERROR) << "Receive error for get all stickers: " << status; } - td->stickers_manager_->on_get_installed_sticker_sets_failed(is_masks_, std::move(status)); + td_->stickers_manager_->on_get_installed_sticker_sets_failed(is_masks_, std::move(status)); } }; @@ -121,14 +121,14 @@ class SearchStickersQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for search stickers: " << to_string(ptr); - td->stickers_manager_->on_find_stickers_success(emoji_, std::move(ptr)); + td_->stickers_manager_->on_find_stickers_success(emoji_, std::move(ptr)); } void on_error(Status status) final { if (!G()->is_expected_error(status)) { LOG(ERROR) << "Receive error for search stickers: " << status; } - td->stickers_manager_->on_find_stickers_fail(emoji_, std::move(status)); + td_->stickers_manager_->on_find_stickers_fail(emoji_, std::move(status)); } }; @@ -272,8 +272,8 @@ class GetArchivedStickerSetsQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for GetArchivedStickerSetsQuery: " << to_string(ptr); - td->stickers_manager_->on_get_archived_sticker_sets(is_masks_, offset_sticker_set_id_, std::move(ptr->sets_), - ptr->count_); + td_->stickers_manager_->on_get_archived_sticker_sets(is_masks_, offset_sticker_set_id_, std::move(ptr->sets_), + ptr->count_); promise_.set_value(Unit()); } @@ -298,11 +298,11 @@ class GetFeaturedStickerSetsQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(DEBUG) << "Receive result for GetFeaturedStickerSetsQuery: " << to_string(ptr); - td->stickers_manager_->on_get_featured_sticker_sets(-1, -1, 0, std::move(ptr)); + td_->stickers_manager_->on_get_featured_sticker_sets(-1, -1, 0, std::move(ptr)); } void on_error(Status status) final { - td->stickers_manager_->on_get_featured_sticker_sets_failed(-1, -1, 0, std::move(status)); + td_->stickers_manager_->on_get_featured_sticker_sets_failed(-1, -1, 0, std::move(status)); } }; @@ -328,11 +328,11 @@ class GetOldFeaturedStickerSetsQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(DEBUG) << "Receive result for GetOldFeaturedStickerSetsQuery: " << to_string(ptr); - td->stickers_manager_->on_get_featured_sticker_sets(offset_, limit_, generation_, std::move(ptr)); + td_->stickers_manager_->on_get_featured_sticker_sets(offset_, limit_, generation_, std::move(ptr)); } void on_error(Status status) final { - td->stickers_manager_->on_get_featured_sticker_sets_failed(offset_, limit_, generation_, std::move(status)); + td_->stickers_manager_->on_get_featured_sticker_sets_failed(offset_, limit_, generation_, std::move(status)); } }; @@ -359,16 +359,16 @@ class GetAttachedStickerSetsQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - td->stickers_manager_->on_get_attached_sticker_sets(file_id_, result_ptr.move_as_ok()); + td_->stickers_manager_->on_get_attached_sticker_sets(file_id_, result_ptr.move_as_ok()); promise_.set_value(Unit()); } void on_error(Status status) final { - if (!td->auth_manager_->is_bot() && FileReferenceManager::is_file_reference_error(status)) { + if (!td_->auth_manager_->is_bot() && FileReferenceManager::is_file_reference_error(status)) { VLOG(file_references) << "Receive " << status << " for " << file_id_; - td->file_manager_->delete_file_reference(file_id_, file_reference_); - td->file_reference_manager_->repair_file_reference( + td_->file_manager_->delete_file_reference(file_id_, file_reference_); + td_->file_reference_manager_->repair_file_reference( file_id_, PromiseCreator::lambda([file_id = file_id_, promise = std::move(promise_)](Result result) mutable { if (result.is_error()) { @@ -411,14 +411,14 @@ class GetRecentStickersQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(DEBUG) << "Receive result for get recent " << (is_attached_ ? "attached " : "") << "stickers: " << to_string(ptr); - td->stickers_manager_->on_get_recent_stickers(is_repair_, is_attached_, std::move(ptr)); + td_->stickers_manager_->on_get_recent_stickers(is_repair_, is_attached_, std::move(ptr)); } void on_error(Status status) final { if (!G()->is_expected_error(status)) { LOG(ERROR) << "Receive error for get recent " << (is_attached_ ? "attached " : "") << "stickers: " << status; } - td->stickers_manager_->on_get_recent_stickers_failed(is_repair_, is_attached_, std::move(status)); + td_->stickers_manager_->on_get_recent_stickers_failed(is_repair_, is_attached_, std::move(status)); } }; @@ -460,17 +460,17 @@ class SaveRecentStickerQuery final : public Td::ResultHandler { bool result = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for save recent " << (is_attached_ ? "attached " : "") << "sticker: " << result; if (!result) { - td->stickers_manager_->reload_recent_stickers(is_attached_, true); + td_->stickers_manager_->reload_recent_stickers(is_attached_, true); } promise_.set_value(Unit()); } void on_error(Status status) final { - if (!td->auth_manager_->is_bot() && FileReferenceManager::is_file_reference_error(status)) { + if (!td_->auth_manager_->is_bot() && FileReferenceManager::is_file_reference_error(status)) { VLOG(file_references) << "Receive " << status << " for " << file_id_; - td->file_manager_->delete_file_reference(file_id_, file_reference_); - td->file_reference_manager_->repair_file_reference( + td_->file_manager_->delete_file_reference(file_id_, file_reference_); + td_->file_reference_manager_->repair_file_reference( file_id_, PromiseCreator::lambda([sticker_id = file_id_, is_attached = is_attached_, unsave = unsave_, promise = std::move(promise_)](Result result) mutable { if (result.is_error()) { @@ -486,7 +486,7 @@ class SaveRecentStickerQuery final : public Td::ResultHandler { if (!G()->is_expected_error(status)) { LOG(ERROR) << "Receive error for save recent " << (is_attached_ ? "attached " : "") << "sticker: " << status; } - td->stickers_manager_->reload_recent_stickers(is_attached_, true); + td_->stickers_manager_->reload_recent_stickers(is_attached_, true); promise_.set_error(std::move(status)); } }; @@ -520,7 +520,7 @@ class ClearRecentStickersQuery final : public Td::ResultHandler { bool result = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for clear recent " << (is_attached_ ? "attached " : "") << "stickers: " << result; if (!result) { - td->stickers_manager_->reload_recent_stickers(is_attached_, true); + td_->stickers_manager_->reload_recent_stickers(is_attached_, true); } promise_.set_value(Unit()); @@ -530,7 +530,7 @@ class ClearRecentStickersQuery final : public Td::ResultHandler { if (!G()->is_expected_error(status)) { LOG(ERROR) << "Receive error for clear recent " << (is_attached_ ? "attached " : "") << "stickers: " << status; } - td->stickers_manager_->reload_recent_stickers(is_attached_, true); + td_->stickers_manager_->reload_recent_stickers(is_attached_, true); promise_.set_error(std::move(status)); } }; @@ -552,14 +552,14 @@ class GetFavedStickersQuery final : public Td::ResultHandler { } auto ptr = result_ptr.move_as_ok(); - td->stickers_manager_->on_get_favorite_stickers(is_repair_, std::move(ptr)); + td_->stickers_manager_->on_get_favorite_stickers(is_repair_, std::move(ptr)); } void on_error(Status status) final { if (!G()->is_expected_error(status)) { LOG(ERROR) << "Receive error for get favorite stickers: " << status; } - td->stickers_manager_->on_get_favorite_stickers_failed(is_repair_, std::move(status)); + td_->stickers_manager_->on_get_favorite_stickers_failed(is_repair_, std::move(status)); } }; @@ -593,17 +593,17 @@ class FaveStickerQuery final : public Td::ResultHandler { bool result = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for fave sticker: " << result; if (!result) { - td->stickers_manager_->reload_favorite_stickers(true); + td_->stickers_manager_->reload_favorite_stickers(true); } promise_.set_value(Unit()); } void on_error(Status status) final { - if (!td->auth_manager_->is_bot() && FileReferenceManager::is_file_reference_error(status)) { + if (!td_->auth_manager_->is_bot() && FileReferenceManager::is_file_reference_error(status)) { VLOG(file_references) << "Receive " << status << " for " << file_id_; - td->file_manager_->delete_file_reference(file_id_, file_reference_); - td->file_reference_manager_->repair_file_reference( + td_->file_manager_->delete_file_reference(file_id_, file_reference_); + td_->file_reference_manager_->repair_file_reference( file_id_, PromiseCreator::lambda([sticker_id = file_id_, unsave = unsave_, promise = std::move(promise_)](Result result) mutable { if (result.is_error()) { @@ -619,7 +619,7 @@ class FaveStickerQuery final : public Td::ResultHandler { if (!G()->is_expected_error(status)) { LOG(ERROR) << "Receive error for fave sticker: " << status; } - td->stickers_manager_->reload_favorite_stickers(true); + td_->stickers_manager_->reload_favorite_stickers(true); promise_.set_error(std::move(status)); } }; @@ -654,7 +654,7 @@ class ReorderStickerSetsQuery final : public Td::ResultHandler { if (!G()->is_expected_error(status)) { LOG(ERROR) << "Receive error for ReorderStickerSetsQuery: " << status; } - td->stickers_manager_->reload_installed_sticker_sets(is_masks_, true); + td_->stickers_manager_->reload_installed_sticker_sets(is_masks_, true); } }; @@ -696,14 +696,14 @@ class GetStickerSetQuery final : public Td::ResultHandler { } } - td->stickers_manager_->on_get_messages_sticker_set(sticker_set_id_, std::move(set), true, "GetStickerSetQuery"); + td_->stickers_manager_->on_get_messages_sticker_set(sticker_set_id_, std::move(set), true, "GetStickerSetQuery"); promise_.set_value(Unit()); } void on_error(Status status) final { LOG(INFO) << "Receive error for GetStickerSetQuery: " << status; - td->stickers_manager_->on_load_sticker_set_fail(sticker_set_id_, status); + td_->stickers_manager_->on_load_sticker_set_fail(sticker_set_id_, status); promise_.set_error(std::move(status)); } }; @@ -723,10 +723,10 @@ class ReloadSpecialStickerSetQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - auto sticker_set_id = td->stickers_manager_->on_get_messages_sticker_set(StickerSetId(), result_ptr.move_as_ok(), - true, "ReloadSpecialStickerSetQuery"); + auto sticker_set_id = td_->stickers_manager_->on_get_messages_sticker_set(StickerSetId(), result_ptr.move_as_ok(), + true, "ReloadSpecialStickerSetQuery"); if (sticker_set_id.is_valid()) { - td->stickers_manager_->on_get_special_sticker_set(type_, sticker_set_id); + td_->stickers_manager_->on_get_special_sticker_set(type_, sticker_set_id); } else { on_error(Status::Error(500, "Failed to add special sticker set")); } @@ -734,7 +734,7 @@ class ReloadSpecialStickerSetQuery final : public Td::ResultHandler { void on_error(Status status) final { LOG(WARNING) << "Receive error for ReloadSpecialStickerSetQuery: " << status; - td->stickers_manager_->on_load_special_sticker_set(type_, std::move(status)); + td_->stickers_manager_->on_load_special_sticker_set(type_, std::move(status)); } }; @@ -756,14 +756,14 @@ class SearchStickerSetsQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for search sticker sets: " << to_string(ptr); - td->stickers_manager_->on_find_sticker_sets_success(query_, std::move(ptr)); + td_->stickers_manager_->on_find_sticker_sets_success(query_, std::move(ptr)); } void on_error(Status status) final { if (!G()->is_expected_error(status)) { LOG(ERROR) << "Receive error for search sticker sets: " << status; } - td->stickers_manager_->on_find_sticker_sets_fail(query_, std::move(status)); + td_->stickers_manager_->on_find_sticker_sets_fail(query_, std::move(status)); } }; @@ -789,7 +789,7 @@ class InstallStickerSetQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - td->stickers_manager_->on_install_sticker_set(set_id_, is_archived_, result_ptr.move_as_ok()); + td_->stickers_manager_->on_install_sticker_set(set_id_, is_archived_, result_ptr.move_as_ok()); promise_.set_value(Unit()); } @@ -823,7 +823,7 @@ class UninstallStickerSetQuery final : public Td::ResultHandler { if (!result) { LOG(WARNING) << "Receive false in result to uninstallStickerSet"; } else { - td->stickers_manager_->on_uninstall_sticker_set(set_id_); + td_->stickers_manager_->on_uninstall_sticker_set(set_id_); } promise_.set_value(Unit()); @@ -857,7 +857,7 @@ class ReadFeaturedStickerSetsQuery final : public Td::ResultHandler { if (!G()->is_expected_error(status)) { LOG(ERROR) << "Receive error for ReadFeaturedStickerSetsQuery: " << status; } - td->stickers_manager_->reload_featured_sticker_sets(true); + td_->stickers_manager_->reload_featured_sticker_sets(true); } }; @@ -886,7 +886,7 @@ class UploadStickerFileQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - td->stickers_manager_->on_uploaded_sticker_file(file_id_, result_ptr.move_as_ok(), std::move(promise_)); + td_->stickers_manager_->on_uploaded_sticker_file(file_id_, result_ptr.move_as_ok(), std::move(promise_)); } void on_error(Status status) final { @@ -894,17 +894,17 @@ class UploadStickerFileQuery final : public Td::ResultHandler { if (was_uploaded_) { CHECK(file_id_.is_valid()); if (begins_with(status.message(), "FILE_PART_") && ends_with(status.message(), "_MISSING")) { - // TODO td->stickers_manager_->on_upload_sticker_file_part_missing(file_id_, to_integer(status.message().substr(10))); + // TODO td_->stickers_manager_->on_upload_sticker_file_part_missing(file_id_, to_integer(status.message().substr(10))); // return; } else { if (status.code() != 429 && status.code() < 500 && !G()->close_flag()) { - td->file_manager_->delete_partial_remote_location(file_id_); + td_->file_manager_->delete_partial_remote_location(file_id_); } } } else if (FileReferenceManager::is_file_reference_error(status)) { LOG(ERROR) << "Receive file reference error for UploadStickerFileQuery"; } - td->file_manager_->cancel_upload(file_id_); + td_->file_manager_->cancel_upload(file_id_); promise_.set_error(std::move(status)); } }; @@ -996,8 +996,8 @@ class CreateNewStickerSetQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - td->stickers_manager_->on_get_messages_sticker_set(StickerSetId(), result_ptr.move_as_ok(), true, - "CreateNewStickerSetQuery"); + td_->stickers_manager_->on_get_messages_sticker_set(StickerSetId(), result_ptr.move_as_ok(), true, + "CreateNewStickerSetQuery"); promise_.set_value(Unit()); } @@ -1026,8 +1026,8 @@ class AddStickerToSetQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - td->stickers_manager_->on_get_messages_sticker_set(StickerSetId(), result_ptr.move_as_ok(), true, - "AddStickerToSetQuery"); + td_->stickers_manager_->on_get_messages_sticker_set(StickerSetId(), result_ptr.move_as_ok(), true, + "AddStickerToSetQuery"); promise_.set_value(Unit()); } @@ -1056,8 +1056,8 @@ class SetStickerSetThumbnailQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - td->stickers_manager_->on_get_messages_sticker_set(StickerSetId(), result_ptr.move_as_ok(), true, - "SetStickerSetThumbnailQuery"); + td_->stickers_manager_->on_get_messages_sticker_set(StickerSetId(), result_ptr.move_as_ok(), true, + "SetStickerSetThumbnailQuery"); promise_.set_value(Unit()); } @@ -1086,8 +1086,8 @@ class SetStickerPositionQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - td->stickers_manager_->on_get_messages_sticker_set(StickerSetId(), result_ptr.move_as_ok(), true, - "SetStickerPositionQuery"); + td_->stickers_manager_->on_get_messages_sticker_set(StickerSetId(), result_ptr.move_as_ok(), true, + "SetStickerPositionQuery"); promise_.set_value(Unit()); } @@ -1115,8 +1115,8 @@ class DeleteStickerFromSetQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - td->stickers_manager_->on_get_messages_sticker_set(StickerSetId(), result_ptr.move_as_ok(), true, - "DeleteStickerFromSetQuery"); + td_->stickers_manager_->on_get_messages_sticker_set(StickerSetId(), result_ptr.move_as_ok(), true, + "DeleteStickerFromSetQuery"); promise_.set_value(Unit()); } @@ -1154,11 +1154,11 @@ class SendAnimatedEmojiClicksQuery final : public Td::ResultHandler { } void on_error(Status status) final { - if (!td->messages_manager_->on_get_dialog_error(dialog_id_, status, "SendAnimatedEmojiClicksQuery")) { + if (!td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "SendAnimatedEmojiClicksQuery")) { LOG(INFO) << "Receive error for send animated emoji clicks: " << status; } - td->stickers_manager_->on_send_animated_emoji_clicks(dialog_id_, emoji_); + td_->stickers_manager_->on_send_animated_emoji_clicks(dialog_id_, emoji_); } }; diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 474df11ec..cc5c7d391 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -153,13 +153,13 @@ namespace td { int VERBOSITY_NAME(td_init) = VERBOSITY_NAME(DEBUG) + 3; int VERBOSITY_NAME(td_requests) = VERBOSITY_NAME(INFO); -void Td::ResultHandler::set_td(Td *new_td) { - CHECK(td == nullptr); - td = new_td; +void Td::ResultHandler::set_td(Td *td) { + CHECK(td_ == nullptr); + td_ = td; } void Td::ResultHandler::send_query(NetQueryPtr query) { - td->add_handler(query->id(), shared_from_this()); + td_->add_handler(query->id(), shared_from_this()); send(std::move(query)); } @@ -208,8 +208,8 @@ class GetRecentMeUrlsQuery final : public Td::ResultHandler { } auto urls_full = result_ptr.move_as_ok(); - td->contacts_manager_->on_get_users(std::move(urls_full->users_), "GetRecentMeUrlsQuery"); - td->contacts_manager_->on_get_chats(std::move(urls_full->chats_), "GetRecentMeUrlsQuery"); + td_->contacts_manager_->on_get_users(std::move(urls_full->users_), "GetRecentMeUrlsQuery"); + td_->contacts_manager_->on_get_chats(std::move(urls_full->chats_), "GetRecentMeUrlsQuery"); auto urls = std::move(urls_full->urls_); auto results = make_tl_object(); @@ -228,7 +228,7 @@ class GetRecentMeUrlsQuery final : public Td::ResultHandler { break; } result->type_ = make_tl_object( - td->contacts_manager_->get_user_id_object(user_id, "tMeUrlTypeUser")); + td_->contacts_manager_->get_user_id_object(user_id, "tMeUrlTypeUser")); break; } case telegram_api::recentMeUrlChat::ID: { @@ -241,15 +241,15 @@ class GetRecentMeUrlsQuery final : public Td::ResultHandler { break; } result->type_ = make_tl_object( - td->contacts_manager_->get_supergroup_id_object(channel_id, "tMeUrlTypeSupergroup")); + td_->contacts_manager_->get_supergroup_id_object(channel_id, "tMeUrlTypeSupergroup")); break; } case telegram_api::recentMeUrlChatInvite::ID: { auto url = move_tl_object_as(url_ptr); result->url_ = std::move(url->url_); - td->contacts_manager_->on_get_dialog_invite_link_info(result->url_, std::move(url->chat_invite_), - Promise()); - auto info_object = td->contacts_manager_->get_chat_invite_link_info_object(result->url_); + td_->contacts_manager_->on_get_dialog_invite_link_info(result->url_, std::move(url->chat_invite_), + Promise()); + auto info_object = td_->contacts_manager_->get_chat_invite_link_info_object(result->url_); if (info_object == nullptr) { result = nullptr; break; @@ -261,7 +261,7 @@ class GetRecentMeUrlsQuery final : public Td::ResultHandler { auto url = move_tl_object_as(url_ptr); result->url_ = std::move(url->url_); auto sticker_set_id = - td->stickers_manager_->on_get_sticker_set_covered(std::move(url->set_), false, "recentMeUrlStickerSet"); + td_->stickers_manager_->on_get_sticker_set_covered(std::move(url->set_), false, "recentMeUrlStickerSet"); if (!sticker_set_id.is_valid()) { LOG(ERROR) << "Receive invalid sticker set"; result = nullptr; @@ -392,7 +392,7 @@ class UpdateStatusQuery final : public Td::ResultHandler { bool result = result_ptr.ok(); LOG(INFO) << "UpdateStatus returned " << result; - td->on_update_status_success(!is_offline_); + td_->on_update_status_success(!is_offline_); } void on_error(Status status) final { diff --git a/td/telegram/Td.h b/td/telegram/Td.h index c8b8dccde..e94a1cb1a 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -221,10 +221,10 @@ class Td final : public Actor { protected: void send_query(NetQueryPtr query); - Td *td = nullptr; + Td *td_ = nullptr; private: - void set_td(Td *new_td); + void set_td(Td *td); }; template diff --git a/td/telegram/TopDialogManager.cpp b/td/telegram/TopDialogManager.cpp index 7cfb85e45..9f2de0bff 100644 --- a/td/telegram/TopDialogManager.cpp +++ b/td/telegram/TopDialogManager.cpp @@ -100,7 +100,7 @@ class ResetTopPeerRatingQuery final : public Td::ResultHandler { public: void send(TopDialogCategory category, DialogId dialog_id) { - auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); + auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); if (input_peer == nullptr) { return; } @@ -120,7 +120,7 @@ class ResetTopPeerRatingQuery final : public Td::ResultHandler { } void on_error(Status status) final { - if (!td->messages_manager_->on_get_dialog_error(dialog_id_, status, "ResetTopPeerRatingQuery")) { + if (!td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "ResetTopPeerRatingQuery")) { LOG(INFO) << "Receive error for ResetTopPeerRatingQuery: " << status; } } diff --git a/td/telegram/WebPagesManager.cpp b/td/telegram/WebPagesManager.cpp index ee7023ec7..e10474e8c 100644 --- a/td/telegram/WebPagesManager.cpp +++ b/td/telegram/WebPagesManager.cpp @@ -84,11 +84,11 @@ class GetWebPagePreviewQuery final : public Td::ResultHandler { auto ptr = result_ptr.move_as_ok(); LOG(INFO) << "Receive result for GetWebPagePreviewQuery: " << to_string(ptr); - td->web_pages_manager_->on_get_web_page_preview_success(request_id_, url_, std::move(ptr), std::move(promise_)); + td_->web_pages_manager_->on_get_web_page_preview_success(request_id_, url_, std::move(ptr), std::move(promise_)); } void on_error(Status status) final { - td->web_pages_manager_->on_get_web_page_preview_fail(request_id_, url_, std::move(status), std::move(promise_)); + td_->web_pages_manager_->on_get_web_page_preview_fail(request_id_, url_, std::move(status), std::move(promise_)); } }; @@ -121,15 +121,15 @@ class GetWebPageQuery final : public Td::ResultHandler { int32 view_count = (web_page->flags_ & telegram_api::webPageNotModified::CACHED_PAGE_VIEWS_MASK) != 0 ? web_page->cached_page_views_ : 0; - td->web_pages_manager_->on_get_web_page_instant_view_view_count(web_page_id_, view_count); + td_->web_pages_manager_->on_get_web_page_instant_view_view_count(web_page_id_, view_count); return promise_.set_value(std::move(web_page_id_)); } else { LOG(ERROR) << "Receive webPageNotModified for " << url_; return on_error(Status::Error(500, "Receive webPageNotModified")); } } - auto web_page_id = td->web_pages_manager_->on_get_web_page(std::move(ptr), DialogId()); - td->web_pages_manager_->on_get_web_page_by_url(url_, web_page_id, false); + auto web_page_id = td_->web_pages_manager_->on_get_web_page(std::move(ptr), DialogId()); + td_->web_pages_manager_->on_get_web_page_by_url(url_, web_page_id, false); promise_.set_value(std::move(web_page_id)); } diff --git a/td/telegram/net/NetActor.cpp b/td/telegram/net/NetActor.cpp index 6877e6096..d47ab654d 100644 --- a/td/telegram/net/NetActor.cpp +++ b/td/telegram/net/NetActor.cpp @@ -12,7 +12,7 @@ namespace td { -NetActor::NetActor() : td(static_cast(G()->td().get_actor_unsafe())) { +NetActor::NetActor() : td_(static_cast(G()->td().get_actor_unsafe())) { } void NetActor::set_parent(ActorShared<> parent) { diff --git a/td/telegram/net/NetActor.h b/td/telegram/net/NetActor.h index 7be4edef7..823d325d4 100644 --- a/td/telegram/net/NetActor.h +++ b/td/telegram/net/NetActor.h @@ -39,9 +39,10 @@ class NetActor : public NetQueryCallback { } protected: + Td *td_; ActorShared<> parent_; + void send_query(NetQueryPtr query); - Td *td; }; class NetActorOnce : public NetActor {