Improve ResultHandler/NetActor td_ private field name.

This commit is contained in:
levlam 2021-11-08 15:20:38 +03:00
parent 776635e8c5
commit 616b0e6d6f
22 changed files with 842 additions and 837 deletions

View File

@ -56,14 +56,14 @@ class GetSavedGifsQuery final : public Td::ResultHandler {
} }
auto ptr = result_ptr.move_as_ok(); 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 { void on_error(Status status) final {
if (!G()->is_expected_error(status)) { if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for get saved animations: " << 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(); bool result = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for save GIF: " << result; LOG(INFO) << "Receive result for save GIF: " << result;
if (!result) { if (!result) {
td->animations_manager_->reload_saved_animations(true); td_->animations_manager_->reload_saved_animations(true);
} }
promise_.set_value(Unit()); promise_.set_value(Unit());
} }
void on_error(Status status) final { 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_; VLOG(file_references) << "Receive " << status << " for " << file_id_;
td->file_manager_->delete_file_reference(file_id_, file_reference_); td_->file_manager_->delete_file_reference(file_id_, file_reference_);
td->file_reference_manager_->repair_file_reference( td_->file_reference_manager_->repair_file_reference(
file_id_, PromiseCreator::lambda([animation_id = file_id_, unsave = unsave_, file_id_, PromiseCreator::lambda([animation_id = file_id_, unsave = unsave_,
promise = std::move(promise_)](Result<Unit> result) mutable { promise = std::move(promise_)](Result<Unit> result) mutable {
if (result.is_error()) { if (result.is_error()) {
@ -122,7 +122,7 @@ class SaveGifQuery final : public Td::ResultHandler {
if (!G()->is_expected_error(status)) { if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for save GIF: " << 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)); promise_.set_error(std::move(status));
} }
}; };

View File

@ -56,7 +56,7 @@ AuthManager::AuthManager(int32 api_id, const string &api_hash, ActorShared<> par
} else { } else {
LOG(ERROR) << "Restore unknown my_id"; LOG(ERROR) << "Restore unknown my_id";
ContactsManager::send_get_me_query( ContactsManager::send_get_me_query(
td, PromiseCreator::lambda([this](Result<Unit> result) { update_state(State::Ok); })); td_, PromiseCreator::lambda([this](Result<Unit> result) { update_state(State::Ok); }));
} }
} else if (auth_str == "logout") { } else if (auth_str == "logout") {
LOG(WARNING) << "Continue to log out"; 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; login_token_expires_at_ = login_token_expires_at;
poll_export_login_code_timeout_.cancel_timeout(); 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(std::move(on_update_login_token_static));
poll_export_login_code_timeout_.set_callback_data(static_cast<void *>(td)); poll_export_login_code_timeout_.set_callback_data(static_cast<void *>(td_));
poll_export_login_code_timeout_.set_timeout_at(login_token_expires_at_); poll_export_login_code_timeout_.set_timeout_at(login_token_expires_at_);
} }
@ -763,9 +763,9 @@ void AuthManager::on_get_authorization(tl_object_ptr<telegram_api::auth_Authoriz
new_password_.clear(); new_password_.clear();
new_hint_.clear(); new_hint_.clear();
state_ = State::Ok; state_ = State::Ok;
td->contacts_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); 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"; LOG(ERROR) << "Server doesn't send proper authorization";
if (query_id_ != 0) { if (query_id_ != 0) {
on_query_error(Status::Error(500, "Server doesn't send proper authorization")); on_query_error(Status::Error(500, "Server doesn't send proper authorization"));
@ -776,19 +776,19 @@ void AuthManager::on_get_authorization(tl_object_ptr<telegram_api::auth_Authoriz
if ((auth->flags_ & telegram_api::auth_authorization::TMP_SESSIONS_MASK) != 0) { if ((auth->flags_ & telegram_api::auth_authorization::TMP_SESSIONS_MASK) != 0) {
G()->shared_config().set_option_integer("session_count", auth->tmp_sessions_); G()->shared_config().set_option_integer("session_count", auth->tmp_sessions_);
} }
td->messages_manager_->on_authorization_success(); td_->messages_manager_->on_authorization_success();
td->notification_manager_->init(); td_->notification_manager_->init();
td->stickers_manager_->init(); td_->stickers_manager_->init();
td->theme_manager_->init(); td_->theme_manager_->init();
td->top_dialog_manager_->init(); td_->top_dialog_manager_->init();
td->updates_manager_->get_difference("on_get_authorization"); td_->updates_manager_->get_difference("on_get_authorization");
td->on_online_updated(false, true); td_->on_online_updated(false, true);
if (!is_bot()) { if (!is_bot()) {
td->schedule_get_terms_of_service(0); td_->schedule_get_terms_of_service(0);
td->schedule_get_promo_data(0); td_->schedule_get_promo_data(0);
G()->td_db()->get_binlog_pmc()->set("fetched_marks_as_unread", "1"); G()->td_db()->get_binlog_pmc()->set("fetched_marks_as_unread", "1");
} else { } else {
td->set_is_bot_online(true); td_->set_is_bot_online(true);
} }
send_closure(G()->config_manager(), &ConfigManager::request_config); send_closure(G()->config_manager(), &ConfigManager::request_config);
if (query_id_ != 0) { if (query_id_ != 0) {

View File

@ -60,7 +60,7 @@ class GetBackgroundQuery final : public Td::ResultHandler {
return on_error(result_ptr.move_as_error()); 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()); promise_.set_value(Unit());
} }
@ -151,7 +151,7 @@ class UploadBackgroundQuery final : public Td::ResultHandler {
return on_error(result_ptr.move_as_error()); 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(), td_->background_manager_->on_uploaded_background_file(file_id_, type_, for_dark_theme_, result_ptr.move_as_ok(),
std::move(promise_)); std::move(promise_));
} }
@ -159,14 +159,14 @@ class UploadBackgroundQuery final : public Td::ResultHandler {
CHECK(status.is_error()); CHECK(status.is_error());
CHECK(file_id_.is_valid()); CHECK(file_id_.is_valid());
if (begins_with(status.message(), "FILE_PART_") && ends_with(status.message(), "_MISSING")) { 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<int32>(status.message().substr(10))); // TODO td_->background_manager_->on_upload_background_file_part_missing(file_id_, to_integer<int32>(status.message().substr(10)));
// return; // return;
} else { } else {
if (status.code() != 429 && status.code() < 500 && !G()->close_flag()) { 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)); promise_.set_error(std::move(status));
} }
}; };

View File

@ -31,7 +31,7 @@ class SetBotCommandsQuery final : public Td::ResultHandler {
void send(BotCommandScope scope, const string &language_code, vector<BotCommand> &&commands) { void send(BotCommandScope scope, const string &language_code, vector<BotCommand> &&commands) {
send_query(G()->net_query_creator().create(telegram_api::bots_setBotCommands( 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(); })))); 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) { void send(BotCommandScope scope, const string &language_code) {
send_query(G()->net_query_creator().create( 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 { void on_result(BufferSlice packet) final {
@ -88,7 +88,7 @@ class GetBotCommandsQuery final : public Td::ResultHandler {
void send(BotCommandScope scope, const string &language_code) { void send(BotCommandScope scope, const string &language_code) {
send_query(G()->net_query_creator().create( 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 { void on_result(BufferSlice packet) final {
@ -97,8 +97,8 @@ class GetBotCommandsQuery final : public Td::ResultHandler {
return on_error(result_ptr.move_as_error()); return on_error(result_ptr.move_as_error());
} }
BotCommands commands(td->contacts_manager_->get_my_id(), result_ptr.move_as_ok()); BotCommands commands(td_->contacts_manager_->get_my_id(), result_ptr.move_as_ok());
promise_.set_value(commands.get_bot_commands_object(td)); promise_.set_value(commands.get_bot_commands_object(td_));
} }
void on_error(Status status) final { void on_error(Status status) final {

View File

@ -41,7 +41,7 @@ class GetBotCallbackAnswerQuery final : public Td::ResultHandler {
dialog_id_ = dialog_id; dialog_id_ = dialog_id;
message_id_ = message_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); CHECK(input_peer != nullptr);
int32 flags = 0; int32 flags = 0;
@ -85,15 +85,15 @@ class GetBotCallbackAnswerQuery final : public Td::ResultHandler {
void on_error(Status status) final { void on_error(Status status) final {
if (status.message() == "DATA_INVALID" || status.message() == "MESSAGE_ID_INVALID") { 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") { } else if (status.message() == "BOT_RESPONSE_TIMEOUT") {
status = Status::Error(502, "The bot is not responding"); 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_api::callbackQueryAnswer>()); return promise_.set_value(td_api::make_object<td_api::callbackQueryAnswer>());
} }
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)); promise_.set_error(std::move(status));
} }
}; };

File diff suppressed because it is too large Load Diff

View File

@ -48,7 +48,7 @@ class SetGameScoreActor final : public NetActorOnce {
dialog_id_ = dialog_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) { if (input_peer == nullptr) {
on_error(Status::Error(400, "Can't access the chat")); on_error(Status::Error(400, "Can't access the chat"));
stop(); stop();
@ -63,7 +63,7 @@ class SetGameScoreActor final : public NetActorOnce {
LOG(INFO) << "Set game score to " << score; LOG(INFO) << "Set game score to " << score;
query->debug("send to MultiSequenceDispatcher"); 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); 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(); auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for SetGameScore: " << to_string(ptr); 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 { void on_error(Status status) final {
LOG(INFO) << "Receive error for SetGameScore: " << status; 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)); 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<telegram_api::InputUser> input_user) { void send(DialogId dialog_id, MessageId message_id, tl_object_ptr<telegram_api::InputUser> input_user) {
dialog_id_ = 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); CHECK(input_peer != nullptr);
CHECK(input_user != nullptr); CHECK(input_user != nullptr);
@ -155,11 +155,11 @@ class GetGameHighScoresQuery final : public Td::ResultHandler {
return on_error(result_ptr.move_as_error()); 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 { 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)); promise_.set_error(std::move(status));
} }
}; };
@ -189,7 +189,7 @@ class GetInlineGameHighScoresQuery final : public Td::ResultHandler {
return on_error(result_ptr.move_as_error()); 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 { void on_error(Status status) final {

View File

@ -84,7 +84,7 @@ class GetGroupCallJoinAsQuery final : public Td::ResultHandler {
void send(DialogId dialog_id) { void send(DialogId dialog_id) {
dialog_id_ = 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); CHECK(input_peer != nullptr);
send_query(G()->net_query_creator().create(telegram_api::phone_getGroupCallJoinAs(std::move(input_peer)))); 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(); auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for GetGroupCallJoinAsQuery: " << to_string(ptr); 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_users(std::move(ptr->users_), "GetGroupCallJoinAsQuery");
td->contacts_manager_->on_get_chats(std::move(ptr->chats_), "GetGroupCallJoinAsQuery"); td_->contacts_manager_->on_get_chats(std::move(ptr->chats_), "GetGroupCallJoinAsQuery");
vector<td_api::object_ptr<td_api::MessageSender>> participant_aliaces; vector<td_api::object_ptr<td_api::MessageSender>> participant_aliaces;
for (auto &peer : ptr->peers_) { for (auto &peer : ptr->peers_) {
@ -110,11 +110,11 @@ class GetGroupCallJoinAsQuery final : public Td::ResultHandler {
continue; continue;
} }
if (dialog_id.get_type() != DialogType::User) { 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( 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<td_api::messageSenders>(static_cast<int32>(participant_aliaces.size()), promise_.set_value(td_api::make_object<td_api::messageSenders>(static_cast<int32>(participant_aliaces.size()),
@ -122,7 +122,7 @@ class GetGroupCallJoinAsQuery final : public Td::ResultHandler {
} }
void on_error(Status status) final { 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)); 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) { 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); 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); CHECK(as_input_peer != nullptr);
send_query(G()->net_query_creator().create( send_query(G()->net_query_creator().create(
@ -158,7 +158,7 @@ class SaveDefaultGroupCallJoinAsQuery final : public Td::ResultHandler {
} }
void on_error(Status status) final { 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)); 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) { void send(DialogId dialog_id, const string &title, int32 start_date) {
dialog_id_ = 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); CHECK(input_peer != nullptr);
int32 flags = 0; int32 flags = 0;
@ -197,7 +197,7 @@ class CreateGroupCallQuery final : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok(); auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for CreateGroupCallQuery: " << to_string(ptr); 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()) { if (group_call_ids.empty()) {
LOG(ERROR) << "Receive wrong CreateGroupCallQuery response " << to_string(ptr); LOG(ERROR) << "Receive wrong CreateGroupCallQuery response " << to_string(ptr);
return on_error(Status::Error(500, "Receive wrong response")); 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 { std::move(ptr), PromiseCreator::lambda([promise = std::move(promise_), group_call_id](Unit) mutable {
promise.set_value(std::move(group_call_id)); promise.set_value(std::move(group_call_id));
})); }));
} }
void on_error(Status status) final { 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)); promise_.set_error(std::move(status));
} }
}; };
@ -274,7 +274,7 @@ class GetGroupCallParticipantQuery final : public Td::ResultHandler {
return on_error(result_ptr.move_as_error()); 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, td_->group_call_manager_->on_get_group_call_participants(input_group_call_id_, result_ptr.move_as_ok(), false,
string()); string());
promise_.set_value(Unit()); promise_.set_value(Unit());
@ -308,7 +308,7 @@ class GetGroupCallParticipantsQuery final : public Td::ResultHandler {
return on_error(result_ptr.move_as_error()); 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, td_->group_call_manager_->on_get_group_call_participants(input_group_call_id_, result_ptr.move_as_ok(), true,
offset_); offset_);
promise_.set_value(Unit()); promise_.set_value(Unit());
@ -339,7 +339,7 @@ class StartScheduledGroupCallQuery final : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok(); auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for StartScheduledGroupCallQuery: " << to_string(ptr); 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 { void on_error(Status status) final {
@ -369,7 +369,7 @@ class JoinGroupCallQuery final : public Td::ResultHandler {
tl_object_ptr<telegram_api::InputPeer> join_as_input_peer; tl_object_ptr<telegram_api::InputPeer> join_as_input_peer;
if (as_dialog_id.is_valid()) { 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 { } else {
join_as_input_peer = make_tl_object<telegram_api::inputPeerSelf>(); join_as_input_peer = make_tl_object<telegram_api::inputPeerSelf>();
} }
@ -401,7 +401,7 @@ class JoinGroupCallQuery final : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok(); auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for JoinGroupCallQuery with generation " << generation_ << ": " << to_string(ptr); 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), td_->group_call_manager_->process_join_group_call_response(input_group_call_id_, generation_, std::move(ptr),
std::move(promise_)); std::move(promise_));
} }
@ -435,12 +435,12 @@ class JoinGroupCallPresentationQuery final : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok(); auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for JoinGroupCallPresentationQuery with generation " << generation_ << ": " LOG(INFO) << "Receive result for JoinGroupCallPresentationQuery with generation " << generation_ << ": "
<< to_string(ptr); << to_string(ptr);
td->group_call_manager_->process_join_group_call_presentation_response(input_group_call_id_, generation_, td_->group_call_manager_->process_join_group_call_presentation_response(input_group_call_id_, generation_,
std::move(ptr), Status::OK()); std::move(ptr), Status::OK());
} }
void on_error(Status status) final { void on_error(Status status) final {
td->group_call_manager_->process_join_group_call_presentation_response(input_group_call_id_, generation_, nullptr, td_->group_call_manager_->process_join_group_call_presentation_response(input_group_call_id_, generation_, nullptr,
std::move(status)); std::move(status));
} }
}; };
@ -465,7 +465,7 @@ class LeaveGroupCallPresentationQuery final : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok(); auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for LeaveGroupCallPresentationQuery: " << to_string(ptr); 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 { void on_error(Status status) final {
@ -497,7 +497,7 @@ class EditGroupCallTitleQuery final : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok(); auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for EditGroupCallTitleQuery: " << to_string(ptr); 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 { void on_error(Status status) final {
@ -529,7 +529,7 @@ class ToggleGroupCallStartSubscriptionQuery final : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok(); auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for ToggleGroupCallStartSubscriptionQuery: " << to_string(ptr); 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 { void on_error(Status status) final {
@ -561,7 +561,7 @@ class ToggleGroupCallSettingsQuery final : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok(); auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for ToggleGroupCallSettingsQuery: " << to_string(ptr); 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 { void on_error(Status status) final {
@ -593,7 +593,7 @@ class InviteToGroupCallQuery final : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok(); auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for InviteToGroupCallQuery: " << to_string(ptr); 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 { void on_error(Status status) final {
@ -664,7 +664,7 @@ class ToggleGroupCallRecordQuery final : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok(); auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for ToggleGroupCallRecordQuery: " << to_string(ptr); 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 { 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, 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 set_video_is_paused, bool video_is_paused, bool set_presentation_is_paused,
bool 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) { if (input_peer == nullptr) {
return on_error(Status::Error(400, "Can't access the chat")); 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(); auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for EditGroupCallParticipantQuery: " << to_string(ptr); 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 { void on_error(Status status) final {
@ -784,7 +784,7 @@ class LeaveGroupCallQuery final : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok(); auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for LeaveGroupCallQuery: " << to_string(ptr); 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 { void on_error(Status status) final {
@ -812,7 +812,7 @@ class DiscardGroupCallQuery final : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok(); auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for DiscardGroupCallQuery: " << to_string(ptr); 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 { void on_error(Status status) final {

View File

@ -95,7 +95,7 @@ class GetInlineBotResultsQuery final : public Td::ResultHandler {
return on_error(result_ptr.move_as_error()); return on_error(result_ptr.move_as_error());
} }
td->inline_queries_manager_->on_get_inline_query_results(dialog_id_, bot_user_id_, query_hash_, td_->inline_queries_manager_->on_get_inline_query_results(dialog_id_, bot_user_id_, query_hash_,
result_ptr.move_as_ok()); result_ptr.move_as_ok());
promise_.set_value(Unit()); promise_.set_value(Unit());
} }
@ -108,7 +108,7 @@ class GetInlineBotResultsQuery final : public Td::ResultHandler {
} }
LOG(INFO) << "Inline query returned error " << status; 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)); promise_.set_error(std::move(status));
} }
}; };

View File

@ -440,7 +440,7 @@ class RequestUrlAuthQuery final : public Td::ResultHandler {
tl_object_ptr<telegram_api::InputPeer> input_peer; tl_object_ptr<telegram_api::InputPeer> input_peer;
if (full_message_id.get_dialog_id().is_valid()) { if (full_message_id.get_dialog_id().is_valid()) {
dialog_id_ = full_message_id.get_dialog_id(); 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); CHECK(input_peer != nullptr);
flags |= telegram_api::messages_requestUrlAuth::PEER_MASK; flags |= telegram_api::messages_requestUrlAuth::PEER_MASK;
} else { } else {
@ -466,9 +466,9 @@ class RequestUrlAuthQuery final : public Td::ResultHandler {
if (!bot_user_id.is_valid()) { if (!bot_user_id.is_valid()) {
return on_error(Status::Error(500, "Receive invalid bot_user_id")); 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<td_api::loginUrlInfoRequestConfirmation>( promise_.set_value(td_api::make_object<td_api::loginUrlInfoRequestConfirmation>(
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_)); request->request_write_access_));
break; break;
} }
@ -485,7 +485,7 @@ class RequestUrlAuthQuery final : public Td::ResultHandler {
void on_error(Status status) final { void on_error(Status status) final {
if (!dialog_id_.is_valid() || 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; LOG(INFO) << "RequestUrlAuthQuery returned " << status;
} }
promise_.set_value(td_api::make_object<td_api::loginUrlInfoOpen>(url_, false)); promise_.set_value(td_api::make_object<td_api::loginUrlInfoOpen>(url_, false));
@ -507,7 +507,7 @@ class AcceptUrlAuthQuery final : public Td::ResultHandler {
tl_object_ptr<telegram_api::InputPeer> input_peer; tl_object_ptr<telegram_api::InputPeer> input_peer;
if (full_message_id.get_dialog_id().is_valid()) { if (full_message_id.get_dialog_id().is_valid()) {
dialog_id_ = full_message_id.get_dialog_id(); 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); CHECK(input_peer != nullptr);
flags |= telegram_api::messages_acceptUrlAuth::PEER_MASK; flags |= telegram_api::messages_acceptUrlAuth::PEER_MASK;
} else { } else {
@ -546,7 +546,7 @@ class AcceptUrlAuthQuery final : public Td::ResultHandler {
void on_error(Status status) final { void on_error(Status status) final {
if (!dialog_id_.is_valid() || 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; LOG(INFO) << "AcceptUrlAuthQuery returned " << status;
} }
promise_.set_error(std::move(status)); promise_.set_error(std::move(status));

File diff suppressed because it is too large Load Diff

View File

@ -113,7 +113,7 @@ class GetContactSignUpNotificationQuery final : public Td::ResultHandler {
return on_error(result_ptr.move_as_error()); 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()); promise_.set_value(Unit());
} }

View File

@ -270,7 +270,7 @@ class GetPaymentFormQuery final : public Td::ResultHandler {
void send(DialogId dialog_id, ServerMessageId server_message_id, void send(DialogId dialog_id, ServerMessageId server_message_id,
tl_object_ptr<telegram_api::dataJSON> &&theme_parameters) { tl_object_ptr<telegram_api::dataJSON> &&theme_parameters) {
dialog_id_ = 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);
if (input_peer == nullptr) { if (input_peer == nullptr) {
return on_error(Status::Error(400, "Can't access the chat")); 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(); auto payment_form = result_ptr.move_as_ok();
LOG(INFO) << "Receive payment form: " << to_string(payment_form); 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_); UserId payments_provider_user_id(payment_form->provider_id_);
if (!payments_provider_user_id.is_valid()) { if (!payments_provider_user_id.is_valid()) {
@ -308,15 +308,15 @@ class GetPaymentFormQuery final : public Td::ResultHandler {
bool need_password = payment_form->password_missing_; bool need_password = payment_form->password_missing_;
promise_.set_value(make_tl_object<td_api::paymentForm>( promise_.set_value(make_tl_object<td_api::paymentForm>(
payment_form->form_id_, convert_invoice(std::move(payment_form->invoice_)), std::move(payment_form->url_), 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(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(payments_provider_user_id, "paymentForm provider"),
convert_payment_provider(payment_form->native_provider_, std::move(payment_form->native_params_)), convert_payment_provider(payment_form->native_provider_, std::move(payment_form->native_params_)),
convert_order_info(std::move(payment_form->saved_info_)), convert_order_info(std::move(payment_form->saved_info_)),
convert_saved_credentials(std::move(payment_form->saved_credentials_)), can_save_credentials, need_password)); convert_saved_credentials(std::move(payment_form->saved_credentials_)), can_save_credentials, need_password));
} }
void on_error(Status status) final { 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)); 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, void send(DialogId dialog_id, ServerMessageId server_message_id,
tl_object_ptr<telegram_api::paymentRequestedInfo> requested_info, bool allow_save) { tl_object_ptr<telegram_api::paymentRequestedInfo> requested_info, bool allow_save) {
dialog_id_ = 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);
if (input_peer == nullptr) { if (input_peer == nullptr) {
return on_error(Status::Error(400, "Can't access the chat")); 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 { 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)); promise_.set_error(std::move(status));
} }
}; };
@ -385,7 +385,7 @@ class SendPaymentFormQuery final : public Td::ResultHandler {
CHECK(input_credentials != nullptr); CHECK(input_credentials != nullptr);
dialog_id_ = 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);
if (input_peer == nullptr) { if (input_peer == nullptr) {
return on_error(Status::Error(400, "Can't access the chat")); return on_error(Status::Error(400, "Can't access the chat"));
} }
@ -417,8 +417,8 @@ class SendPaymentFormQuery final : public Td::ResultHandler {
switch (payment_result->get_id()) { switch (payment_result->get_id()) {
case telegram_api::payments_paymentResult::ID: { case telegram_api::payments_paymentResult::ID: {
auto result = move_tl_object_as<telegram_api::payments_paymentResult>(payment_result); auto result = move_tl_object_as<telegram_api::payments_paymentResult>(payment_result);
td->updates_manager_->on_get_updates(std::move(result->updates_), td_->updates_manager_->on_get_updates(
PromiseCreator::lambda([promise = std::move(promise_)](Unit) mutable { std::move(result->updates_), PromiseCreator::lambda([promise = std::move(promise_)](Unit) mutable {
promise.set_value(make_tl_object<td_api::paymentResult>(true, string())); promise.set_value(make_tl_object<td_api::paymentResult>(true, string()));
})); }));
return; return;
@ -434,7 +434,7 @@ class SendPaymentFormQuery final : public Td::ResultHandler {
} }
void on_error(Status status) final { 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)); 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) { void send(DialogId dialog_id, ServerMessageId server_message_id) {
dialog_id_ = 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);
if (input_peer == nullptr) { if (input_peer == nullptr) {
return on_error(Status::Error(400, "Can't access the chat")); 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(); auto payment_receipt = result_ptr.move_as_ok();
LOG(INFO) << "Receive payment receipt: " << to_string(payment_receipt); 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_); UserId payments_provider_user_id(payment_receipt->provider_id_);
if (!payments_provider_user_id.is_valid()) { 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; LOG(ERROR) << "Receive invalid seller " << seller_bot_user_id;
return on_error(Status::Error(500, "Receive invalid seller identifier")); 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<td_api::paymentReceipt>( promise_.set_value(make_tl_object<td_api::paymentReceipt>(
payment_receipt->title_, payment_receipt->description_, get_photo_object(td->file_manager_.get(), photo), 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"), 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"), 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_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_), convert_shipping_option(std::move(payment_receipt->shipping_)), std::move(payment_receipt->credentials_title_),
payment_receipt->tip_amount_)); payment_receipt->tip_amount_));
} }
void on_error(Status status) final { 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)); promise_.set_error(std::move(status));
} }
}; };

View File

@ -61,7 +61,7 @@ class GetPollResultsQuery final : public Td::ResultHandler {
void send(PollId poll_id, FullMessageId full_message_id) { void send(PollId poll_id, FullMessageId full_message_id) {
poll_id_ = poll_id; poll_id_ = poll_id;
dialog_id_ = full_message_id.get_dialog_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) { if (input_peer == nullptr) {
LOG(INFO) << "Can't reget poll, because have no read access to " << dialog_id_; LOG(INFO) << "Can't reget poll, because have no read access to " << dialog_id_;
return promise_.set_value(nullptr); return promise_.set_value(nullptr);
@ -82,7 +82,7 @@ class GetPollResultsQuery final : public Td::ResultHandler {
} }
void on_error(Status status) final { 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") { status.message() != "MESSAGE_ID_INVALID") {
LOG(ERROR) << "Receive " << status << ", while trying to get results of " << poll_id_; 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) { void send(PollId poll_id, FullMessageId full_message_id, BufferSlice &&option, const string &offset, int32 limit) {
poll_id_ = poll_id; poll_id_ = poll_id;
dialog_id_ = full_message_id.get_dialog_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) { if (input_peer == nullptr) {
LOG(INFO) << "Can't get poll, because have no read access to " << dialog_id_; 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")); 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 { 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") { status.message() != "MESSAGE_ID_INVALID") {
LOG(ERROR) << "Receive " << status << ", while trying to get voters of " << poll_id_; 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<BufferSlice> &&options, uint64 generation, NetQueryRef *query_ref) { void send(FullMessageId full_message_id, vector<BufferSlice> &&options, uint64 generation, NetQueryRef *query_ref) {
dialog_id_ = full_message_id.get_dialog_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) { if (input_peer == nullptr) {
LOG(INFO) << "Can't set poll answer, because have no read access to " << dialog_id_; 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")); 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))); telegram_api::messages_sendVote(std::move(input_peer), message_id, std::move(options)));
*query_ref = query.get_weak(); *query_ref = query.get_weak();
auto sequence_id = -1; 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); std::move(query), actor_shared(this), sequence_id);
} }
@ -175,7 +175,7 @@ class SetPollAnswerActor final : public NetActorOnce {
} }
void on_error(Status status) final { 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)); promise_.set_error(std::move(status));
} }
}; };
@ -190,7 +190,7 @@ class StopPollActor final : public NetActorOnce {
void send(FullMessageId full_message_id, unique_ptr<ReplyMarkup> &&reply_markup) { void send(FullMessageId full_message_id, unique_ptr<ReplyMarkup> &&reply_markup) {
dialog_id_ = full_message_id.get_dialog_id(); 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) { if (input_peer == nullptr) {
LOG(INFO) << "Can't close poll, because have no edit access to " << dialog_id_; 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")); 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( 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), flags, false /*ignored*/, std::move(input_peer), message_id, string(), std::move(input_media),
std::move(input_reply_markup), vector<tl_object_ptr<telegram_api::MessageEntity>>(), 0)); std::move(input_reply_markup), vector<tl_object_ptr<telegram_api::MessageEntity>>(), 0));
if (td->auth_manager_->is_bot()) { if (td_->auth_manager_->is_bot()) {
send_query(std::move(query)); send_query(std::move(query));
} else { } else {
auto sequence_id = -1; 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); std::move(query), actor_shared(this), sequence_id);
} }
} }
@ -227,14 +227,14 @@ class StopPollActor final : public NetActorOnce {
auto result = result_ptr.move_as_ok(); auto result = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for StopPoll: " << to_string(result); 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 { 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()); 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)); promise_.set_error(std::move(status));
} }
}; };

View File

@ -40,7 +40,7 @@ class GetSponsoredMessagesQuery final : public Td::ResultHandler {
void send(ChannelId channel_id) { void send(ChannelId channel_id) {
channel_id_ = 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) { if (input_channel == nullptr) {
return promise_.set_error(Status::Error(400, "Chat info not found")); 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 { 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)); 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) { void send(ChannelId channel_id, const string &message_id) {
channel_id_ = 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) { if (input_channel == nullptr) {
return promise_.set_error(Status::Error(400, "Chat info not found")); 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 { 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)); promise_.set_error(std::move(status));
} }
}; };

View File

@ -93,14 +93,14 @@ class GetAllStickersQuery final : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok(); auto ptr = result_ptr.move_as_ok();
LOG(DEBUG) << "Receive result for get all " << (is_masks_ ? "masks" : "stickers") << ": " << to_string(ptr); 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 { void on_error(Status status) final {
if (!G()->is_expected_error(status)) { if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for get all stickers: " << 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(); auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for search stickers: " << to_string(ptr); 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 { void on_error(Status status) final {
if (!G()->is_expected_error(status)) { if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for search stickers: " << 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,7 +272,7 @@ class GetArchivedStickerSetsQuery final : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok(); auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for GetArchivedStickerSetsQuery: " << to_string(ptr); 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_), td_->stickers_manager_->on_get_archived_sticker_sets(is_masks_, offset_sticker_set_id_, std::move(ptr->sets_),
ptr->count_); ptr->count_);
promise_.set_value(Unit()); promise_.set_value(Unit());
@ -298,11 +298,11 @@ class GetFeaturedStickerSetsQuery final : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok(); auto ptr = result_ptr.move_as_ok();
LOG(DEBUG) << "Receive result for GetFeaturedStickerSetsQuery: " << to_string(ptr); 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 { 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(); auto ptr = result_ptr.move_as_ok();
LOG(DEBUG) << "Receive result for GetOldFeaturedStickerSetsQuery: " << to_string(ptr); 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 { 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()); 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()); promise_.set_value(Unit());
} }
void on_error(Status status) final { 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_; VLOG(file_references) << "Receive " << status << " for " << file_id_;
td->file_manager_->delete_file_reference(file_id_, file_reference_); td_->file_manager_->delete_file_reference(file_id_, file_reference_);
td->file_reference_manager_->repair_file_reference( td_->file_reference_manager_->repair_file_reference(
file_id_, file_id_,
PromiseCreator::lambda([file_id = file_id_, promise = std::move(promise_)](Result<Unit> result) mutable { PromiseCreator::lambda([file_id = file_id_, promise = std::move(promise_)](Result<Unit> result) mutable {
if (result.is_error()) { if (result.is_error()) {
@ -411,14 +411,14 @@ class GetRecentStickersQuery final : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok(); auto ptr = result_ptr.move_as_ok();
LOG(DEBUG) << "Receive result for get recent " << (is_attached_ ? "attached " : "") LOG(DEBUG) << "Receive result for get recent " << (is_attached_ ? "attached " : "")
<< "stickers: " << to_string(ptr); << "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 { void on_error(Status status) final {
if (!G()->is_expected_error(status)) { if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for get recent " << (is_attached_ ? "attached " : "") << "stickers: " << 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(); bool result = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for save recent " << (is_attached_ ? "attached " : "") << "sticker: " << result; LOG(INFO) << "Receive result for save recent " << (is_attached_ ? "attached " : "") << "sticker: " << result;
if (!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()); promise_.set_value(Unit());
} }
void on_error(Status status) final { 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_; VLOG(file_references) << "Receive " << status << " for " << file_id_;
td->file_manager_->delete_file_reference(file_id_, file_reference_); td_->file_manager_->delete_file_reference(file_id_, file_reference_);
td->file_reference_manager_->repair_file_reference( td_->file_reference_manager_->repair_file_reference(
file_id_, PromiseCreator::lambda([sticker_id = file_id_, is_attached = is_attached_, unsave = unsave_, file_id_, PromiseCreator::lambda([sticker_id = file_id_, is_attached = is_attached_, unsave = unsave_,
promise = std::move(promise_)](Result<Unit> result) mutable { promise = std::move(promise_)](Result<Unit> result) mutable {
if (result.is_error()) { if (result.is_error()) {
@ -486,7 +486,7 @@ class SaveRecentStickerQuery final : public Td::ResultHandler {
if (!G()->is_expected_error(status)) { if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for save recent " << (is_attached_ ? "attached " : "") << "sticker: " << 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)); promise_.set_error(std::move(status));
} }
}; };
@ -520,7 +520,7 @@ class ClearRecentStickersQuery final : public Td::ResultHandler {
bool result = result_ptr.move_as_ok(); bool result = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for clear recent " << (is_attached_ ? "attached " : "") << "stickers: " << result; LOG(INFO) << "Receive result for clear recent " << (is_attached_ ? "attached " : "") << "stickers: " << result;
if (!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()); promise_.set_value(Unit());
@ -530,7 +530,7 @@ class ClearRecentStickersQuery final : public Td::ResultHandler {
if (!G()->is_expected_error(status)) { if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for clear recent " << (is_attached_ ? "attached " : "") << "stickers: " << 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)); promise_.set_error(std::move(status));
} }
}; };
@ -552,14 +552,14 @@ class GetFavedStickersQuery final : public Td::ResultHandler {
} }
auto ptr = result_ptr.move_as_ok(); 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 { void on_error(Status status) final {
if (!G()->is_expected_error(status)) { if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for get favorite stickers: " << 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(); bool result = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for fave sticker: " << result; LOG(INFO) << "Receive result for fave sticker: " << result;
if (!result) { if (!result) {
td->stickers_manager_->reload_favorite_stickers(true); td_->stickers_manager_->reload_favorite_stickers(true);
} }
promise_.set_value(Unit()); promise_.set_value(Unit());
} }
void on_error(Status status) final { 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_; VLOG(file_references) << "Receive " << status << " for " << file_id_;
td->file_manager_->delete_file_reference(file_id_, file_reference_); td_->file_manager_->delete_file_reference(file_id_, file_reference_);
td->file_reference_manager_->repair_file_reference( td_->file_reference_manager_->repair_file_reference(
file_id_, PromiseCreator::lambda([sticker_id = file_id_, unsave = unsave_, file_id_, PromiseCreator::lambda([sticker_id = file_id_, unsave = unsave_,
promise = std::move(promise_)](Result<Unit> result) mutable { promise = std::move(promise_)](Result<Unit> result) mutable {
if (result.is_error()) { if (result.is_error()) {
@ -619,7 +619,7 @@ class FaveStickerQuery final : public Td::ResultHandler {
if (!G()->is_expected_error(status)) { if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for fave sticker: " << 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)); promise_.set_error(std::move(status));
} }
}; };
@ -654,7 +654,7 @@ class ReorderStickerSetsQuery final : public Td::ResultHandler {
if (!G()->is_expected_error(status)) { if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for ReorderStickerSetsQuery: " << 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()); promise_.set_value(Unit());
} }
void on_error(Status status) final { void on_error(Status status) final {
LOG(INFO) << "Receive error for GetStickerSetQuery: " << status; 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)); promise_.set_error(std::move(status));
} }
}; };
@ -723,10 +723,10 @@ class ReloadSpecialStickerSetQuery final : public Td::ResultHandler {
return on_error(result_ptr.move_as_error()); 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(), auto sticker_set_id = td_->stickers_manager_->on_get_messages_sticker_set(StickerSetId(), result_ptr.move_as_ok(),
true, "ReloadSpecialStickerSetQuery"); true, "ReloadSpecialStickerSetQuery");
if (sticker_set_id.is_valid()) { 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 { } else {
on_error(Status::Error(500, "Failed to add special sticker set")); 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 { void on_error(Status status) final {
LOG(WARNING) << "Receive error for ReloadSpecialStickerSetQuery: " << status; 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(); auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for search sticker sets: " << to_string(ptr); 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 { void on_error(Status status) final {
if (!G()->is_expected_error(status)) { if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for search sticker sets: " << 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()); 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()); promise_.set_value(Unit());
} }
@ -823,7 +823,7 @@ class UninstallStickerSetQuery final : public Td::ResultHandler {
if (!result) { if (!result) {
LOG(WARNING) << "Receive false in result to uninstallStickerSet"; LOG(WARNING) << "Receive false in result to uninstallStickerSet";
} else { } else {
td->stickers_manager_->on_uninstall_sticker_set(set_id_); td_->stickers_manager_->on_uninstall_sticker_set(set_id_);
} }
promise_.set_value(Unit()); promise_.set_value(Unit());
@ -857,7 +857,7 @@ class ReadFeaturedStickerSetsQuery final : public Td::ResultHandler {
if (!G()->is_expected_error(status)) { if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for ReadFeaturedStickerSetsQuery: " << 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()); 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 { void on_error(Status status) final {
@ -894,17 +894,17 @@ class UploadStickerFileQuery final : public Td::ResultHandler {
if (was_uploaded_) { if (was_uploaded_) {
CHECK(file_id_.is_valid()); CHECK(file_id_.is_valid());
if (begins_with(status.message(), "FILE_PART_") && ends_with(status.message(), "_MISSING")) { 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<int32>(status.message().substr(10))); // TODO td_->stickers_manager_->on_upload_sticker_file_part_missing(file_id_, to_integer<int32>(status.message().substr(10)));
// return; // return;
} else { } else {
if (status.code() != 429 && status.code() < 500 && !G()->close_flag()) { 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)) { } else if (FileReferenceManager::is_file_reference_error(status)) {
LOG(ERROR) << "Receive file reference error for UploadStickerFileQuery"; 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)); promise_.set_error(std::move(status));
} }
}; };
@ -996,7 +996,7 @@ class CreateNewStickerSetQuery final : public Td::ResultHandler {
return on_error(result_ptr.move_as_error()); return on_error(result_ptr.move_as_error());
} }
td->stickers_manager_->on_get_messages_sticker_set(StickerSetId(), result_ptr.move_as_ok(), true, td_->stickers_manager_->on_get_messages_sticker_set(StickerSetId(), result_ptr.move_as_ok(), true,
"CreateNewStickerSetQuery"); "CreateNewStickerSetQuery");
promise_.set_value(Unit()); promise_.set_value(Unit());
@ -1026,7 +1026,7 @@ class AddStickerToSetQuery final : public Td::ResultHandler {
return on_error(result_ptr.move_as_error()); return on_error(result_ptr.move_as_error());
} }
td->stickers_manager_->on_get_messages_sticker_set(StickerSetId(), result_ptr.move_as_ok(), true, td_->stickers_manager_->on_get_messages_sticker_set(StickerSetId(), result_ptr.move_as_ok(), true,
"AddStickerToSetQuery"); "AddStickerToSetQuery");
promise_.set_value(Unit()); promise_.set_value(Unit());
@ -1056,7 +1056,7 @@ class SetStickerSetThumbnailQuery final : public Td::ResultHandler {
return on_error(result_ptr.move_as_error()); return on_error(result_ptr.move_as_error());
} }
td->stickers_manager_->on_get_messages_sticker_set(StickerSetId(), result_ptr.move_as_ok(), true, td_->stickers_manager_->on_get_messages_sticker_set(StickerSetId(), result_ptr.move_as_ok(), true,
"SetStickerSetThumbnailQuery"); "SetStickerSetThumbnailQuery");
promise_.set_value(Unit()); promise_.set_value(Unit());
@ -1086,7 +1086,7 @@ class SetStickerPositionQuery final : public Td::ResultHandler {
return on_error(result_ptr.move_as_error()); return on_error(result_ptr.move_as_error());
} }
td->stickers_manager_->on_get_messages_sticker_set(StickerSetId(), result_ptr.move_as_ok(), true, td_->stickers_manager_->on_get_messages_sticker_set(StickerSetId(), result_ptr.move_as_ok(), true,
"SetStickerPositionQuery"); "SetStickerPositionQuery");
promise_.set_value(Unit()); promise_.set_value(Unit());
@ -1115,7 +1115,7 @@ class DeleteStickerFromSetQuery final : public Td::ResultHandler {
return on_error(result_ptr.move_as_error()); return on_error(result_ptr.move_as_error());
} }
td->stickers_manager_->on_get_messages_sticker_set(StickerSetId(), result_ptr.move_as_ok(), true, td_->stickers_manager_->on_get_messages_sticker_set(StickerSetId(), result_ptr.move_as_ok(), true,
"DeleteStickerFromSetQuery"); "DeleteStickerFromSetQuery");
promise_.set_value(Unit()); promise_.set_value(Unit());
@ -1154,11 +1154,11 @@ class SendAnimatedEmojiClicksQuery final : public Td::ResultHandler {
} }
void on_error(Status status) final { 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; 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_);
} }
}; };

View File

@ -153,13 +153,13 @@ namespace td {
int VERBOSITY_NAME(td_init) = VERBOSITY_NAME(DEBUG) + 3; int VERBOSITY_NAME(td_init) = VERBOSITY_NAME(DEBUG) + 3;
int VERBOSITY_NAME(td_requests) = VERBOSITY_NAME(INFO); int VERBOSITY_NAME(td_requests) = VERBOSITY_NAME(INFO);
void Td::ResultHandler::set_td(Td *new_td) { void Td::ResultHandler::set_td(Td *td) {
CHECK(td == nullptr); CHECK(td_ == nullptr);
td = new_td; td_ = td;
} }
void Td::ResultHandler::send_query(NetQueryPtr query) { 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)); send(std::move(query));
} }
@ -208,8 +208,8 @@ class GetRecentMeUrlsQuery final : public Td::ResultHandler {
} }
auto urls_full = result_ptr.move_as_ok(); 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_users(std::move(urls_full->users_), "GetRecentMeUrlsQuery");
td->contacts_manager_->on_get_chats(std::move(urls_full->chats_), "GetRecentMeUrlsQuery"); td_->contacts_manager_->on_get_chats(std::move(urls_full->chats_), "GetRecentMeUrlsQuery");
auto urls = std::move(urls_full->urls_); auto urls = std::move(urls_full->urls_);
auto results = make_tl_object<td_api::tMeUrls>(); auto results = make_tl_object<td_api::tMeUrls>();
@ -228,7 +228,7 @@ class GetRecentMeUrlsQuery final : public Td::ResultHandler {
break; break;
} }
result->type_ = make_tl_object<td_api::tMeUrlTypeUser>( result->type_ = make_tl_object<td_api::tMeUrlTypeUser>(
td->contacts_manager_->get_user_id_object(user_id, "tMeUrlTypeUser")); td_->contacts_manager_->get_user_id_object(user_id, "tMeUrlTypeUser"));
break; break;
} }
case telegram_api::recentMeUrlChat::ID: { case telegram_api::recentMeUrlChat::ID: {
@ -241,15 +241,15 @@ class GetRecentMeUrlsQuery final : public Td::ResultHandler {
break; break;
} }
result->type_ = make_tl_object<td_api::tMeUrlTypeSupergroup>( result->type_ = make_tl_object<td_api::tMeUrlTypeSupergroup>(
td->contacts_manager_->get_supergroup_id_object(channel_id, "tMeUrlTypeSupergroup")); td_->contacts_manager_->get_supergroup_id_object(channel_id, "tMeUrlTypeSupergroup"));
break; break;
} }
case telegram_api::recentMeUrlChatInvite::ID: { case telegram_api::recentMeUrlChatInvite::ID: {
auto url = move_tl_object_as<telegram_api::recentMeUrlChatInvite>(url_ptr); auto url = move_tl_object_as<telegram_api::recentMeUrlChatInvite>(url_ptr);
result->url_ = std::move(url->url_); result->url_ = std::move(url->url_);
td->contacts_manager_->on_get_dialog_invite_link_info(result->url_, std::move(url->chat_invite_), td_->contacts_manager_->on_get_dialog_invite_link_info(result->url_, std::move(url->chat_invite_),
Promise<Unit>()); Promise<Unit>());
auto info_object = td->contacts_manager_->get_chat_invite_link_info_object(result->url_); auto info_object = td_->contacts_manager_->get_chat_invite_link_info_object(result->url_);
if (info_object == nullptr) { if (info_object == nullptr) {
result = nullptr; result = nullptr;
break; break;
@ -261,7 +261,7 @@ class GetRecentMeUrlsQuery final : public Td::ResultHandler {
auto url = move_tl_object_as<telegram_api::recentMeUrlStickerSet>(url_ptr); auto url = move_tl_object_as<telegram_api::recentMeUrlStickerSet>(url_ptr);
result->url_ = std::move(url->url_); result->url_ = std::move(url->url_);
auto sticker_set_id = 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()) { if (!sticker_set_id.is_valid()) {
LOG(ERROR) << "Receive invalid sticker set"; LOG(ERROR) << "Receive invalid sticker set";
result = nullptr; result = nullptr;
@ -392,7 +392,7 @@ class UpdateStatusQuery final : public Td::ResultHandler {
bool result = result_ptr.ok(); bool result = result_ptr.ok();
LOG(INFO) << "UpdateStatus returned " << result; 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 { void on_error(Status status) final {

View File

@ -221,10 +221,10 @@ class Td final : public Actor {
protected: protected:
void send_query(NetQueryPtr query); void send_query(NetQueryPtr query);
Td *td = nullptr; Td *td_ = nullptr;
private: private:
void set_td(Td *new_td); void set_td(Td *td);
}; };
template <class HandlerT, class... Args> template <class HandlerT, class... Args>

View File

@ -100,7 +100,7 @@ class ResetTopPeerRatingQuery final : public Td::ResultHandler {
public: public:
void send(TopDialogCategory category, DialogId dialog_id) { 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) { if (input_peer == nullptr) {
return; return;
} }
@ -120,7 +120,7 @@ class ResetTopPeerRatingQuery final : public Td::ResultHandler {
} }
void on_error(Status status) final { 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; LOG(INFO) << "Receive error for ResetTopPeerRatingQuery: " << status;
} }
} }

View File

@ -84,11 +84,11 @@ class GetWebPagePreviewQuery final : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok(); auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for GetWebPagePreviewQuery: " << to_string(ptr); 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 { 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 int32 view_count = (web_page->flags_ & telegram_api::webPageNotModified::CACHED_PAGE_VIEWS_MASK) != 0
? web_page->cached_page_views_ ? web_page->cached_page_views_
: 0; : 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_)); return promise_.set_value(std::move(web_page_id_));
} else { } else {
LOG(ERROR) << "Receive webPageNotModified for " << url_; LOG(ERROR) << "Receive webPageNotModified for " << url_;
return on_error(Status::Error(500, "Receive webPageNotModified")); return on_error(Status::Error(500, "Receive webPageNotModified"));
} }
} }
auto web_page_id = td->web_pages_manager_->on_get_web_page(std::move(ptr), DialogId()); 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); td_->web_pages_manager_->on_get_web_page_by_url(url_, web_page_id, false);
promise_.set_value(std::move(web_page_id)); promise_.set_value(std::move(web_page_id));
} }

View File

@ -12,7 +12,7 @@
namespace td { namespace td {
NetActor::NetActor() : td(static_cast<Td *>(G()->td().get_actor_unsafe())) { NetActor::NetActor() : td_(static_cast<Td *>(G()->td().get_actor_unsafe())) {
} }
void NetActor::set_parent(ActorShared<> parent) { void NetActor::set_parent(ActorShared<> parent) {

View File

@ -39,9 +39,10 @@ class NetActor : public NetQueryCallback {
} }
protected: protected:
Td *td_;
ActorShared<> parent_; ActorShared<> parent_;
void send_query(NetQueryPtr query); void send_query(NetQueryPtr query);
Td *td;
}; };
class NetActorOnce : public NetActor { class NetActorOnce : public NetActor {