Remove NetQuery id from ResultHandler and NetActor.

This commit is contained in:
levlam 2021-11-08 14:19:57 +03:00
parent 365965d1fb
commit 5578ecc6b8
27 changed files with 971 additions and 964 deletions

View File

@ -49,17 +49,17 @@ class GetSavedGifsQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create(telegram_api::messages_getSavedGifs(hash)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_getSavedGifs>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto ptr = result_ptr.move_as_ok();
td->animations_manager_->on_get_saved_animations(is_repair_, std::move(ptr));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for get saved animations: " << status;
}
@ -87,10 +87,10 @@ class SaveGifQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create(telegram_api::messages_saveGif(std::move(input_document), unsave)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_saveGif>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
bool result = result_ptr.move_as_ok();
@ -102,7 +102,7 @@ class SaveGifQuery final : public Td::ResultHandler {
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
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_);

View File

@ -42,10 +42,10 @@ class GetAutoDownloadSettingsQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create(telegram_api::account_getAutoDownloadSettings()));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::account_getAutoDownloadSettings>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto settings = result_ptr.move_as_ok();
@ -54,7 +54,7 @@ class GetAutoDownloadSettingsQuery final : public Td::ResultHandler {
convert_auto_download_settings(settings->high_)));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -98,17 +98,17 @@ class SaveAutoDownloadSettingsQuery final : public Td::ResultHandler {
flags, false /*ignored*/, false /*ignored*/, get_input_auto_download_settings(settings))));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::account_saveAutoDownloadSettings>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
LOG(INFO) << "SaveAutoDownloadSettingsQuery returned " << result_ptr.ok();
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};

View File

@ -54,10 +54,10 @@ class GetBackgroundQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create(telegram_api::account_getWallPaper(std::move(input_wallpaper))));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::account_getWallPaper>(packet);
if (result_ptr.is_error()) {
return on_error(id, 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);
@ -65,7 +65,7 @@ class GetBackgroundQuery final : public Td::ResultHandler {
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
LOG(INFO) << "Receive error for GetBackgroundQuery for " << background_id_ << "/" << background_name_ << ": "
<< status;
promise_.set_error(std::move(status));
@ -84,16 +84,16 @@ class GetBackgroundsQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create(telegram_api::account_getWallPapers(0)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::account_getWallPapers>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
promise_.set_value(result_ptr.move_as_ok());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -110,17 +110,17 @@ class InstallBackgroundQuery final : public Td::ResultHandler {
telegram_api::account_installWallPaper(std::move(input_wallpaper), type.get_input_wallpaper_settings())));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::account_installWallPaper>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
LOG_IF(INFO, !result_ptr.ok()) << "Receive false from account.installWallPaper";
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -145,17 +145,17 @@ class UploadBackgroundQuery final : public Td::ResultHandler {
std::move(input_file), type_.get_mime_type(), type_.get_input_wallpaper_settings())));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::account_uploadWallPaper>(packet);
if (result_ptr.is_error()) {
return on_error(id, 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(),
std::move(promise_));
}
void on_error(uint64 id, Status status) final {
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")) {
@ -183,10 +183,10 @@ class UnsaveBackgroundQuery final : public Td::ResultHandler {
std::move(input_wallpaper), true, telegram_api::make_object<telegram_api::wallPaperSettings>())));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::account_saveWallPaper>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
bool result = result_ptr.move_as_ok();
@ -194,7 +194,7 @@ class UnsaveBackgroundQuery final : public Td::ResultHandler {
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for save background: " << status;
}
@ -213,10 +213,10 @@ class ResetBackgroundsQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create(telegram_api::account_resetWallPapers()));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::account_resetWallPapers>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
bool result = result_ptr.move_as_ok();
@ -224,7 +224,7 @@ class ResetBackgroundsQuery final : public Td::ResultHandler {
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for reset backgrounds: " << status;
}

View File

@ -35,10 +35,10 @@ class SetBotCommandsQuery final : public Td::ResultHandler {
transform(commands, [](const BotCommand &command) { return command.get_input_bot_command(); }))));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::bots_setBotCommands>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
if (!result_ptr.ok()) {
@ -47,7 +47,7 @@ class SetBotCommandsQuery final : public Td::ResultHandler {
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -64,16 +64,16 @@ class ResetBotCommandsQuery final : public Td::ResultHandler {
telegram_api::bots_resetBotCommands(scope.get_input_bot_command_scope(td), language_code)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::bots_resetBotCommands>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -91,17 +91,17 @@ class GetBotCommandsQuery final : public Td::ResultHandler {
telegram_api::bots_getBotCommands(scope.get_input_bot_command_scope(td), language_code)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::bots_getBotCommands>(packet);
if (result_ptr.is_error()) {
return on_error(id, 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());
promise_.set_value(commands.get_bot_commands_object(td));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};

View File

@ -72,10 +72,10 @@ class GetBotCallbackAnswerQuery final : public Td::ResultHandler {
send_query(std::move(net_query));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_getBotCallbackAnswer>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto answer = result_ptr.move_as_ok();
@ -83,7 +83,7 @@ class GetBotCallbackAnswerQuery final : public Td::ResultHandler {
td_api::make_object<td_api::callbackQueryAnswer>(answer->message_, answer->alert_, answer->url_));
}
void on_error(uint64 id, Status status) final {
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");
} else if (status.message() == "BOT_RESPONSE_TIMEOUT") {
@ -110,10 +110,10 @@ class SetBotCallbackAnswerQuery final : public Td::ResultHandler {
flags, false /*ignored*/, callback_query_id, text, url, cache_time)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_setBotCallbackAnswer>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
bool result = result_ptr.ok();
@ -123,7 +123,7 @@ class SetBotCallbackAnswerQuery final : public Td::ResultHandler {
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};

File diff suppressed because it is too large Load Diff

View File

@ -34,17 +34,17 @@ class GetNearestDcQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create_unauth(telegram_api::help_getNearestDc()));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::help_getNearestDc>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto result = result_ptr.move_as_ok();
promise_.set_value(std::move(result->country_));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
if (!G()->is_expected_error(status) && status.message() != "BOT_METHOD_INVALID") {
LOG(ERROR) << "GetNearestDc returned " << status;
}
@ -64,17 +64,17 @@ class GetCountriesListQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create_unauth(telegram_api::help_getCountriesList(language_code, hash)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
// LOG(ERROR) << base64url_encode(gzencode(packet, 0.9));
auto result_ptr = fetch_result<telegram_api::help_getCountriesList>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
promise_.set_value(result_ptr.move_as_ok());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "GetCountriesList returned " << status;
}

View File

@ -50,7 +50,7 @@ class SetGameScoreActor final : public NetActorOnce {
auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Edit);
if (input_peer == nullptr) {
on_error(0, Status::Error(400, "Can't access the chat"));
on_error(Status::Error(400, "Can't access the chat"));
stop();
return;
}
@ -67,10 +67,10 @@ class SetGameScoreActor final : public NetActorOnce {
std::move(query), actor_shared(this), sequence_dispatcher_id);
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_setGameScore>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto ptr = result_ptr.move_as_ok();
@ -78,7 +78,7 @@ class SetGameScoreActor final : public NetActorOnce {
td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
LOG(INFO) << "Receive error for SetGameScore: " << status;
td->messages_manager_->on_get_dialog_error(dialog_id_, status, "SetGameScoreActor");
promise_.set_error(std::move(status));
@ -112,10 +112,10 @@ class SetInlineGameScoreQuery final : public Td::ResultHandler {
dc_id));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_setInlineGameScore>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
LOG_IF(ERROR, !result_ptr.ok()) << "Receive false in result of setInlineGameScore";
@ -123,7 +123,7 @@ class SetInlineGameScoreQuery final : public Td::ResultHandler {
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
LOG(INFO) << "Receive error for SetInlineGameScoreQuery: " << status;
promise_.set_error(std::move(status));
}
@ -149,16 +149,16 @@ class GetGameHighScoresQuery final : public Td::ResultHandler {
std::move(input_peer), message_id.get_server_message_id().get(), std::move(input_user))));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_getGameHighScores>(packet);
if (result_ptr.is_error()) {
return on_error(id, 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()));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetGameHighScoresQuery");
promise_.set_error(std::move(status));
}
@ -183,16 +183,16 @@ class GetInlineGameHighScoresQuery final : public Td::ResultHandler {
dc_id));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_getInlineGameHighScores>(packet);
if (result_ptr.is_error()) {
return on_error(id, 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()));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};

View File

@ -52,22 +52,22 @@ class GetGroupCallStreamQuery final : public Td::ResultHandler {
send_query(std::move(query));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::upload_getFile>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto ptr = result_ptr.move_as_ok();
if (ptr->get_id() != telegram_api::upload_file::ID) {
return on_error(id, Status::Error(500, "Receive unexpected server response"));
return on_error(Status::Error(500, "Receive unexpected server response"));
}
auto file = move_tl_object_as<telegram_api::upload_file>(ptr);
promise_.set_value(file->bytes_.as_slice().str());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -90,10 +90,10 @@ class GetGroupCallJoinAsQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create(telegram_api::phone_getGroupCallJoinAs(std::move(input_peer))));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::phone_getGroupCallJoinAs>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto ptr = result_ptr.move_as_ok();
@ -121,7 +121,7 @@ class GetGroupCallJoinAsQuery final : public Td::ResultHandler {
std::move(participant_aliaces)));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetGroupCallJoinAsQuery");
promise_.set_error(std::move(status));
}
@ -145,10 +145,10 @@ class SaveDefaultGroupCallJoinAsQuery final : public Td::ResultHandler {
telegram_api::phone_saveDefaultGroupCallJoinAs(std::move(input_peer), std::move(as_input_peer))));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::phone_saveDefaultGroupCallJoinAs>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto success = result_ptr.move_as_ok();
@ -157,7 +157,7 @@ class SaveDefaultGroupCallJoinAsQuery final : public Td::ResultHandler {
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
// td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetGroupCallJoinAsQuery");
promise_.set_error(std::move(status));
}
@ -188,10 +188,10 @@ class CreateGroupCallQuery final : public Td::ResultHandler {
telegram_api::phone_createGroupCall(flags, std::move(input_peer), Random::secure_int32(), title, start_date)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::phone_createGroupCall>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto ptr = result_ptr.move_as_ok();
@ -200,13 +200,13 @@ class CreateGroupCallQuery final : public Td::ResultHandler {
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(id, Status::Error(500, "Receive wrong response"));
return on_error(Status::Error(500, "Receive wrong response"));
}
auto group_call_id = group_call_ids[0];
for (auto other_group_call_id : group_call_ids) {
if (group_call_id != other_group_call_id) {
LOG(ERROR) << "Receive wrong CreateGroupCallQuery response " << to_string(ptr);
return on_error(id, Status::Error(500, "Receive wrong response"));
return on_error(Status::Error(500, "Receive wrong response"));
}
}
@ -216,7 +216,7 @@ class CreateGroupCallQuery final : public Td::ResultHandler {
}));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
td->messages_manager_->on_get_dialog_error(dialog_id_, status, "CreateGroupCallQuery");
promise_.set_error(std::move(status));
}
@ -235,10 +235,10 @@ class GetGroupCallQuery final : public Td::ResultHandler {
telegram_api::phone_getGroupCall(input_group_call_id.get_input_group_call(), limit)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::phone_getGroupCall>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto ptr = result_ptr.move_as_ok();
@ -247,7 +247,7 @@ class GetGroupCallQuery final : public Td::ResultHandler {
promise_.set_value(std::move(ptr));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -268,10 +268,10 @@ class GetGroupCallParticipantQuery final : public Td::ResultHandler {
input_group_call_id.get_input_group_call(), std::move(input_peers), std::move(source_ids), string(), limit)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::phone_getGroupParticipants>(packet);
if (result_ptr.is_error()) {
return on_error(id, 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,
@ -280,7 +280,7 @@ class GetGroupCallParticipantQuery final : public Td::ResultHandler {
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -302,10 +302,10 @@ class GetGroupCallParticipantsQuery final : public Td::ResultHandler {
offset_, limit)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::phone_getGroupParticipants>(packet);
if (result_ptr.is_error()) {
return on_error(id, 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,
@ -314,7 +314,7 @@ class GetGroupCallParticipantsQuery final : public Td::ResultHandler {
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -331,10 +331,10 @@ class StartScheduledGroupCallQuery final : public Td::ResultHandler {
telegram_api::phone_startScheduledGroupCall(input_group_call_id.get_input_group_call())));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::phone_startScheduledGroupCall>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto ptr = result_ptr.move_as_ok();
@ -342,7 +342,7 @@ class StartScheduledGroupCallQuery final : public Td::ResultHandler {
td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
if (status.message() == "GROUPCALL_NOT_MODIFIED") {
promise_.set_value(Unit());
return;
@ -393,10 +393,10 @@ class JoinGroupCallQuery final : public Td::ResultHandler {
return join_query_ref;
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::phone_joinGroupCall>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto ptr = result_ptr.move_as_ok();
@ -405,7 +405,7 @@ class JoinGroupCallQuery final : public Td::ResultHandler {
std::move(promise_));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -426,10 +426,10 @@ class JoinGroupCallPresentationQuery final : public Td::ResultHandler {
return join_query_ref;
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::phone_joinGroupCallPresentation>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto ptr = result_ptr.move_as_ok();
@ -439,7 +439,7 @@ class JoinGroupCallPresentationQuery final : public Td::ResultHandler {
std::move(ptr), Status::OK());
}
void on_error(uint64 id, 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,
std::move(status));
}
@ -457,10 +457,10 @@ class LeaveGroupCallPresentationQuery final : public Td::ResultHandler {
telegram_api::phone_leaveGroupCallPresentation(input_group_call_id.get_input_group_call())));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::phone_editGroupCallTitle>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto ptr = result_ptr.move_as_ok();
@ -468,7 +468,7 @@ class LeaveGroupCallPresentationQuery final : public Td::ResultHandler {
td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
if (status.message() == "PARTICIPANT_PRESENTATION_MISSING") {
promise_.set_value(Unit());
return;
@ -489,10 +489,10 @@ class EditGroupCallTitleQuery final : public Td::ResultHandler {
telegram_api::phone_editGroupCallTitle(input_group_call_id.get_input_group_call(), title)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::phone_editGroupCallTitle>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto ptr = result_ptr.move_as_ok();
@ -500,7 +500,7 @@ class EditGroupCallTitleQuery final : public Td::ResultHandler {
td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
if (status.message() == "GROUPCALL_NOT_MODIFIED") {
promise_.set_value(Unit());
return;
@ -521,10 +521,10 @@ class ToggleGroupCallStartSubscriptionQuery final : public Td::ResultHandler {
input_group_call_id.get_input_group_call(), start_subscribed)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::phone_toggleGroupCallStartSubscription>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto ptr = result_ptr.move_as_ok();
@ -532,7 +532,7 @@ class ToggleGroupCallStartSubscriptionQuery final : public Td::ResultHandler {
td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
if (status.message() == "GROUPCALL_NOT_MODIFIED") {
promise_.set_value(Unit());
return;
@ -553,10 +553,10 @@ class ToggleGroupCallSettingsQuery final : public Td::ResultHandler {
flags, false /*ignored*/, input_group_call_id.get_input_group_call(), join_muted)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::phone_toggleGroupCallSettings>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto ptr = result_ptr.move_as_ok();
@ -564,7 +564,7 @@ class ToggleGroupCallSettingsQuery final : public Td::ResultHandler {
td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
if (status.message() == "GROUPCALL_NOT_MODIFIED") {
promise_.set_value(Unit());
return;
@ -585,10 +585,10 @@ class InviteToGroupCallQuery final : public Td::ResultHandler {
telegram_api::phone_inviteToGroupCall(input_group_call_id.get_input_group_call(), std::move(input_users))));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::phone_inviteToGroupCall>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto ptr = result_ptr.move_as_ok();
@ -596,7 +596,7 @@ class InviteToGroupCallQuery final : public Td::ResultHandler {
td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -617,17 +617,17 @@ class ExportGroupCallInviteQuery final : public Td::ResultHandler {
flags, false /*ignored*/, input_group_call_id.get_input_group_call())));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::phone_exportGroupCallInvite>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto ptr = result_ptr.move_as_ok();
promise_.set_value(std::move(ptr->link_));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -656,10 +656,10 @@ class ToggleGroupCallRecordQuery final : public Td::ResultHandler {
use_portrait_orientation)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::phone_toggleGroupCallRecord>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto ptr = result_ptr.move_as_ok();
@ -667,7 +667,7 @@ class ToggleGroupCallRecordQuery final : public Td::ResultHandler {
td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
if (status.message() == "GROUPCALL_NOT_MODIFIED") {
promise_.set_value(Unit());
return;
@ -689,7 +689,7 @@ class EditGroupCallParticipantQuery final : public Td::ResultHandler {
bool presentation_is_paused) {
auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Know);
if (input_peer == nullptr) {
return on_error(0, Status::Error(400, "Can't access the chat"));
return on_error(Status::Error(400, "Can't access the chat"));
}
int32 flags = 0;
@ -712,10 +712,10 @@ class EditGroupCallParticipantQuery final : public Td::ResultHandler {
video_is_stopped, video_is_paused, presentation_is_paused)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::phone_editGroupCallParticipant>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto ptr = result_ptr.move_as_ok();
@ -723,7 +723,7 @@ class EditGroupCallParticipantQuery final : public Td::ResultHandler {
td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -743,10 +743,10 @@ class CheckGroupCallQuery final : public Td::ResultHandler {
telegram_api::phone_checkGroupCall(input_group_call_id.get_input_group_call(), std::move(audio_sources))));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::phone_checkGroupCall>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
vector<int32> active_audio_sources = result_ptr.move_as_ok();
@ -759,7 +759,7 @@ class CheckGroupCallQuery final : public Td::ResultHandler {
}
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -776,10 +776,10 @@ class LeaveGroupCallQuery final : public Td::ResultHandler {
telegram_api::phone_leaveGroupCall(input_group_call_id.get_input_group_call(), audio_source)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::phone_leaveGroupCall>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto ptr = result_ptr.move_as_ok();
@ -787,7 +787,7 @@ class LeaveGroupCallQuery final : public Td::ResultHandler {
td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -804,10 +804,10 @@ class DiscardGroupCallQuery final : public Td::ResultHandler {
telegram_api::phone_discardGroupCall(input_group_call_id.get_input_group_call())));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::phone_discardGroupCall>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto ptr = result_ptr.move_as_ok();
@ -815,7 +815,7 @@ class DiscardGroupCallQuery final : public Td::ResultHandler {
td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};

View File

@ -89,10 +89,10 @@ class GetInlineBotResultsQuery final : public Td::ResultHandler {
return result;
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_getInlineBotResults>(packet);
if (result_ptr.is_error()) {
return on_error(id, 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_,
@ -100,7 +100,7 @@ class GetInlineBotResultsQuery final : public Td::ResultHandler {
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
if (status.code() == NetQuery::Canceled) {
status = Status::Error(406, "Request canceled");
} else if (status.message() == "BOT_RESPONSE_TIMEOUT") {
@ -143,10 +143,10 @@ class SetInlineBotResultsQuery final : public Td::ResultHandler {
std::move(inline_bot_switch_pm))));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_setInlineBotResults>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
bool result = result_ptr.ok();
@ -156,7 +156,7 @@ class SetInlineBotResultsQuery final : public Td::ResultHandler {
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};

View File

@ -389,10 +389,10 @@ class GetDeepLinkInfoQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create_unauth(telegram_api::help_getDeepLinkInfo(link.str())));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::help_getDeepLinkInfo>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto result = result_ptr.move_as_ok();
@ -419,7 +419,7 @@ class GetDeepLinkInfoQuery final : public Td::ResultHandler {
}
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -451,10 +451,10 @@ class RequestUrlAuthQuery final : public Td::ResultHandler {
url_)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_requestUrlAuth>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto result = result_ptr.move_as_ok();
@ -464,7 +464,7 @@ class RequestUrlAuthQuery final : public Td::ResultHandler {
auto request = telegram_api::move_object_as<telegram_api::urlAuthResultRequest>(result);
UserId bot_user_id = ContactsManager::get_user_id(request->bot_);
if (!bot_user_id.is_valid()) {
return on_error(id, 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");
promise_.set_value(td_api::make_object<td_api::loginUrlInfoRequestConfirmation>(
@ -483,7 +483,7 @@ class RequestUrlAuthQuery final : public Td::ResultHandler {
}
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
if (!dialog_id_.is_valid() ||
!td->messages_manager_->on_get_dialog_error(dialog_id_, status, "RequestUrlAuthQuery")) {
LOG(INFO) << "RequestUrlAuthQuery returned " << status;
@ -521,10 +521,10 @@ class AcceptUrlAuthQuery final : public Td::ResultHandler {
button_id, url_)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_acceptUrlAuth>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto result = result_ptr.move_as_ok();
@ -532,7 +532,7 @@ class AcceptUrlAuthQuery final : public Td::ResultHandler {
switch (result->get_id()) {
case telegram_api::urlAuthResultRequest::ID:
LOG(ERROR) << "Receive unexpected " << to_string(result);
return on_error(id, Status::Error(500, "Receive unexpected urlAuthResultRequest"));
return on_error(Status::Error(500, "Receive unexpected urlAuthResultRequest"));
case telegram_api::urlAuthResultAccepted::ID: {
auto accepted = telegram_api::move_object_as<telegram_api::urlAuthResultAccepted>(result);
promise_.set_value(td_api::make_object<td_api::httpUrl>(accepted->url_));
@ -544,7 +544,7 @@ class AcceptUrlAuthQuery final : public Td::ResultHandler {
}
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
if (!dialog_id_.is_valid() ||
!td->messages_manager_->on_get_dialog_error(dialog_id_, status, "AcceptUrlAuthQuery")) {
LOG(INFO) << "AcceptUrlAuthQuery returned " << status;

File diff suppressed because it is too large Load Diff

View File

@ -79,16 +79,16 @@ class SetContactSignUpNotificationQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create(telegram_api::account_setContactSignUpNotification(is_disabled)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::account_setContactSignUpNotification>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for set contact sign up notification: " << status;
}
@ -107,17 +107,17 @@ class GetContactSignUpNotificationQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create(telegram_api::account_getContactSignUpNotification()));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::account_getContactSignUpNotification>(packet);
if (result_ptr.is_error()) {
return on_error(id, 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());
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for get contact sign up notification: " << status;
}

View File

@ -51,10 +51,10 @@ class SetBotShippingAnswerQuery final : public Td::ResultHandler {
flags, shipping_query_id, error_message, std::move(shipping_options))));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_setBotShippingResults>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
bool result = result_ptr.ok();
@ -64,7 +64,7 @@ class SetBotShippingAnswerQuery final : public Td::ResultHandler {
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -88,10 +88,10 @@ class SetBotPreCheckoutAnswerQuery final : public Td::ResultHandler {
flags, false /*ignored*/, pre_checkout_query_id, error_message)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_setBotPrecheckoutResults>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
bool result = result_ptr.ok();
@ -101,7 +101,7 @@ class SetBotPreCheckoutAnswerQuery final : public Td::ResultHandler {
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -272,7 +272,7 @@ class GetPaymentFormQuery final : public Td::ResultHandler {
dialog_id_ = dialog_id;
auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read);
if (input_peer == nullptr) {
return on_error(0, Status::Error(400, "Can't access the chat"));
return on_error(Status::Error(400, "Can't access the chat"));
}
int32 flags = 0;
@ -283,10 +283,10 @@ class GetPaymentFormQuery final : public Td::ResultHandler {
flags, std::move(input_peer), server_message_id.get(), std::move(theme_parameters))));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::payments_getPaymentForm>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto payment_form = result_ptr.move_as_ok();
@ -297,12 +297,12 @@ class GetPaymentFormQuery final : public Td::ResultHandler {
UserId payments_provider_user_id(payment_form->provider_id_);
if (!payments_provider_user_id.is_valid()) {
LOG(ERROR) << "Receive invalid payments provider " << payments_provider_user_id;
return on_error(id, Status::Error(500, "Receive invalid payments provider identifier"));
return on_error(Status::Error(500, "Receive invalid payments provider identifier"));
}
UserId seller_bot_user_id(payment_form->bot_id_);
if (!seller_bot_user_id.is_valid()) {
LOG(ERROR) << "Receive invalid seller " << seller_bot_user_id;
return on_error(id, Status::Error(500, "Receive invalid seller identifier"));
return on_error(Status::Error(500, "Receive invalid seller identifier"));
}
bool can_save_credentials = payment_form->can_save_credentials_;
bool need_password = payment_form->password_missing_;
@ -315,7 +315,7 @@ class GetPaymentFormQuery final : public Td::ResultHandler {
convert_saved_credentials(std::move(payment_form->saved_credentials_)), can_save_credentials, need_password));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetPaymentFormQuery");
promise_.set_error(std::move(status));
}
@ -335,7 +335,7 @@ class ValidateRequestedInfoQuery final : public Td::ResultHandler {
dialog_id_ = dialog_id;
auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read);
if (input_peer == nullptr) {
return on_error(0, Status::Error(400, "Can't access the chat"));
return on_error(Status::Error(400, "Can't access the chat"));
}
int32 flags = 0;
@ -350,10 +350,10 @@ class ValidateRequestedInfoQuery final : public Td::ResultHandler {
flags, false /*ignored*/, std::move(input_peer), server_message_id.get(), std::move(requested_info))));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::payments_validateRequestedInfo>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto validated_order_info = result_ptr.move_as_ok();
@ -364,7 +364,7 @@ class ValidateRequestedInfoQuery final : public Td::ResultHandler {
transform(std::move(validated_order_info->shipping_options_), convert_shipping_option)));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
td->messages_manager_->on_get_dialog_error(dialog_id_, status, "ValidateRequestedInfoQuery");
promise_.set_error(std::move(status));
}
@ -387,7 +387,7 @@ class SendPaymentFormQuery final : public Td::ResultHandler {
dialog_id_ = dialog_id;
auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read);
if (input_peer == nullptr) {
return on_error(0, Status::Error(400, "Can't access the chat"));
return on_error(Status::Error(400, "Can't access the chat"));
}
int32 flags = 0;
@ -405,10 +405,10 @@ class SendPaymentFormQuery final : public Td::ResultHandler {
std::move(input_credentials), tip_amount)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::payments_sendPaymentForm>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto payment_result = result_ptr.move_as_ok();
@ -433,7 +433,7 @@ class SendPaymentFormQuery final : public Td::ResultHandler {
}
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
td->messages_manager_->on_get_dialog_error(dialog_id_, status, "SendPaymentFormQuery");
promise_.set_error(std::move(status));
}
@ -452,17 +452,17 @@ class GetPaymentReceiptQuery final : public Td::ResultHandler {
dialog_id_ = dialog_id;
auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read);
if (input_peer == nullptr) {
return on_error(0, Status::Error(400, "Can't access the chat"));
return on_error(Status::Error(400, "Can't access the chat"));
}
send_query(G()->net_query_creator().create(
telegram_api::payments_getPaymentReceipt(std::move(input_peer), server_message_id.get())));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::payments_getPaymentReceipt>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto payment_receipt = result_ptr.move_as_ok();
@ -473,12 +473,12 @@ class GetPaymentReceiptQuery final : public Td::ResultHandler {
UserId payments_provider_user_id(payment_receipt->provider_id_);
if (!payments_provider_user_id.is_valid()) {
LOG(ERROR) << "Receive invalid payments provider " << payments_provider_user_id;
return on_error(id, Status::Error(500, "Receive invalid payments provider identifier"));
return on_error(Status::Error(500, "Receive invalid payments provider identifier"));
}
UserId seller_bot_user_id(payment_receipt->bot_id_);
if (!seller_bot_user_id.is_valid()) {
LOG(ERROR) << "Receive invalid seller " << seller_bot_user_id;
return on_error(id, 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_);
@ -491,7 +491,7 @@ class GetPaymentReceiptQuery final : public Td::ResultHandler {
payment_receipt->tip_amount_));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetPaymentReceiptQuery");
promise_.set_error(std::move(status));
}
@ -508,10 +508,10 @@ class GetSavedInfoQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create(telegram_api::payments_getSavedInfo()));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::payments_getSavedInfo>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto saved_info = result_ptr.move_as_ok();
@ -519,7 +519,7 @@ class GetSavedInfoQuery final : public Td::ResultHandler {
promise_.set_value(convert_order_info(std::move(saved_info->saved_info_)));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -544,16 +544,16 @@ class ClearSavedInfoQuery final : public Td::ResultHandler {
telegram_api::payments_clearSavedInfo(flags, false /*ignored*/, false /*ignored*/)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::payments_clearSavedInfo>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -571,10 +571,10 @@ class GetBankCardInfoQuery final : public Td::ResultHandler {
G()->get_webfile_dc_id()));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::payments_getBankCardData>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto response = result_ptr.move_as_ok();
@ -584,7 +584,7 @@ class GetBankCardInfoQuery final : public Td::ResultHandler {
promise_.set_value(td_api::make_object<td_api::bankCardInfo>(response->title_, std::move(actions)));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};

View File

@ -72,16 +72,16 @@ class GetPollResultsQuery final : public Td::ResultHandler {
G()->net_query_creator().create(telegram_api::messages_getPollResults(std::move(input_peer), message_id)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_getPollResults>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
promise_.set_value(result_ptr.move_as_ok());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
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_;
@ -120,16 +120,16 @@ class GetPollVotersQuery final : public Td::ResultHandler {
flags, std::move(input_peer), message_id, std::move(option), offset, limit)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_getPollVotes>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
promise_.set_value(result_ptr.move_as_ok());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
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_;
@ -151,7 +151,7 @@ class SetPollAnswerActor final : public NetActorOnce {
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(0, Status::Error(400, "Can't access the chat"));
return on_error(Status::Error(400, "Can't access the chat"));
}
auto message_id = full_message_id.get_message_id().get_server_message_id().get();
@ -163,10 +163,10 @@ class SetPollAnswerActor final : public NetActorOnce {
std::move(query), actor_shared(this), sequence_id);
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_sendVote>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto result = result_ptr.move_as_ok();
@ -174,7 +174,7 @@ class SetPollAnswerActor final : public NetActorOnce {
promise_.set_value(std::move(result));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
td->messages_manager_->on_get_dialog_error(dialog_id_, status, "SetPollAnswerActor");
promise_.set_error(std::move(status));
}
@ -193,7 +193,7 @@ class StopPollActor final : public NetActorOnce {
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(0, Status::Error(400, "Can't access the chat"));
return on_error(Status::Error(400, "Can't access the chat"));
}
int32 flags = telegram_api::messages_editMessage::MEDIA_MASK;
@ -219,10 +219,10 @@ class StopPollActor final : public NetActorOnce {
}
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_editMessage>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto result = result_ptr.move_as_ok();
@ -230,7 +230,7 @@ class StopPollActor final : public NetActorOnce {
td->updates_manager_->on_get_updates(std::move(result), std::move(promise_));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
if (!td->auth_manager_->is_bot() && status.message() == "MESSAGE_NOT_MODIFIED") {
return promise_.set_value(Unit());
}

View File

@ -141,10 +141,10 @@ class SetSecureValueErrorsQuery final : public Td::ResultHandler {
telegram_api::users_setSecureValueErrors(std::move(input_user), std::move(input_errors))));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::users_setSecureValueErrors>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
bool ptr = result_ptr.move_as_ok();
@ -152,7 +152,7 @@ class SetSecureValueErrorsQuery final : public Td::ResultHandler {
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
if (status.code() != 0) {
promise_.set_error(std::move(status));
} else {

View File

@ -47,16 +47,16 @@ class GetSponsoredMessagesQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create(telegram_api::channels_getSponsoredMessages(std::move(input_channel))));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::channels_getSponsoredMessages>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
promise_.set_value(result_ptr.move_as_ok());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
td->contacts_manager_->on_get_channel_error(channel_id_, status, "GetSponsoredMessagesQuery");
promise_.set_error(std::move(status));
}
@ -80,16 +80,16 @@ class ViewSponsoredMessageQuery final : public Td::ResultHandler {
telegram_api::channels_viewSponsoredMessage(std::move(input_channel), BufferSlice(message_id))));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::channels_viewSponsoredMessage>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
td->contacts_manager_->on_get_channel_error(channel_id_, status, "ViewSponsoredMessageQuery");
promise_.set_error(std::move(status));
}

View File

@ -82,13 +82,13 @@ class GetAllStickersQuery final : public Td::ResultHandler {
}
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
static_assert(std::is_same<telegram_api::messages_getMaskStickers::ReturnType,
telegram_api::messages_getAllStickers::ReturnType>::value,
"");
auto result_ptr = fetch_result<telegram_api::messages_getAllStickers>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto ptr = result_ptr.move_as_ok();
@ -96,7 +96,7 @@ class GetAllStickersQuery final : public Td::ResultHandler {
td->stickers_manager_->on_get_installed_sticker_sets(is_masks_, std::move(ptr));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for get all stickers: " << status;
}
@ -113,10 +113,10 @@ class SearchStickersQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create(telegram_api::messages_getStickers(emoji_, hash)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_getStickers>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto ptr = result_ptr.move_as_ok();
@ -124,7 +124,7 @@ class SearchStickersQuery final : public Td::ResultHandler {
td->stickers_manager_->on_find_stickers_success(emoji_, std::move(ptr));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for search stickers: " << status;
}
@ -143,10 +143,10 @@ class GetEmojiKeywordsLanguageQuery final : public Td::ResultHandler {
send_query(
G()->net_query_creator().create(telegram_api::messages_getEmojiKeywordsLanguages(std::move(language_codes))));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_getEmojiKeywordsLanguages>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto result =
@ -154,7 +154,7 @@ class GetEmojiKeywordsLanguageQuery final : public Td::ResultHandler {
promise_.set_value(std::move(result));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -171,16 +171,16 @@ class GetEmojiKeywordsQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create(telegram_api::messages_getEmojiKeywords(language_code)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_getEmojiKeywords>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
promise_.set_value(result_ptr.move_as_ok());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -199,16 +199,16 @@ class GetEmojiKeywordsDifferenceQuery final : public Td::ResultHandler {
G()->net_query_creator().create(telegram_api::messages_getEmojiKeywordsDifference(language_code, version)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_getEmojiKeywordsDifference>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
promise_.set_value(result_ptr.move_as_ok());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -225,16 +225,16 @@ class GetEmojiUrlQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create(telegram_api::messages_getEmojiURL(language_code)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_getEmojiURL>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
promise_.set_value(result_ptr.move_as_ok());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -264,10 +264,10 @@ class GetArchivedStickerSetsQuery final : public Td::ResultHandler {
telegram_api::messages_getArchivedStickers(flags, is_masks /*ignored*/, offset_sticker_set_id.get(), limit)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_getArchivedStickers>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto ptr = result_ptr.move_as_ok();
@ -278,7 +278,7 @@ class GetArchivedStickerSetsQuery final : public Td::ResultHandler {
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -290,10 +290,10 @@ class GetFeaturedStickerSetsQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create(telegram_api::messages_getFeaturedStickers(hash)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_getFeaturedStickers>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto ptr = result_ptr.move_as_ok();
@ -301,7 +301,7 @@ class GetFeaturedStickerSetsQuery final : public Td::ResultHandler {
td->stickers_manager_->on_get_featured_sticker_sets(-1, -1, 0, std::move(ptr));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
td->stickers_manager_->on_get_featured_sticker_sets_failed(-1, -1, 0, std::move(status));
}
};
@ -320,10 +320,10 @@ class GetOldFeaturedStickerSetsQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create(telegram_api::messages_getOldFeaturedStickers(offset, limit, 0)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_getOldFeaturedStickers>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto ptr = result_ptr.move_as_ok();
@ -331,7 +331,7 @@ class GetOldFeaturedStickerSetsQuery final : public Td::ResultHandler {
td->stickers_manager_->on_get_featured_sticker_sets(offset_, limit_, generation_, std::move(ptr));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
td->stickers_manager_->on_get_featured_sticker_sets_failed(offset_, limit_, generation_, std::move(status));
}
};
@ -353,10 +353,10 @@ class GetAttachedStickerSetsQuery final : public Td::ResultHandler {
G()->net_query_creator().create(telegram_api::messages_getAttachedStickers(std::move(input_stickered_media))));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_getAttachedStickers>(packet);
if (result_ptr.is_error()) {
return on_error(id, 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());
@ -364,7 +364,7 @@ class GetAttachedStickerSetsQuery final : public Td::ResultHandler {
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
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_);
@ -402,10 +402,10 @@ class GetRecentStickersQuery final : public Td::ResultHandler {
telegram_api::messages_getRecentStickers(flags, is_attached /*ignored*/, hash)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_getRecentStickers>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto ptr = result_ptr.move_as_ok();
@ -414,7 +414,7 @@ class GetRecentStickersQuery final : public Td::ResultHandler {
td->stickers_manager_->on_get_recent_stickers(is_repair_, is_attached_, std::move(ptr));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for get recent " << (is_attached_ ? "attached " : "") << "stickers: " << status;
}
@ -451,10 +451,10 @@ class SaveRecentStickerQuery final : public Td::ResultHandler {
telegram_api::messages_saveRecentSticker(flags, is_attached /*ignored*/, std::move(input_document), unsave)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_saveRecentSticker>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
bool result = result_ptr.move_as_ok();
@ -466,7 +466,7 @@ class SaveRecentStickerQuery final : public Td::ResultHandler {
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
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_);
@ -511,10 +511,10 @@ class ClearRecentStickersQuery final : public Td::ResultHandler {
G()->net_query_creator().create(telegram_api::messages_clearRecentStickers(flags, is_attached /*ignored*/)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_clearRecentStickers>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
bool result = result_ptr.move_as_ok();
@ -526,7 +526,7 @@ class ClearRecentStickersQuery final : public Td::ResultHandler {
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for clear recent " << (is_attached_ ? "attached " : "") << "stickers: " << status;
}
@ -545,17 +545,17 @@ class GetFavedStickersQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create(telegram_api::messages_getFavedStickers(hash)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_getFavedStickers>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto ptr = result_ptr.move_as_ok();
td->stickers_manager_->on_get_favorite_stickers(is_repair_, std::move(ptr));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for get favorite stickers: " << status;
}
@ -584,10 +584,10 @@ class FaveStickerQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create(telegram_api::messages_faveSticker(std::move(input_document), unsave)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_faveSticker>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
bool result = result_ptr.move_as_ok();
@ -599,7 +599,7 @@ class FaveStickerQuery final : public Td::ResultHandler {
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
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_);
@ -638,19 +638,19 @@ class ReorderStickerSetsQuery final : public Td::ResultHandler {
flags, is_masks /*ignored*/, StickersManager::convert_sticker_set_ids(sticker_set_ids))));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_reorderStickerSets>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
bool result = result_ptr.move_as_ok();
if (!result) {
return on_error(id, Status::Error(400, "Result is false"));
return on_error(Status::Error(400, "Result is false"));
}
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for ReorderStickerSetsQuery: " << status;
}
@ -678,10 +678,10 @@ class GetStickerSetQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create(telegram_api::messages_getStickerSet(std::move(input_sticker_set))));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_getStickerSet>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto set = result_ptr.move_as_ok();
@ -701,7 +701,7 @@ class GetStickerSetQuery final : public Td::ResultHandler {
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
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);
promise_.set_error(std::move(status));
@ -717,10 +717,10 @@ class ReloadSpecialStickerSetQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create(telegram_api::messages_getStickerSet(type_.get_input_sticker_set())));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_getStickerSet>(packet);
if (result_ptr.is_error()) {
return on_error(id, 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(),
@ -728,11 +728,11 @@ class ReloadSpecialStickerSetQuery final : public Td::ResultHandler {
if (sticker_set_id.is_valid()) {
td->stickers_manager_->on_get_special_sticker_set(type_, sticker_set_id);
} else {
on_error(id, Status::Error(500, "Failed to add special sticker set"));
on_error(Status::Error(500, "Failed to add special sticker set"));
}
}
void on_error(uint64 id, Status status) final {
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));
}
@ -748,10 +748,10 @@ class SearchStickerSetsQuery final : public Td::ResultHandler {
G()->net_query_creator().create(telegram_api::messages_searchStickerSets(0, false /*ignored*/, query_, 0)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_searchStickerSets>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto ptr = result_ptr.move_as_ok();
@ -759,7 +759,7 @@ class SearchStickerSetsQuery final : public Td::ResultHandler {
td->stickers_manager_->on_find_sticker_sets_success(query_, std::move(ptr));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for search sticker sets: " << status;
}
@ -783,10 +783,10 @@ class InstallStickerSetQuery final : public Td::ResultHandler {
G()->net_query_creator().create(telegram_api::messages_installStickerSet(std::move(input_set), is_archived)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_installStickerSet>(packet);
if (result_ptr.is_error()) {
return on_error(id, 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());
@ -794,7 +794,7 @@ class InstallStickerSetQuery final : public Td::ResultHandler {
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
CHECK(status.is_error());
promise_.set_error(std::move(status));
}
@ -813,10 +813,10 @@ class UninstallStickerSetQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create(telegram_api::messages_uninstallStickerSet(std::move(input_set))));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_uninstallStickerSet>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
bool result = result_ptr.move_as_ok();
@ -829,7 +829,7 @@ class UninstallStickerSetQuery final : public Td::ResultHandler {
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
CHECK(status.is_error());
promise_.set_error(std::move(status));
}
@ -843,17 +843,17 @@ class ReadFeaturedStickerSetsQuery final : public Td::ResultHandler {
telegram_api::messages_readFeaturedStickers(StickersManager::convert_sticker_set_ids(sticker_set_ids))));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_readFeaturedStickers>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
bool result = result_ptr.move_as_ok();
(void)result;
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for ReadFeaturedStickerSetsQuery: " << status;
}
@ -880,16 +880,16 @@ class UploadStickerFileQuery final : public Td::ResultHandler {
telegram_api::messages_uploadMedia(std::move(input_peer), std::move(input_media))));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_uploadMedia>(packet);
if (result_ptr.is_error()) {
return on_error(id, 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_));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
CHECK(status.is_error());
if (was_uploaded_) {
CHECK(file_id_.is_valid());
@ -919,17 +919,17 @@ class SuggestStickerSetShortNameQuery final : public Td::ResultHandler {
void send(const string &title) {
send_query(G()->net_query_creator().create(telegram_api::stickers_suggestShortName(title)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::stickers_suggestShortName>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto ptr = result_ptr.move_as_ok();
promise_.set_value(std::move(ptr->short_name_));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
if (status.message() == "TITLE_INVALID") {
return promise_.set_value(string());
}
@ -948,16 +948,16 @@ class CheckStickerSetShortNameQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create(telegram_api::stickers_checkShortName(short_name)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::stickers_checkShortName>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
promise_.set_value(result_ptr.move_as_ok());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -990,10 +990,10 @@ class CreateNewStickerSetQuery final : public Td::ResultHandler {
title, short_name, nullptr, std::move(input_stickers), software)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::stickers_createStickerSet>(packet);
if (result_ptr.is_error()) {
return on_error(id, 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,
@ -1002,7 +1002,7 @@ class CreateNewStickerSetQuery final : public Td::ResultHandler {
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
CHECK(status.is_error());
promise_.set_error(std::move(status));
}
@ -1020,10 +1020,10 @@ class AddStickerToSetQuery final : public Td::ResultHandler {
make_tl_object<telegram_api::inputStickerSetShortName>(short_name), std::move(input_sticker))));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::stickers_addStickerToSet>(packet);
if (result_ptr.is_error()) {
return on_error(id, 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,
@ -1032,7 +1032,7 @@ class AddStickerToSetQuery final : public Td::ResultHandler {
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
CHECK(status.is_error());
promise_.set_error(std::move(status));
}
@ -1050,10 +1050,10 @@ class SetStickerSetThumbnailQuery final : public Td::ResultHandler {
make_tl_object<telegram_api::inputStickerSetShortName>(short_name), std::move(input_document))));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::stickers_setStickerSetThumb>(packet);
if (result_ptr.is_error()) {
return on_error(id, 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,
@ -1062,7 +1062,7 @@ class SetStickerSetThumbnailQuery final : public Td::ResultHandler {
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
CHECK(status.is_error());
promise_.set_error(std::move(status));
}
@ -1080,10 +1080,10 @@ class SetStickerPositionQuery final : public Td::ResultHandler {
telegram_api::stickers_changeStickerPosition(std::move(input_document), position)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::stickers_changeStickerPosition>(packet);
if (result_ptr.is_error()) {
return on_error(id, 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,
@ -1092,7 +1092,7 @@ class SetStickerPositionQuery final : public Td::ResultHandler {
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
CHECK(status.is_error());
promise_.set_error(std::move(status));
}
@ -1109,10 +1109,10 @@ class DeleteStickerFromSetQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create(telegram_api::stickers_removeStickerFromSet(std::move(input_document))));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::stickers_removeStickerFromSet>(packet);
if (result_ptr.is_error()) {
return on_error(id, 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,
@ -1121,7 +1121,7 @@ class DeleteStickerFromSetQuery final : public Td::ResultHandler {
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
CHECK(status.is_error());
promise_.set_error(std::move(status));
}
@ -1144,16 +1144,16 @@ class SendAnimatedEmojiClicksQuery final : public Td::ResultHandler {
telegram_api::messages_setTyping(flags, std::move(input_peer), 0, std::move(action))));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_setTyping>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
// ignore result
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
if (!td->messages_manager_->on_get_dialog_error(dialog_id_, status, "SendAnimatedEmojiClicksQuery")) {
LOG(INFO) << "Receive error for send animated emoji clicks: " << status;
}

View File

@ -161,9 +161,9 @@ void Td::ResultHandler::set_td(Td *new_td) {
void Td::ResultHandler::on_result(NetQueryPtr query) {
CHECK(query->is_ready());
if (query->is_ok()) {
on_result(query->id(), std::move(query->ok()));
on_result(std::move(query->ok()));
} else {
on_error(query->id(), std::move(query->error()));
on_error(std::move(query->error()));
}
query->clear();
}
@ -186,16 +186,16 @@ class GetPromoDataQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create(telegram_api::help_getPromoData()));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::help_getPromoData>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
promise_.set_value(result_ptr.move_as_ok());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -211,10 +211,10 @@ class GetRecentMeUrlsQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create(telegram_api::help_getRecentMeUrls(referrer)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::help_getRecentMeUrls>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto urls_full = result_ptr.move_as_ok();
@ -294,7 +294,7 @@ class GetRecentMeUrlsQuery final : public Td::ResultHandler {
promise_.set_value(std::move(results));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -312,17 +312,17 @@ class SendCustomRequestQuery final : public Td::ResultHandler {
telegram_api::bots_sendCustomRequest(method, make_tl_object<telegram_api::dataJSON>(parameters))));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::bots_sendCustomRequest>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto result = result_ptr.move_as_ok();
promise_.set_value(td_api::make_object<td_api::customRequestResult>(result->data_));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -339,10 +339,10 @@ class AnswerCustomQueryQuery final : public Td::ResultHandler {
telegram_api::bots_answerWebhookJSONQuery(custom_query_id, make_tl_object<telegram_api::dataJSON>(data))));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::bots_answerWebhookJSONQuery>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
bool result = result_ptr.ok();
@ -352,7 +352,7 @@ class AnswerCustomQueryQuery final : public Td::ResultHandler {
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -364,17 +364,17 @@ class SetBotUpdatesStatusQuery final : public Td::ResultHandler {
G()->net_query_creator().create(telegram_api::help_setBotUpdatesStatus(pending_update_count, error_message)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::help_setBotUpdatesStatus>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
bool result = result_ptr.ok();
LOG_IF(WARNING, !result) << "Set bot updates status has failed";
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
if (!G()->is_expected_error(status)) {
LOG(WARNING) << "Receive error for SetBotUpdatesStatusQuery: " << status;
}
@ -394,10 +394,10 @@ class UpdateStatusQuery final : public Td::ResultHandler {
return result;
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::account_updateStatus>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
bool result = result_ptr.ok();
@ -405,7 +405,7 @@ class UpdateStatusQuery final : public Td::ResultHandler {
td->on_update_status_success(!is_offline_);
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
if (status.code() != NetQuery::Canceled && !G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for UpdateStatusQuery: " << status;
}
@ -424,17 +424,17 @@ class GetInviteTextQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create(telegram_api::help_getInviteText()));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::help_getInviteText>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto result = result_ptr.move_as_ok();
promise_.set_value(std::move(result->message_));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -454,10 +454,10 @@ class SaveAppLogQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create_unauth(telegram_api::help_saveAppLog(std::move(input_app_events))));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::help_saveAppLog>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
bool result = result_ptr.move_as_ok();
@ -465,7 +465,7 @@ class SaveAppLogQuery final : public Td::ResultHandler {
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -481,17 +481,17 @@ class TestNetworkQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create_unauth(telegram_api::help_getConfig()));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::help_getConfig>(packet);
if (result_ptr.is_error()) {
return on_error(id, Status::Error(500, "Fetch failed"));
return on_error(Status::Error(500, "Fetch failed"));
}
LOG(DEBUG) << "TestNetwork OK: " << to_string(result_ptr.ok());
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
LOG(ERROR) << "Test query failed: " << status;
promise_.set_error(std::move(status));
}

View File

@ -209,10 +209,12 @@ class Td final : public Actor {
virtual ~ResultHandler() = default;
virtual void on_result(NetQueryPtr query);
virtual void on_result(uint64 id, BufferSlice packet) {
virtual void on_result(BufferSlice packet) {
UNREACHABLE();
}
virtual void on_error(uint64 id, Status status) {
virtual void on_error(Status status) {
UNREACHABLE();
}

View File

@ -30,10 +30,10 @@ class GetTermsOfServiceUpdateQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create(telegram_api::help_getTermsOfServiceUpdate()));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::help_getTermsOfServiceUpdate>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto result = result_ptr.move_as_ok();
@ -53,7 +53,7 @@ class GetTermsOfServiceUpdateQuery final : public Td::ResultHandler {
}
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -70,10 +70,10 @@ class AcceptTermsOfServiceQuery final : public Td::ResultHandler {
telegram_api::make_object<telegram_api::dataJSON>(terms_of_service_id))));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::help_acceptTermsOfService>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto result = result_ptr.ok();
@ -83,7 +83,7 @@ class AcceptTermsOfServiceQuery final : public Td::ResultHandler {
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};

View File

@ -36,16 +36,16 @@ class GetChatThemesQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create(telegram_api::account_getChatThemes(hash)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::account_getChatThemes>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
promise_.set_value(result_ptr.move_as_ok());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};

View File

@ -56,16 +56,16 @@ class GetTopPeersQuery final : public Td::ResultHandler {
false /*ignored*/, false /*ignored*/, false /*ignored*/, 0 /*offset*/, 100 /*limit*/, hash)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::contacts_getTopPeers>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
promise_.set_value(result_ptr.move_as_ok());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -81,16 +81,16 @@ class ToggleTopPeersQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create(telegram_api::contacts_toggleTopPeers(is_enabled)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::contacts_toggleTopPeers>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -110,16 +110,16 @@ class ResetTopPeerRatingQuery final : public Td::ResultHandler {
telegram_api::contacts_resetTopPeerRating(get_input_top_peer_category(category), std::move(input_peer))));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::contacts_resetTopPeerRating>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
// ignore the result
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
if (!td->messages_manager_->on_get_dialog_error(dialog_id_, status, "ResetTopPeerRatingQuery")) {
LOG(INFO) << "Receive error for ResetTopPeerRatingQuery: " << status;
}

View File

@ -98,16 +98,16 @@ class GetUpdatesStateQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create(telegram_api::updates_getState()));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::updates_getState>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
promise_.set_value(result_ptr.move_as_ok());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -124,16 +124,16 @@ class PingServerQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create(telegram_api::updates_getState()));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::updates_getState>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
promise_.set_value(result_ptr.move_as_ok());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};
@ -150,17 +150,17 @@ class GetDifferenceQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create(telegram_api::updates_getDifference(0, pts, 0, date, qts)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
VLOG(get_difference) << "Receive getDifference result of size " << packet.size();
auto result_ptr = fetch_result<telegram_api::updates_getDifference>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
promise_.set_value(result_ptr.move_as_ok());
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};

View File

@ -76,10 +76,10 @@ class GetWebPagePreviewQuery final : public Td::ResultHandler {
G()->net_query_creator().create(telegram_api::messages_getWebPagePreview(flags, text, std::move(entities))));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_getWebPagePreview>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto ptr = result_ptr.move_as_ok();
@ -87,7 +87,7 @@ class GetWebPagePreviewQuery final : public Td::ResultHandler {
td->web_pages_manager_->on_get_web_page_preview_success(request_id_, url_, std::move(ptr), std::move(promise_));
}
void on_error(uint64 id, 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_));
}
};
@ -107,10 +107,10 @@ class GetWebPageQuery final : public Td::ResultHandler {
send_query(G()->net_query_creator().create(telegram_api::messages_getWebPage(url, hash)));
}
void on_result(uint64 id, BufferSlice packet) final {
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::messages_getWebPage>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
return on_error(result_ptr.move_as_error());
}
auto ptr = result_ptr.move_as_ok();
@ -125,7 +125,7 @@ class GetWebPageQuery final : public Td::ResultHandler {
return promise_.set_value(std::move(web_page_id_));
} else {
LOG(ERROR) << "Receive webPageNotModified for " << url_;
return on_error(id, 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());
@ -133,7 +133,7 @@ class GetWebPageQuery final : public Td::ResultHandler {
promise_.set_value(std::move(web_page_id));
}
void on_error(uint64 id, Status status) final {
void on_error(Status status) final {
promise_.set_error(std::move(status));
}
};

View File

@ -22,9 +22,9 @@ void NetActor::set_parent(ActorShared<> parent) {
void NetActor::on_result(NetQueryPtr query) {
CHECK(query->is_ready());
if (query->is_ok()) {
on_result(query->id(), query->move_as_ok());
on_result(query->move_as_ok());
} else {
on_error(query->id(), query->move_as_error());
on_error(query->move_as_error());
}
on_result_finish();
}

View File

@ -22,14 +22,19 @@ class Td;
class NetActor : public NetQueryCallback {
public:
NetActor();
void set_parent(ActorShared<> parent);
void on_result(NetQueryPtr query) override;
virtual void on_result(uint64 id, BufferSlice packet) {
virtual void on_result(BufferSlice packet) {
UNREACHABLE();
}
virtual void on_error(uint64 id, Status status) {
virtual void on_error(Status status) {
UNREACHABLE();
}
virtual void on_result_finish() {
}
@ -41,7 +46,7 @@ class NetActor : public NetQueryCallback {
class NetActorOnce : public NetActor {
void hangup() override {
on_error(0, Global::request_aborted_error());
on_error(Global::request_aborted_error());
stop();
}