From 68b0a85369c159cfff6c5d9988a8f58e8c46db54 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 12 Mar 2021 16:48:00 +0400 Subject: [PATCH] Rename RPCError to MTP::Error. --- .../SourceFiles/api/api_attached_stickers.cpp | 2 +- .../SourceFiles/api/api_authorizations.cpp | 4 +- Telegram/SourceFiles/api/api_authorizations.h | 2 +- Telegram/SourceFiles/api/api_bot.cpp | 8 +- Telegram/SourceFiles/api/api_chat_invite.cpp | 2 +- Telegram/SourceFiles/api/api_editing.cpp | 8 +- Telegram/SourceFiles/api/api_editing.h | 9 +- .../SourceFiles/api/api_global_privacy.cpp | 4 +- Telegram/SourceFiles/api/api_invite_links.cpp | 14 +- .../SourceFiles/api/api_self_destruct.cpp | 4 +- Telegram/SourceFiles/api/api_sending.cpp | 4 +- .../SourceFiles/api/api_sensitive_content.cpp | 4 +- .../api/api_single_message_search.cpp | 6 +- .../SourceFiles/api/api_toggling_media.cpp | 2 +- Telegram/SourceFiles/api/api_updates.cpp | 12 +- Telegram/SourceFiles/api/api_updates.h | 9 +- Telegram/SourceFiles/apiwrap.cpp | 150 +++++++++--------- Telegram/SourceFiles/apiwrap.h | 18 +-- .../SourceFiles/boxes/add_contact_box.cpp | 20 +-- Telegram/SourceFiles/boxes/add_contact_box.h | 8 +- .../boxes/background_preview_box.cpp | 2 +- .../SourceFiles/boxes/change_phone_box.cpp | 16 +- Telegram/SourceFiles/boxes/confirm_box.cpp | 2 +- .../SourceFiles/boxes/confirm_phone_box.cpp | 12 +- .../SourceFiles/boxes/confirm_phone_box.h | 4 +- .../SourceFiles/boxes/edit_caption_box.cpp | 2 +- Telegram/SourceFiles/boxes/passcode_box.cpp | 44 ++--- Telegram/SourceFiles/boxes/passcode_box.h | 12 +- .../boxes/peer_list_controllers.cpp | 4 +- .../boxes/peers/add_participants_box.cpp | 8 +- .../boxes/peers/edit_contact_box.cpp | 2 +- .../boxes/peers/edit_participant_box.cpp | 6 +- .../boxes/peers/edit_participant_box.h | 6 +- .../boxes/peers/edit_participants_box.cpp | 16 +- .../boxes/peers/edit_peer_info_box.cpp | 24 +-- .../boxes/peers/edit_peer_invite_link.cpp | 2 +- .../boxes/peers/edit_peer_permissions_box.cpp | 2 +- .../boxes/peers/edit_peer_type_box.cpp | 2 +- Telegram/SourceFiles/boxes/rate_call_box.cpp | 2 +- Telegram/SourceFiles/boxes/sessions_box.cpp | 4 +- Telegram/SourceFiles/boxes/share_box.cpp | 4 +- Telegram/SourceFiles/boxes/share_box.h | 2 +- .../SourceFiles/boxes/sticker_set_box.cpp | 4 +- Telegram/SourceFiles/boxes/stickers_box.cpp | 6 +- Telegram/SourceFiles/boxes/stickers_box.h | 2 +- Telegram/SourceFiles/boxes/url_auth_box.cpp | 8 +- Telegram/SourceFiles/boxes/username_box.cpp | 8 +- Telegram/SourceFiles/boxes/username_box.h | 4 +- .../calls/calls_box_controller.cpp | 2 +- Telegram/SourceFiles/calls/calls_call.cpp | 14 +- Telegram/SourceFiles/calls/calls_call.h | 2 +- .../calls/calls_choose_join_as.cpp | 2 +- .../SourceFiles/calls/calls_group_call.cpp | 24 +-- Telegram/SourceFiles/calls/calls_group_call.h | 2 +- Telegram/SourceFiles/calls/calls_instance.cpp | 4 +- .../chat_helpers/emoji_keywords.cpp | 4 +- .../chat_helpers/gifs_list_widget.cpp | 2 +- .../chat_helpers/stickers_dice_pack.cpp | 2 +- .../chat_helpers/stickers_emoji_pack.cpp | 2 +- .../chat_helpers/stickers_list_widget.cpp | 6 +- Telegram/SourceFiles/core/update_checker.cpp | 6 +- .../SourceFiles/data/data_chat_filters.cpp | 6 +- .../SourceFiles/data/data_cloud_themes.cpp | 6 +- Telegram/SourceFiles/data/data_group_call.cpp | 6 +- Telegram/SourceFiles/data/data_histories.cpp | 18 +-- .../SourceFiles/data/data_replies_list.cpp | 6 +- .../data/data_scheduled_messages.cpp | 2 +- .../data/data_search_controller.cpp | 2 +- .../data/stickers/data_stickers.cpp | 2 +- .../dialogs/dialogs_inner_widget.h | 4 +- .../SourceFiles/dialogs/dialogs_widget.cpp | 16 +- Telegram/SourceFiles/dialogs/dialogs_widget.h | 8 +- .../SourceFiles/export/export_api_wrap.cpp | 34 ++-- Telegram/SourceFiles/export/export_api_wrap.h | 6 +- .../SourceFiles/export/export_controller.cpp | 4 +- .../SourceFiles/export/export_controller.h | 4 +- .../admin_log/history_admin_log_inner.cpp | 4 +- .../SourceFiles/history/history_message.cpp | 2 +- .../SourceFiles/history/history_widget.cpp | 16 +- Telegram/SourceFiles/history/history_widget.h | 9 +- .../history_view_compose_controls.cpp | 4 +- .../controls/history_view_compose_controls.h | 2 +- .../view/controls/history_view_ttl_button.cpp | 2 +- .../view/history_view_context_menu.cpp | 4 +- .../view/history_view_replies_section.cpp | 2 +- .../view/history_view_scheduled_section.cpp | 2 +- .../polls/info_polls_results_inner_widget.cpp | 2 +- .../inline_bots/inline_results_widget.cpp | 2 +- Telegram/SourceFiles/intro/intro_code.cpp | 14 +- Telegram/SourceFiles/intro/intro_code.h | 4 +- .../intro/intro_password_check.cpp | 16 +- .../SourceFiles/intro/intro_password_check.h | 6 +- Telegram/SourceFiles/intro/intro_phone.cpp | 6 +- Telegram/SourceFiles/intro/intro_phone.h | 2 +- Telegram/SourceFiles/intro/intro_qr.cpp | 8 +- Telegram/SourceFiles/intro/intro_qr.h | 2 +- Telegram/SourceFiles/intro/intro_signup.cpp | 6 +- Telegram/SourceFiles/intro/intro_signup.h | 2 +- Telegram/SourceFiles/intro/intro_step.cpp | 2 +- Telegram/SourceFiles/intro/intro_widget.cpp | 2 +- .../SourceFiles/lang/lang_cloud_manager.cpp | 10 +- Telegram/SourceFiles/main/main_account.cpp | 2 +- Telegram/SourceFiles/main/main_app_config.cpp | 2 +- Telegram/SourceFiles/mainwidget.cpp | 4 +- Telegram/SourceFiles/mainwidget.h | 7 +- Telegram/SourceFiles/mtproto/config_loader.h | 2 +- .../mtproto/dedicated_file_loader.cpp | 14 +- .../mtproto/dedicated_file_loader.h | 14 +- Telegram/SourceFiles/mtproto/mtp_instance.cpp | 74 ++++----- Telegram/SourceFiles/mtproto/mtp_instance.h | 6 +- .../mtproto/mtproto_concurrent_sender.cpp | 21 ++- .../mtproto/mtproto_concurrent_sender.h | 34 ++-- ...to_rpc_sender.cpp => mtproto_response.cpp} | 25 +-- ...tproto_rpc_sender.h => mtproto_response.h} | 24 +-- Telegram/SourceFiles/mtproto/sender.h | 26 +-- Telegram/SourceFiles/mtproto/session.h | 2 +- .../SourceFiles/mtproto/session_private.cpp | 2 +- .../passport/passport_form_controller.cpp | 36 ++--- .../passport/passport_form_controller.h | 2 +- .../SourceFiles/settings/settings_main.cpp | 2 +- .../settings/settings_privacy_controllers.cpp | 2 +- .../storage/download_manager_mtproto.cpp | 26 +-- .../storage/download_manager_mtproto.h | 11 +- Telegram/SourceFiles/storage/file_upload.cpp | 8 +- Telegram/SourceFiles/storage/file_upload.h | 2 +- .../SourceFiles/support/support_helper.cpp | 4 +- .../window/themes/window_theme_editor_box.cpp | 10 +- .../SourceFiles/window/window_peer_menu.cpp | 4 +- .../window/window_session_controller.cpp | 6 +- Telegram/cmake/td_mtproto.cmake | 4 +- 130 files changed, 609 insertions(+), 594 deletions(-) rename Telegram/SourceFiles/mtproto/{mtproto_rpc_sender.cpp => mtproto_response.cpp} (76%) rename Telegram/SourceFiles/mtproto/{mtproto_rpc_sender.h => mtproto_response.h} (67%) diff --git a/Telegram/SourceFiles/api/api_attached_stickers.cpp b/Telegram/SourceFiles/api/api_attached_stickers.cpp index dc38822da..65cf9efd9 100644 --- a/Telegram/SourceFiles/api/api_attached_stickers.cpp +++ b/Telegram/SourceFiles/api/api_attached_stickers.cpp @@ -55,7 +55,7 @@ void AttachedStickers::request( Ui::show( Box(strongController, setId), Ui::LayerOption::KeepOther); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _requestId = 0; Ui::show(Box(tr::lng_stickers_not_found(tr::now))); }).send(); diff --git a/Telegram/SourceFiles/api/api_authorizations.cpp b/Telegram/SourceFiles/api/api_authorizations.cpp index b0a99e929..8e849e1b6 100644 --- a/Telegram/SourceFiles/api/api_authorizations.cpp +++ b/Telegram/SourceFiles/api/api_authorizations.cpp @@ -112,7 +112,7 @@ void Authorizations::reload() { }) | ranges::to; _listChanges.fire({}); }); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _requestId = 0; }).send(); } @@ -123,7 +123,7 @@ void Authorizations::cancelCurrentRequest() { void Authorizations::requestTerminate( Fn &&done, - Fn &&fail, + Fn &&fail, std::optional hash) { const auto send = [&](auto request) { _api.request( diff --git a/Telegram/SourceFiles/api/api_authorizations.h b/Telegram/SourceFiles/api/api_authorizations.h index ba2377d68..96e036199 100644 --- a/Telegram/SourceFiles/api/api_authorizations.h +++ b/Telegram/SourceFiles/api/api_authorizations.h @@ -30,7 +30,7 @@ public: void cancelCurrentRequest(); void requestTerminate( Fn &&done, - Fn &&fail, + Fn &&fail, std::optional hash = std::nullopt); [[nodiscard]] crl::time lastReceivedTime(); diff --git a/Telegram/SourceFiles/api/api_bot.cpp b/Telegram/SourceFiles/api/api_bot.cpp index d8824cf20..516f37227 100644 --- a/Telegram/SourceFiles/api/api_bot.cpp +++ b/Telegram/SourceFiles/api/api_bot.cpp @@ -34,7 +34,7 @@ void SendBotCallbackData( int row, int column, std::optional password = std::nullopt, - Fn handleError = nullptr) { + Fn handleError = nullptr) { if (!IsServerMsgId(item->id)) { return; } @@ -115,7 +115,7 @@ void SendBotCallbackData( Ui::hideLayer(); } }); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { const auto item = owner->message(fullId); if (!item) { return; @@ -170,7 +170,7 @@ void SendBotCallbackDataWithPassword( return; } api->reloadPasswordState(); - SendBotCallbackData(item, row, column, MTP_inputCheckPasswordEmpty(), [=](const RPCError &error) { + SendBotCallbackData(item, row, column, MTP_inputCheckPasswordEmpty(), [=](const MTP::Error &error) { auto box = PrePasswordErrorBox( error, session, @@ -212,7 +212,7 @@ void SendBotCallbackDataWithPassword( return; } if (const auto item = owner->message(fullId)) { - SendBotCallbackData(item, row, column, result.result, [=](const RPCError &error) { + SendBotCallbackData(item, row, column, result.result, [=](const MTP::Error &error) { if (*box) { (*box)->handleCustomCheckError(error); } diff --git a/Telegram/SourceFiles/api/api_chat_invite.cpp b/Telegram/SourceFiles/api/api_chat_invite.cpp index 020f2775c..183864479 100644 --- a/Telegram/SourceFiles/api/api_chat_invite.cpp +++ b/Telegram/SourceFiles/api/api_chat_invite.cpp @@ -75,7 +75,7 @@ void CheckChatInvite( } } }); - }, [=](const RPCError &error) { + }, [=](const MTP::Error &error) { if (error.code() != 400) { return; } diff --git a/Telegram/SourceFiles/api/api_editing.cpp b/Telegram/SourceFiles/api/api_editing.cpp index b5a2e1085..c0a67e28e 100644 --- a/Telegram/SourceFiles/api/api_editing.cpp +++ b/Telegram/SourceFiles/api/api_editing.cpp @@ -17,7 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/history_item.h" #include "lang/lang_keys.h" #include "main/main_session.h" -#include "mtproto/mtproto_rpc_sender.h" +#include "mtproto/mtproto_response.h" namespace Api { namespace { @@ -131,7 +131,7 @@ void EditMessageWithUploadedMedia( item->setIsLocalUpdateMedia(false); } }; - const auto fail = [=](const RPCError &error) { + const auto fail = [=](const MTP::Error &error) { const auto err = error.type(); const auto session = &item->history()->session(); const auto notModified = (err == u"MESSAGE_NOT_MODIFIED"_q); @@ -189,7 +189,7 @@ mtpRequestId EditCaption( const TextWithEntities &caption, SendOptions options, Fn done, - Fn fail) { + Fn fail) { return EditMessage(item, caption, options, done, fail); } @@ -198,7 +198,7 @@ mtpRequestId EditTextMessage( const TextWithEntities &caption, SendOptions options, Fn done, - Fn fail) { + Fn fail) { const auto callback = [=]( const auto &result, Fn applyUpdates, diff --git a/Telegram/SourceFiles/api/api_editing.h b/Telegram/SourceFiles/api/api_editing.h index d433aa0ae..8e1e56fb2 100644 --- a/Telegram/SourceFiles/api/api_editing.h +++ b/Telegram/SourceFiles/api/api_editing.h @@ -8,7 +8,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #pragma once class HistoryItem; -class RPCError; + +namespace MTP { +class Error; +} // namespace MTP namespace Api { @@ -40,13 +43,13 @@ mtpRequestId EditCaption( const TextWithEntities &caption, SendOptions options, Fn done, - Fn fail); + Fn fail); mtpRequestId EditTextMessage( not_null item, const TextWithEntities &caption, SendOptions options, Fn done, - Fn fail); + Fn fail); } // namespace Api diff --git a/Telegram/SourceFiles/api/api_global_privacy.cpp b/Telegram/SourceFiles/api/api_global_privacy.cpp index 5d07ab79a..3d2c1d462 100644 --- a/Telegram/SourceFiles/api/api_global_privacy.cpp +++ b/Telegram/SourceFiles/api/api_global_privacy.cpp @@ -33,7 +33,7 @@ void GlobalPrivacy::reload(Fn callback) { for (const auto &callback : base::take(_callbacks)) { callback(); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _requestId = 0; for (const auto &callback : base::take(_callbacks)) { callback(); @@ -86,7 +86,7 @@ void GlobalPrivacy::update(bool archiveAndMute) { )).done([=](const MTPGlobalPrivacySettings &result) { _requestId = 0; apply(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _requestId = 0; }).send(); _archiveAndMute = archiveAndMute; diff --git a/Telegram/SourceFiles/api/api_invite_links.cpp b/Telegram/SourceFiles/api/api_invite_links.cpp index 5bc25514b..6d4415f67 100644 --- a/Telegram/SourceFiles/api/api_invite_links.cpp +++ b/Telegram/SourceFiles/api/api_invite_links.cpp @@ -110,7 +110,7 @@ void InviteLinks::performCreate( callback(link); } } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _createCallbacks.erase(peer); }).send(); } @@ -282,7 +282,7 @@ void InviteLinks::performEdit( prepend(peer, admin, data.vnew_invite()); } }); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _editCallbacks.erase(key); }).send(); } @@ -344,7 +344,7 @@ void InviteLinks::destroy( .admin = admin, .was = key.link, }); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _deleteCallbacks.erase(key); }).send(); } @@ -374,7 +374,7 @@ void InviteLinks::destroyAllRevoked( } } _allRevokedDestroyed.fire({ peer, admin }); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { }).send(); } @@ -415,7 +415,7 @@ void InviteLinks::requestMyLinks(not_null peer) { i->second.count = std::max(slice.count, int(existing.size())); } notify(peer); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _firstSliceRequests.remove(peer); }).send(); _firstSliceRequests.emplace(peer, requestId); @@ -493,7 +493,7 @@ void InviteLinks::requestJoinedFirstSlice(LinkKey key) { _firstJoinedRequests.remove(key); _firstJoined[key] = ParseJoinedByLinkSlice(key.peer, result); _joinedFirstSliceLoaded.fire_copy(key); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _firstJoinedRequests.remove(key); }).send(); _firstJoinedRequests.emplace(key, requestId); @@ -653,7 +653,7 @@ void InviteLinks::requestMoreLinks( MTP_int(kPerPage) )).done([=](const MTPmessages_ExportedChatInvites &result) { done(parseSlice(peer, result)); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { done(Links()); }).send(); } diff --git a/Telegram/SourceFiles/api/api_self_destruct.cpp b/Telegram/SourceFiles/api/api_self_destruct.cpp index 64cf1a5b2..ea7de681b 100644 --- a/Telegram/SourceFiles/api/api_self_destruct.cpp +++ b/Telegram/SourceFiles/api/api_self_destruct.cpp @@ -25,7 +25,7 @@ void SelfDestruct::reload() { result.match([&](const MTPDaccountDaysTTL &data) { _days = data.vdays().v; }); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _requestId = 0; }).send(); } @@ -42,7 +42,7 @@ void SelfDestruct::update(int days) { MTP_accountDaysTTL(MTP_int(days)) )).done([=](const MTPBool &result) { _requestId = 0; - }).fail([=](const RPCError &result) { + }).fail([=](const MTP::Error &result) { _requestId = 0; }).send(); _days = days; diff --git a/Telegram/SourceFiles/api/api_sending.cpp b/Telegram/SourceFiles/api/api_sending.cpp index 076c6e43a..48e6440bb 100644 --- a/Telegram/SourceFiles/api/api_sending.cpp +++ b/Telegram/SourceFiles/api/api_sending.cpp @@ -150,7 +150,7 @@ void SendExistingMedia( )).done([=](const MTPUpdates &result) { api->applyUpdates(result, randomId); finish(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { if (error.code() == 400 && error.type().startsWith(qstr("FILE_REFERENCE_"))) { api->refreshFileReference(origin, [=](const auto &result) { @@ -324,7 +324,7 @@ bool SendDice(Api::MessageToSend &message) { )).done([=](const MTPUpdates &result) { api->applyUpdates(result, randomId); finish(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { api->sendMessageFail(error, peer, randomId, newId); finish(); }).afterRequest(history->sendRequestId diff --git a/Telegram/SourceFiles/api/api_sensitive_content.cpp b/Telegram/SourceFiles/api/api_sensitive_content.cpp index 02fea25ba..a18967368 100644 --- a/Telegram/SourceFiles/api/api_sensitive_content.cpp +++ b/Telegram/SourceFiles/api/api_sensitive_content.cpp @@ -36,7 +36,7 @@ void SensitiveContent::reload() { _enabled = data.is_sensitive_enabled(); _canChange = data.is_sensitive_can_change(); }); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _requestId = 0; }).send(); } @@ -63,7 +63,7 @@ void SensitiveContent::update(bool enabled) { MTP_flags(enabled ? Flag::f_sensitive_enabled : Flag(0)) )).done([=](const MTPBool &result) { _requestId = 0; - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _requestId = 0; }).send(); _enabled = enabled; diff --git a/Telegram/SourceFiles/api/api_single_message_search.cpp b/Telegram/SourceFiles/api/api_single_message_search.cpp index fc9829b2b..9f39f372d 100644 --- a/Telegram/SourceFiles/api/api_single_message_search.cpp +++ b/Telegram/SourceFiles/api/api_single_message_search.cpp @@ -117,7 +117,7 @@ std::optional SingleMessageSearch::performLookupByChannel( } else { fail(); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { fail(); }).send(); @@ -154,7 +154,7 @@ std::optional SingleMessageSearch::performLookupById( fail(); } }); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { fail(); }).send(); @@ -198,7 +198,7 @@ std::optional SingleMessageSearch::performLookupByUsername( fail(); } }); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { fail(); }).send(); diff --git a/Telegram/SourceFiles/api/api_toggling_media.cpp b/Telegram/SourceFiles/api/api_toggling_media.cpp index e1f542b3c..37869c29d 100644 --- a/Telegram/SourceFiles/api/api_toggling_media.cpp +++ b/Telegram/SourceFiles/api/api_toggling_media.cpp @@ -33,7 +33,7 @@ void ToggleExistingMedia( if (mtpIsTrue(result)) { done(); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { if (error.code() == 400 && error.type().startsWith(u"FILE_REFERENCE_"_q)) { auto refreshed = [=](const Data::UpdatedFileReferences &d) { diff --git a/Telegram/SourceFiles/api/api_updates.cpp b/Telegram/SourceFiles/api/api_updates.cpp index 70610ac41..69dce85e9 100644 --- a/Telegram/SourceFiles/api/api_updates.cpp +++ b/Telegram/SourceFiles/api/api_updates.cpp @@ -398,7 +398,7 @@ void Updates::feedChannelDifference( void Updates::channelDifferenceFail( not_null channel, - const RPCError &error) { + const MTP::Error &error) { LOG(("RPC Error in getChannelDifference: %1 %2: %3" ).arg(error.code() ).arg(error.type() @@ -556,7 +556,7 @@ void Updates::feedDifference( feedUpdateVector(other, true); } -void Updates::differenceFail(const RPCError &error) { +void Updates::differenceFail(const MTP::Error &error) { LOG(("RPC Error in getDifference: %1 %2: %3" ).arg(error.code() ).arg(error.type() @@ -643,7 +643,7 @@ void Updates::getDifference() { MTP_int(_updatesQts) )).done([=](const MTPupdates_Difference &result) { differenceDone(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { differenceFail(error); }).send(); } @@ -678,7 +678,7 @@ void Updates::getChannelDifference( MTP_int(kChannelGetDifferenceLimit) )).done([=](const MTPupdates_ChannelDifference &result) { channelDifferenceDone(channel, result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { channelDifferenceFail(channel, error); }).send(); } @@ -742,7 +742,7 @@ void Updates::channelRangeDifferenceSend( )).done([=](const MTPupdates_ChannelDifference &result) { _rangeDifferenceRequests.remove(channel); channelRangeDifferenceDone(channel, range, result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _rangeDifferenceRequests.remove(channel); }).send(); _rangeDifferenceRequests.emplace(channel, requestId); @@ -862,7 +862,7 @@ void Updates::updateOnline(bool gotOtherOffline) { MTP_bool(!isOnline) )).done([=](const MTPBool &result) { Core::App().quitPreventFinished(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { Core::App().quitPreventFinished(); }).send(); } diff --git a/Telegram/SourceFiles/api/api_updates.h b/Telegram/SourceFiles/api/api_updates.h index 17f8cc9f8..fbc7d3209 100644 --- a/Telegram/SourceFiles/api/api_updates.h +++ b/Telegram/SourceFiles/api/api_updates.h @@ -10,10 +10,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_pts_waiter.h" #include "base/timer.h" -class RPCError; class ApiWrap; class History; +namespace MTP { +class Error; +} // namespace MTP + namespace Main { class Session; } // namespace Main @@ -89,7 +92,7 @@ private: not_null channel, ChannelDifferenceRequest from = ChannelDifferenceRequest::Unknown); void differenceDone(const MTPupdates_Difference &result); - void differenceFail(const RPCError &error); + void differenceFail(const MTP::Error &error); void feedDifference( const MTPVector &users, const MTPVector &chats, @@ -102,7 +105,7 @@ private: const MTPupdates_ChannelDifference &diff); void channelDifferenceFail( not_null channel, - const RPCError &error); + const MTP::Error &error); void failDifferenceStartTimerFor(ChannelData *channel); void feedChannelDifference(const MTPDupdates_channelDifference &data); diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index 01ffbd175..6f58543db 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -279,7 +279,7 @@ void ApiWrap::refreshTopPromotion() { )).done([=](const MTPhelp_PromoData &result) { _topPromotionRequestId = 0; topPromotionDone(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _topPromotionRequestId = 0; const auto now = base::unixtime::now(); const auto next = _topPromotionNextRequestTime = now @@ -329,7 +329,7 @@ void ApiWrap::requestDeepLinkInfo( if (result.type() == mtpc_help_deepLinkInfo) { callback(result.c_help_deepLinkInfo()); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _deepLinkInfoRequestId = 0; }).send(); } @@ -376,7 +376,7 @@ void ApiWrap::requestTermsUpdate() { } break; default: Unexpected("Type in requestTermsUpdate()."); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _termsUpdateRequestId = 0; _termsUpdateSendAt = crl::now() + kTermsUpdateTimeoutMin; requestTermsUpdate(); @@ -394,7 +394,7 @@ void ApiWrap::acceptTerms(bytes::const_span id) { void ApiWrap::checkChatInvite( const QString &hash, FnMut done, - Fn fail) { + Fn fail) { request(base::take(_checkInviteRequestId)).cancel(); _checkInviteRequestId = request(MTPmessages_CheckChatInvite( MTP_string(hash) @@ -436,7 +436,7 @@ void ApiWrap::importChatInvite(const QString &hash) { LOG(("API Error: unexpected update cons %1 " "(ApiWrap::importChatInvite)").arg(result.type())); }); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { const auto &type = error.type(); if (type == qstr("CHANNELS_TOO_MUCH")) { Ui::show(Box(tr::lng_join_channel_error(tr::now))); @@ -501,14 +501,14 @@ void ApiWrap::toggleHistoryArchived( if (isPinned) { _session->data().notifyPinnedDialogsOrderUpdated(); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _historyArchivedRequests.remove(history); }).send(); _historyArchivedRequests.emplace(history, requestId, callback); } void ApiWrap::sendMessageFail( - const RPCError &error, + const MTP::Error &error, not_null peer, uint64 randomId, FullMsgId itemId) { @@ -591,7 +591,7 @@ void ApiWrap::resolveMessageDatas() { MTP_vector(ids) )).done([this](const MTPmessages_Messages &result, mtpRequestId requestId) { gotMessageDatas(nullptr, result, requestId); - }).fail([this](const RPCError &error, mtpRequestId requestId) { + }).fail([this](const MTP::Error &error, mtpRequestId requestId) { finalizeMessageDataRequest(nullptr, requestId); }).afterDelay(kSmallDelayMs).send(); for (auto &request : _messageDataRequests) { @@ -612,7 +612,7 @@ void ApiWrap::resolveMessageDatas() { MTP_vector(ids) )).done([=](const MTPmessages_Messages &result, mtpRequestId requestId) { gotMessageDatas(channel, result, requestId); - }).fail([=](const RPCError &error, mtpRequestId requestId) { + }).fail([=](const MTP::Error &error, mtpRequestId requestId) { finalizeMessageDataRequest(channel, requestId); }).afterDelay(kSmallDelayMs).send(); @@ -782,7 +782,7 @@ void ApiWrap::requestContacts() { } } _session->data().contactsLoaded() = true; - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _contactsRequestId = 0; }).send(); } @@ -856,7 +856,7 @@ void ApiWrap::requestMoreDialogs(Data::Folder *folder) { } requestMoreDialogsIfNeeded(); _session->data().chatsListChanged(folder); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { dialogsLoadState(folder)->requestId = 0; }).send(); @@ -1001,7 +1001,7 @@ void ApiWrap::requestPinnedDialogs(Data::Folder *folder) { _session->data().chatsListChanged(folder); _session->data().notifyPinnedDialogsOrderUpdated(); }); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { finalize(); }).send(); } @@ -1029,7 +1029,7 @@ rpl::producer ApiWrap::dialogsLoadBlockedByDate() const { void ApiWrap::requestWallPaper( const QString &slug, Fn done, - Fn fail) { + Fn fail) { if (_wallPaperSlug != slug) { _wallPaperSlug = slug; if (_wallPaperRequestId) { @@ -1051,9 +1051,9 @@ void ApiWrap::requestWallPaper( done(*paper); } } else if (const auto fail = base::take(_wallPaperFail)) { - fail(RPCError::Local("BAD_DOCUMENT", "In a wallpaper.")); + fail(MTP::Error::Local("BAD_DOCUMENT", "In a wallpaper.")); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _wallPaperRequestId = 0; _wallPaperSlug = QString(); if (const auto fail = base::take(_wallPaperFail)) { @@ -1068,7 +1068,7 @@ void ApiWrap::requestFullPeer(not_null peer) { } const auto requestId = [&] { - const auto failHandler = [=](const RPCError &error) { + const auto failHandler = [=](const MTP::Error &error) { _fullPeerRequests.remove(peer); migrateFail(peer, error); }; @@ -1180,7 +1180,7 @@ void ApiWrap::requestPeer(not_null peer) { } const auto requestId = [&] { - const auto failHandler = [=](const RPCError &error) { + const auto failHandler = [=](const MTP::Error &error) { _peerRequests.remove(peer); }; const auto chatHandler = [=](const MTPmessages_Chats &result) { @@ -1223,7 +1223,7 @@ void ApiWrap::requestPeerSettings(not_null peer) { return data.vflags().v; })); _requestedPeerSettings.erase(peer); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _requestedPeerSettings.erase(peer); }).send(); } @@ -1231,7 +1231,7 @@ void ApiWrap::requestPeerSettings(not_null peer) { void ApiWrap::migrateChat( not_null chat, FnMut)> done, - Fn fail) { + Fn fail) { const auto callback = [&] { return MigrateCallbacks{ std::move(done), std::move(fail) }; }; @@ -1252,7 +1252,7 @@ void ApiWrap::migrateChat( crl::on_main([=] { migrateFail( chat, - RPCError::Local( + MTP::Error::Local( "BAD_MIGRATION", "Chat is already deactivated")); }); @@ -1261,7 +1261,7 @@ void ApiWrap::migrateChat( crl::on_main([=] { migrateFail( chat, - RPCError::Local( + MTP::Error::Local( "BAD_MIGRATION", "Current user is not the creator of that chat")); }); @@ -1282,9 +1282,9 @@ void ApiWrap::migrateChat( } else { migrateFail( chat, - RPCError::Local("MIGRATION_FAIL", "No channel")); + MTP::Error::Local("MIGRATION_FAIL", "No channel")); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { migrateFail(chat, error); }).send(); } @@ -1302,7 +1302,7 @@ void ApiWrap::migrateDone( } } -void ApiWrap::migrateFail(not_null peer, const RPCError &error) { +void ApiWrap::migrateFail(not_null peer, const MTP::Error &error) { const auto &type = error.type(); if (type == qstr("CHANNELS_TOO_MUCH")) { Ui::show(Box(tr::lng_migrate_error(tr::now))); @@ -1446,7 +1446,7 @@ void ApiWrap::requestLastParticipants(not_null channel) { availableCount, list); }); - }).fail([this, channel](const RPCError &error) { + }).fail([this, channel](const MTP::Error &error) { _participantsRequests.remove(channel); }).send(); @@ -1476,7 +1476,7 @@ void ApiWrap::requestBots(not_null channel) { availableCount, list); }); - }).fail([this, channel](const RPCError &error) { + }).fail([this, channel](const MTP::Error &error) { _botsRequests.remove(channel); }).send(); @@ -1503,7 +1503,7 @@ void ApiWrap::requestAdmins(not_null channel) { }, [&](const MTPDchannels_channelParticipantsNotModified &) { LOG(("API Error: channels.channelParticipantsNotModified received!")); }); - }).fail([this, channel](const RPCError &error) { + }).fail([this, channel](const MTP::Error &error) { _adminsRequests.remove(channel); }).send(); @@ -1687,7 +1687,7 @@ void ApiWrap::requestSelfParticipant(not_null channel) { finalize(-1, 0); }); }); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _selfParticipantRequests.erase(channel); if (error.type() == qstr("CHANNEL_PRIVATE")) { channel->privateErrorReceived(); @@ -1725,7 +1725,7 @@ void ApiWrap::kickParticipant( _kickRequests.remove(KickRequest(channel, user)); channel->applyEditBanned(user, currentRights, rights); - }).fail([this, kick](const RPCError &error) { + }).fail([this, kick](const MTP::Error &error) { _kickRequests.remove(kick); }).send(); @@ -1753,7 +1753,7 @@ void ApiWrap::unblockParticipant( } else { channel->updateFullForced(); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _kickRequests.remove(kick); }).send(); @@ -1818,7 +1818,7 @@ void ApiWrap::requestChannelMembersForAdd( base::take(_channelMembersForAddRequestId); base::take(_channelMembersForAdd); base::take(_channelMembersForAddCallback)(result); - }).fail([this](const RPCError &error) { + }).fail([this](const MTP::Error &error) { base::take(_channelMembersForAddRequestId); base::take(_channelMembersForAdd); base::take(_channelMembersForAddCallback); @@ -1839,7 +1839,7 @@ void ApiWrap::requestStickerSets() { auto waitMs = (j == e) ? 0 : kSmallDelayMs; i.value().second = request(MTPmessages_GetStickerSet(MTP_inputStickerSetID(MTP_long(i.key()), MTP_long(i.value().first)))).done([this, setId = i.key()](const MTPmessages_StickerSet &result) { gotStickerSet(setId, result); - }).fail([this, setId = i.key()](const RPCError &error) { + }).fail([this, setId = i.key()](const MTP::Error &error) { _stickerSetRequests.remove(setId); }).afterDelay(waitMs).send(); } @@ -1876,7 +1876,7 @@ void ApiWrap::saveStickerSets( MTP_flags(0) )).done([this](const MTPBool &result) { _stickersClearRecentRequestId = 0; - }).fail([this](const RPCError &error) { + }).fail([this](const MTP::Error &error) { _stickersClearRecentRequestId = 0; }).send(); continue; @@ -1898,7 +1898,7 @@ void ApiWrap::saveStickerSets( auto requestId = request(MTPmessages_UninstallStickerSet(setId)).done([this](const MTPBool &result, mtpRequestId requestId) { stickerSetDisenabled(requestId); - }).fail([this](const RPCError &error, mtpRequestId requestId) { + }).fail([this](const MTP::Error &error, mtpRequestId requestId) { stickerSetDisenabled(requestId); }).afterDelay(kSmallDelayMs).send(); @@ -1944,7 +1944,7 @@ void ApiWrap::saveStickerSets( mtpRequestId requestId) { stickerSetDisenabled(requestId); }).fail([=]( - const RPCError &error, + const MTP::Error &error, mtpRequestId requestId) { stickerSetDisenabled(requestId); }).afterDelay(kSmallDelayMs).send(); @@ -2006,7 +2006,7 @@ void ApiWrap::joinChannel(not_null channel) { )).done([=](const MTPUpdates &result) { _channelAmInRequests.remove(channel); applyUpdates(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { if (error.type() == qstr("CHANNEL_PRIVATE") && channel->invitePeekExpires()) { channel->privateErrorReceived(); @@ -2039,7 +2039,7 @@ void ApiWrap::leaveChannel(not_null channel) { )).done([=](const MTPUpdates &result) { _channelAmInRequests.remove(channel); applyUpdates(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _channelAmInRequests.remove(channel); }).send(); @@ -2065,7 +2065,7 @@ void ApiWrap::blockPeer(not_null peer) { ++_blockedPeersSlice->total; _blockedPeersChanges.fire_copy(*_blockedPeersSlice); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _blockRequests.erase(peer); }).send(); @@ -2103,7 +2103,7 @@ void ApiWrap::unblockPeer(not_null peer, Fn onDone) { if (onDone) { onDone(); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _blockRequests.erase(peer); }).send(); _blockRequests.emplace(peer, requestId); @@ -2143,7 +2143,7 @@ void ApiWrap::requestNotifySettings(const MTPInputNotifyPeer &peer) { )).done([=](const MTPPeerNotifySettings &result) { applyNotifySettings(peer, result); _notifySettingRequests.erase(key); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { applyNotifySettings( peer, MTP_peerNotifySettings( @@ -2203,7 +2203,7 @@ void ApiWrap::savePrivacy( handlePrivacyChange(*key, data.vrules()); } }); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _privacySaveRequests.remove(keyTypeId); }).send(); @@ -2263,7 +2263,7 @@ void ApiWrap::updatePrivacyLastSeens(const QVector &rules) { } } } - }).fail([this](const RPCError &error) { + }).fail([this](const MTP::Error &error) { _contactsStatusesRequestId = 0; }).send(); } @@ -2297,7 +2297,7 @@ void ApiWrap::deleteConversation(not_null peer, bool revoke) { )).done([=](const MTPUpdates &result) { applyUpdates(result); deleteHistory(peer, false, revoke); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { deleteHistory(peer, false, revoke); }).send(); } else { @@ -2472,7 +2472,7 @@ void ApiWrap::saveDraftsToCloud() { _draftsSaveRequestIds.erase(history); checkQuitPreventFinished(); } - }).fail([=](const RPCError &error, const MTP::Response &response) { + }).fail([=](const MTP::Error &error, const MTP::Response &response) { history->finishSavingCloudDraft( UnixtimeFromMsgId(response.outerMsgId)); @@ -2724,7 +2724,7 @@ void ApiWrap::requestFileReference( for (auto &handler : handlers) { handler(parsed); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { const auto i = _fileReferenceHandlers.find(origin); Assert(i != end(_fileReferenceHandlers)); auto handlers = std::move(i->second); @@ -2881,7 +2881,7 @@ void ApiWrap::stickersSaveOrder() { MTP_vector(mtpOrder) )).done([=](const MTPBool &result) { _stickersReorderRequestId = 0; - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _stickersReorderRequestId = 0; _session->data().stickers().setLastUpdate(0); updateStickers(); @@ -2979,7 +2979,7 @@ void ApiWrap::requestStickers(TimeId now) { }; _stickersUpdateRequest = request(MTPmessages_GetAllStickers( MTP_int(Api::CountStickersHash(_session, true)) - )).done(onDone).fail([=](const RPCError &error) { + )).done(onDone).fail([=](const MTP::Error &error) { LOG(("App Fail: Failed to get stickers!")); onDone(MTP_messages_allStickersNotModified()); }).send(); @@ -3018,7 +3018,7 @@ void ApiWrap::requestRecentStickersWithHash(int32 hash) { } return; default: Unexpected("Type in ApiWrap::recentStickersDone()"); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _session->data().stickers().setLastRecentUpdate(crl::now()); _recentStickersUpdateRequest = 0; @@ -3050,7 +3050,7 @@ void ApiWrap::requestFavedStickers(TimeId now) { } return; default: Unexpected("Type in ApiWrap::favedStickersDone()"); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _session->data().stickers().setLastFavedUpdate(crl::now()); _favedStickersUpdateRequest = 0; @@ -3080,7 +3080,7 @@ void ApiWrap::requestFeaturedStickers(TimeId now) { } return; default: Unexpected("Type in ApiWrap::featuredStickersDone()"); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _session->data().stickers().setLastFeaturedUpdate(crl::now()); _featuredStickersUpdateRequest = 0; @@ -3109,7 +3109,7 @@ void ApiWrap::requestSavedGifs(TimeId now) { } return; default: Unexpected("Type in ApiWrap::savedGifsDone()"); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _session->data().stickers().setLastSavedGifsUpdate(crl::now()); _savedGifsUpdateRequest = 0; @@ -3340,7 +3340,7 @@ void ApiWrap::preloadEnoughUnreadMentions(not_null history) { auto requestId = request(MTPmessages_GetUnreadMentions(history->peer->input, MTP_int(offsetId), MTP_int(addOffset), MTP_int(limit), MTP_int(maxId), MTP_int(minId))).done([this, history](const MTPmessages_Messages &result) { _unreadMentionsRequests.remove(history); history->addUnreadMentionsSlice(result); - }).fail([this, history](const RPCError &error) { + }).fail([this, history](const MTP::Error &error) { _unreadMentionsRequests.remove(history); }).send(); _unreadMentionsRequests.emplace(history, requestId); @@ -3375,7 +3375,7 @@ void ApiWrap::addChatParticipants( )).done([=](const MTPUpdates &result) { applyUpdates(result); if (done) done(true); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { ShowAddParticipantsError(error.type(), peer, { 1, user }); if (done) done(false); }).afterDelay(crl::time(5)).send(); @@ -3397,7 +3397,7 @@ void ApiWrap::addChatParticipants( applyUpdates(result); requestParticipantsCountDelayed(channel); if (callback) callback(true); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { ShowAddParticipantsError(error.type(), peer, users); if (callback) callback(false); }).afterDelay(crl::time(5)).send(); @@ -3454,7 +3454,7 @@ void ApiWrap::requestSharedMedia( _sharedMediaRequests.remove(key); sharedMediaDone(peer, type, messageId, slice, result); finish(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _sharedMediaRequests.remove(key); finish(); }).send(); @@ -3503,7 +3503,7 @@ void ApiWrap::requestUserPhotos( )).done([this, user, afterId](const MTPphotos_Photos &result) { _userPhotosRequests.remove(user); userPhotosDone(user, afterId, result); - }).fail([this, user](const RPCError &error) { + }).fail([this, user](const MTP::Error &error) { _userPhotosRequests.remove(user); }).send(); _userPhotosRequests.emplace(user, requestId); @@ -3644,7 +3644,7 @@ void ApiWrap::forwardMessages( shared->callback(); } finish(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { if (idsCopy) { for (const auto &[randomId, itemId] : *idsCopy) { sendMessageFail(error, peer, randomId, itemId); @@ -4098,7 +4098,7 @@ void ApiWrap::sendMessage(MessageToSend &&message) { } finish(); }).fail([=]( - const RPCError &error, + const MTP::Error &error, const MTP::Response &response) { if (error.type() == qstr("MESSAGE_EMPTY")) { lastMessage->destroy(); @@ -4144,7 +4144,7 @@ void ApiWrap::sendBotStart(not_null bot, PeerData *chat) { MTP_string(base::take(token)) )).done([=](const MTPUpdates &result) { applyUpdates(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { if (chat) { ShowAddParticipantsError(error.type(), chat, { 1, bot }); } @@ -4227,7 +4227,7 @@ void ApiWrap::sendInlineResult( UnixtimeFromMsgId(response.outerMsgId)); finish(); }).fail([=]( - const RPCError &error, + const MTP::Error &error, const MTP::Response &response) { sendMessageFail(error, peer, randomId, newId); history->finishSavingCloudDraft( @@ -4311,7 +4311,7 @@ void ApiWrap::uploadAlbumMedia( sendAlbumWithUploaded(item, groupId, media); } break; } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { failed(); }).send(); } @@ -4373,7 +4373,7 @@ void ApiWrap::sendMediaWithRandomId( )).done([=](const MTPUpdates &result) { applyUpdates(result); finish(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { sendMessageFail(error, peer, randomId, itemId); finish(); }).afterRequest( @@ -4472,7 +4472,7 @@ void ApiWrap::sendAlbumIfReady(not_null album) { _sendingAlbums.remove(groupId); applyUpdates(result); finish(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { if (const auto album = _sendingAlbums.take(groupId)) { for (const auto &item : (*album)->items) { sendMessageFail(error, peer, item.randomId, item.msgId); @@ -4609,7 +4609,7 @@ void ApiWrap::reloadPasswordState() { } _passwordStateChanges.fire_copy(*_passwordState); }); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _passwordRequestId = 0; }).send(); } @@ -4619,7 +4619,7 @@ void ApiWrap::clearUnconfirmedPassword() { )).done([=](const MTPBool &result) { _passwordRequestId = 0; reloadPasswordState(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _passwordRequestId = 0; reloadPasswordState(); }).send(); @@ -4648,7 +4648,7 @@ void ApiWrap::reloadContactSignupSilent() { const auto silent = mtpIsTrue(result); _contactSignupSilent = silent; _contactSignupSilentChanges.fire_copy(silent); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _contactSignupSilentRequestId = 0; }).send(); _contactSignupSilentRequestId = requestId; @@ -4674,7 +4674,7 @@ void ApiWrap::saveContactSignupSilent(bool silent) { _contactSignupSilentRequestId = 0; _contactSignupSilent = silent; _contactSignupSilentChanges.fire_copy(silent); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _contactSignupSilentRequestId = 0; }).send(); _contactSignupSilentRequestId = requestId; @@ -4706,7 +4706,7 @@ void ApiWrap::saveSelfBio(const QString &text, FnMut done) { if (_saveBioDone) { _saveBioDone(); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _saveBioRequestId = 0; }).send(); } @@ -4724,7 +4724,7 @@ void ApiWrap::reloadPrivacy(Privacy::Key key) { _session->data().processChats(data.vchats()); pushPrivacy(key, data.vrules().v); }); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _privacyRequestIds.erase(key); }).send(); _privacyRequestIds.emplace(key, requestId); @@ -4867,7 +4867,7 @@ void ApiWrap::reloadBlockedPeers() { _session->data().processUsers(data.vusers()); push(0, data.vblocked().v); }); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _blockedPeersRequestId = 0; }).send(); } @@ -4909,7 +4909,7 @@ void ApiWrap::createPoll( const PollData &data, const SendAction &action, Fn done, - Fn fail) { + Fn fail) { sendAction(action); const auto history = action.history; @@ -4962,7 +4962,7 @@ void ApiWrap::createPoll( done(); finish(); }).fail([=]( - const RPCError &error, + const MTP::Error &error, const MTP::Response &response) mutable { if (clearCloudDraft) { history->finishSavingCloudDraft( @@ -5017,7 +5017,7 @@ void ApiWrap::sendPollVotes( _pollVotesRequestIds.erase(itemId); hideSending(); applyUpdates(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _pollVotesRequestIds.erase(itemId); hideSending(); }).send(); @@ -5046,7 +5046,7 @@ void ApiWrap::closePoll(not_null item) { )).done([=](const MTPUpdates &result) { _pollCloseRequestIds.erase(itemId); applyUpdates(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _pollCloseRequestIds.erase(itemId); }).send(); _pollCloseRequestIds.emplace(itemId, requestId); @@ -5064,7 +5064,7 @@ void ApiWrap::reloadPollResults(not_null item) { )).done([=](const MTPUpdates &result) { _pollReloadRequestIds.erase(itemId); applyUpdates(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _pollReloadRequestIds.erase(itemId); }).send(); _pollReloadRequestIds.emplace(itemId, requestId); diff --git a/Telegram/SourceFiles/apiwrap.h b/Telegram/SourceFiles/apiwrap.h index 568092eaf..05d19025a 100644 --- a/Telegram/SourceFiles/apiwrap.h +++ b/Telegram/SourceFiles/apiwrap.h @@ -192,7 +192,7 @@ public: void requestWallPaper( const QString &slug, Fn done, - Fn fail); + Fn fail); void requestFullPeer(not_null peer); void requestPeer(not_null peer); @@ -227,7 +227,7 @@ public: void checkChatInvite( const QString &hash, FnMut done, - Fn fail); + Fn fail); void importChatInvite(const QString &hash); void requestChannelMembersForAdd( @@ -243,7 +243,7 @@ public: void migrateChat( not_null chat, FnMut)> done, - Fn fail = nullptr); + Fn fail = nullptr); void markMediaRead(const base::flat_set> &items); void markMediaRead(not_null item); @@ -416,7 +416,7 @@ public: not_null data, const SendAction &action); void sendMessageFail( - const RPCError &error, + const MTP::Error &error, not_null peer, uint64 randomId = 0, FullMsgId itemId = FullMsgId()); @@ -453,7 +453,7 @@ public: const PollData &data, const SendAction &action, Fn done, - Fn fail); + Fn fail); void sendPollVotes( FullMsgId itemId, const std::vector &options); @@ -628,7 +628,7 @@ private: void migrateDone( not_null peer, not_null channel); - void migrateFail(not_null peer, const RPCError &error); + void migrateFail(not_null peer, const MTP::Error &error); not_null _session; @@ -742,11 +742,11 @@ private: mtpRequestId _checkInviteRequestId = 0; FnMut _checkInviteDone; - Fn _checkInviteFail; + Fn _checkInviteFail; struct MigrateCallbacks { FnMut)> done; - Fn fail; + Fn fail; }; base::flat_map< not_null, @@ -786,7 +786,7 @@ private: mtpRequestId _wallPaperRequestId = 0; QString _wallPaperSlug; Fn _wallPaperDone; - Fn _wallPaperFail; + Fn _wallPaperFail; mtpRequestId _contactSignupSilentRequestId = 0; std::optional _contactSignupSilent; diff --git a/Telegram/SourceFiles/boxes/add_contact_box.cpp b/Telegram/SourceFiles/boxes/add_contact_box.cpp index 09324ddba..a69e40b96 100644 --- a/Telegram/SourceFiles/boxes/add_contact_box.cpp +++ b/Telegram/SourceFiles/boxes/add_contact_box.cpp @@ -586,7 +586,7 @@ void GroupInfoBox::createGroup( Ui::hideLayer(); // Destroys 'this'. ChatCreateDone(navigation, std::move(image), result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _creationRequestId = 0; if (error.type() == qstr("NO_CHAT_TITLE")) { auto weak = Ui::MakeWeak(this); @@ -703,7 +703,7 @@ void GroupInfoBox::createChannel(const QString &title, const QString &descriptio LOG(("API Error: channel not found in updates (GroupInfoBox::creationDone)")); closeBox(); } - }).fail([this](const RPCError &error) { + }).fail([this](const MTP::Error &error) { _creationRequestId = 0; if (error.type() == "NO_CHAT_TITLE") { _title->setFocus(); @@ -824,7 +824,7 @@ void SetupChannelBox::prepare() { _checkRequestId = _api.request(MTPchannels_CheckUsername( _channel->inputChannel, MTP_string("preston") - )).fail([=](const RPCError &error) { + )).fail([=](const MTP::Error &error) { firstCheckFail(error); }).send(); @@ -983,7 +983,7 @@ void SetupChannelBox::save() { MTP_string(_sentUsername) )).done([=](const MTPBool &result) { updateDone(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { updateFail(error); }).send(); }; @@ -1055,7 +1055,7 @@ void SetupChannelBox::check() { MTP_string(link) )).done([=](const MTPBool &result) { checkDone(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { checkFail(error); }).send(); } @@ -1095,7 +1095,7 @@ void SetupChannelBox::updateDone(const MTPBool &result) { closeBox(); } -void SetupChannelBox::updateFail(const RPCError &error) { +void SetupChannelBox::updateFail(const MTP::Error &error) { _saveRequestId = 0; QString err(error.type()); if (err == "USERNAME_NOT_MODIFIED" @@ -1130,7 +1130,7 @@ void SetupChannelBox::checkDone(const MTPBool &result) { } } -void SetupChannelBox::checkFail(const RPCError &error) { +void SetupChannelBox::checkFail(const MTP::Error &error) { _checkRequestId = 0; QString err(error.type()); if (err == qstr("CHANNEL_PUBLIC_GROUP_NA")) { @@ -1171,7 +1171,7 @@ void SetupChannelBox::showRevokePublicLinkBoxForEdit() { Ui::LayerOption::KeepOther); } -void SetupChannelBox::firstCheckFail(const RPCError &error) { +void SetupChannelBox::firstCheckFail(const MTP::Error &error) { _checkRequestId = 0; const auto &type = error.type(); if (type == qstr("CHANNEL_PUBLIC_GROUP_NA")) { @@ -1281,7 +1281,7 @@ void EditNameBox::save() { MTPstring() )).done([=](const MTPUser &result) { saveSelfDone(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { saveSelfFail(error); }).send(); } @@ -1291,7 +1291,7 @@ void EditNameBox::saveSelfDone(const MTPUser &user) { closeBox(); } -void EditNameBox::saveSelfFail(const RPCError &error) { +void EditNameBox::saveSelfFail(const MTP::Error &error) { auto err = error.type(); auto first = TextUtilities::SingleLine(_first->getLastText().trimmed()); auto last = TextUtilities::SingleLine(_last->getLastText().trimmed()); diff --git a/Telegram/SourceFiles/boxes/add_contact_box.h b/Telegram/SourceFiles/boxes/add_contact_box.h index 39bb98717..bda2c9d92 100644 --- a/Telegram/SourceFiles/boxes/add_contact_box.h +++ b/Telegram/SourceFiles/boxes/add_contact_box.h @@ -179,11 +179,11 @@ private: void save(); void updateDone(const MTPBool &result); - void updateFail(const RPCError &error); + void updateFail(const MTP::Error &error); void checkDone(const MTPBool &result); - void checkFail(const RPCError &error); - void firstCheckFail(const RPCError &error); + void checkFail(const MTP::Error &error); + void firstCheckFail(const MTP::Error &error); void updateMaxHeight(); @@ -229,7 +229,7 @@ private: void submit(); void save(); void saveSelfDone(const MTPUser &user); - void saveSelfFail(const RPCError &error); + void saveSelfFail(const MTP::Error &error); const not_null _user; MTP::Sender _api; diff --git a/Telegram/SourceFiles/boxes/background_preview_box.cpp b/Telegram/SourceFiles/boxes/background_preview_box.cpp index 487cf333f..807ca7c68 100644 --- a/Telegram/SourceFiles/boxes/background_preview_box.cpp +++ b/Telegram/SourceFiles/boxes/background_preview_box.cpp @@ -785,7 +785,7 @@ bool BackgroundPreviewBox::Start( Ui::show(Box( controller, result.withUrlParams(params))); - }), [](const RPCError &error) { + }), [](const MTP::Error &error) { Ui::show(Box(tr::lng_background_bad_link(tr::now))); }); return true; diff --git a/Telegram/SourceFiles/boxes/change_phone_box.cpp b/Telegram/SourceFiles/boxes/change_phone_box.cpp index 65dcc5834..727c8b93c 100644 --- a/Telegram/SourceFiles/boxes/change_phone_box.cpp +++ b/Telegram/SourceFiles/boxes/change_phone_box.cpp @@ -78,7 +78,7 @@ protected: private: void submit(); void sendPhoneDone(const MTPauth_SentCode &result, const QString &phoneNumber); - void sendPhoneFail(const RPCError &error, const QString &phoneNumber); + void sendPhoneFail(const MTP::Error &error, const QString &phoneNumber); void showError(const QString &text); void hideError() { showError(QString()); @@ -114,7 +114,7 @@ private: void submit(); void sendCall(); void updateCall(); - void sendCodeFail(const RPCError &error); + void sendCodeFail(const MTP::Error &error); void showError(const QString &text); void hideError() { showError(QString()); @@ -180,7 +180,7 @@ void ChangePhoneBox::EnterPhone::submit() { MTP_codeSettings(MTP_flags(0)) )).done([=](const MTPauth_SentCode &result) { sendPhoneDone(result, phoneNumber); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { sendPhoneFail(error, phoneNumber); }).handleFloodErrors().send(); } @@ -222,9 +222,9 @@ void ChangePhoneBox::EnterPhone::sendPhoneDone( Ui::LayerOption::KeepOther); } -void ChangePhoneBox::EnterPhone::sendPhoneFail(const RPCError &error, const QString &phoneNumber) { +void ChangePhoneBox::EnterPhone::sendPhoneFail(const MTP::Error &error, const QString &phoneNumber) { _requestId = 0; - if (MTP::isFloodError(error)) { + if (MTP::IsFloodError(error)) { showError(tr::lng_flood_error(tr::now)); } else if (error.type() == qstr("PHONE_NUMBER_INVALID")) { showError(tr::lng_bad_phone(tr::now)); @@ -320,7 +320,7 @@ void ChangePhoneBox::EnterCode::submit() { Ui::hideLayer(); } Ui::Toast::Show(tr::lng_change_phone_success(tr::now)); - }).fail(crl::guard(this, [=](const RPCError &error) { + }).fail(crl::guard(this, [=](const MTP::Error &error) { sendCodeFail(error); })).handleFloodErrors().send(); } @@ -354,9 +354,9 @@ void ChangePhoneBox::EnterCode::showError(const QString &text) { } } -void ChangePhoneBox::EnterCode::sendCodeFail(const RPCError &error) { +void ChangePhoneBox::EnterCode::sendCodeFail(const MTP::Error &error) { _requestId = 0; - if (MTP::isFloodError(error)) { + if (MTP::IsFloodError(error)) { showError(tr::lng_flood_error(tr::now)); } else if (error.type() == qstr("PHONE_CODE_EMPTY") || error.type() == qstr("PHONE_CODE_INVALID")) { showError(tr::lng_bad_code(tr::now)); diff --git a/Telegram/SourceFiles/boxes/confirm_box.cpp b/Telegram/SourceFiles/boxes/confirm_box.cpp index 9c90309a4..423f0ee23 100644 --- a/Telegram/SourceFiles/boxes/confirm_box.cpp +++ b/Telegram/SourceFiles/boxes/confirm_box.cpp @@ -536,7 +536,7 @@ void PinMessageBox::pinMessage() { )).done([=](const MTPUpdates &result) { _peer->session().api().applyUpdates(result); Ui::hideLayer(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { Ui::hideLayer(); }).send(); } diff --git a/Telegram/SourceFiles/boxes/confirm_phone_box.cpp b/Telegram/SourceFiles/boxes/confirm_phone_box.cpp index ab96d75f3..e0d4bf803 100644 --- a/Telegram/SourceFiles/boxes/confirm_phone_box.cpp +++ b/Telegram/SourceFiles/boxes/confirm_phone_box.cpp @@ -249,7 +249,7 @@ void ConfirmPhoneBox::checkPhoneAndHash() { MTP_codeSettings(MTP_flags(0)) )).done([=](const MTPauth_SentCode &result) { sendCodeDone(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { sendCodeFail(error); }).handleFloodErrors().send(); } @@ -278,9 +278,9 @@ void ConfirmPhoneBox::sendCodeDone(const MTPauth_SentCode &result) { }); } -void ConfirmPhoneBox::sendCodeFail(const RPCError &error) { +void ConfirmPhoneBox::sendCodeFail(const MTP::Error &error) { auto errorText = Lang::Hard::ServerError(); - if (MTP::isFloodError(error)) { + if (MTP::IsFloodError(error)) { errorText = tr::lng_flood_error(tr::now); } else if (error.code() == 400) { errorText = tr::lng_confirm_phone_link_invalid(tr::now); @@ -348,7 +348,7 @@ void ConfirmPhoneBox::sendCode() { MTP_string(code) )).done([=](const MTPBool &result) { confirmDone(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { confirmFail(error); }).handleFloodErrors().send(); } @@ -358,9 +358,9 @@ void ConfirmPhoneBox::confirmDone(const MTPBool &result) { Ui::show(Box(tr::lng_confirm_phone_success(tr::now, lt_phone, App::formatPhone(_phone)))); } -void ConfirmPhoneBox::confirmFail(const RPCError &error) { +void ConfirmPhoneBox::confirmFail(const MTP::Error &error) { auto errorText = Lang::Hard::ServerError(); - if (MTP::isFloodError(error)) { + if (MTP::IsFloodError(error)) { errorText = tr::lng_flood_error(tr::now); } else { auto &errorType = error.type(); diff --git a/Telegram/SourceFiles/boxes/confirm_phone_box.h b/Telegram/SourceFiles/boxes/confirm_phone_box.h index 735b137cb..cb3b15de8 100644 --- a/Telegram/SourceFiles/boxes/confirm_phone_box.h +++ b/Telegram/SourceFiles/boxes/confirm_phone_box.h @@ -121,12 +121,12 @@ private: void checkPhoneAndHash(); void sendCodeDone(const MTPauth_SentCode &result); - void sendCodeFail(const RPCError &error); + void sendCodeFail(const MTP::Error &error); void callDone(const MTPauth_SentCode &result); void confirmDone(const MTPBool &result); - void confirmFail(const RPCError &error); + void confirmFail(const MTP::Error &error); QString getPhone() const { return _phone; diff --git a/Telegram/SourceFiles/boxes/edit_caption_box.cpp b/Telegram/SourceFiles/boxes/edit_caption_box.cpp index 9facde242..2a4734399 100644 --- a/Telegram/SourceFiles/boxes/edit_caption_box.cpp +++ b/Telegram/SourceFiles/boxes/edit_caption_box.cpp @@ -1061,7 +1061,7 @@ void EditCaptionBox::save() { closeBox(); }); - const auto fail = crl::guard(this, [=](const RPCError &error) { + const auto fail = crl::guard(this, [=](const MTP::Error &error) { _saveRequestId = 0; const auto &type = error.type(); if (ranges::contains(Api::kDefaultEditMessagesErrors, type)) { diff --git a/Telegram/SourceFiles/boxes/passcode_box.cpp b/Telegram/SourceFiles/boxes/passcode_box.cpp index 475e9bac5..77cfa62fe 100644 --- a/Telegram/SourceFiles/boxes/passcode_box.cpp +++ b/Telegram/SourceFiles/boxes/passcode_box.cpp @@ -360,8 +360,8 @@ void PasscodeBox::closeReplacedBy() { } } -void PasscodeBox::setPasswordFail(const RPCError &error) { - if (MTP::isFloodError(error)) { +void PasscodeBox::setPasswordFail(const MTP::Error &error) { + if (MTP::IsFloodError(error)) { closeReplacedBy(); _setRequest = 0; @@ -402,7 +402,7 @@ void PasscodeBox::setPasswordFail(const RPCError &error) { void PasscodeBox::setPasswordFail( const QByteArray &newPasswordBytes, const QString &email, - const RPCError &error) { + const MTP::Error &error) { const auto prefix = qstr("EMAIL_UNCONFIRMED_"); if (error.type().startsWith(prefix)) { const auto codeLength = error.type().mid(prefix.size()).toInt(); @@ -432,9 +432,9 @@ void PasscodeBox::validateEmail( )).done([=](const MTPBool &result) { *set = true; setPasswordDone(newPasswordBytes); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _setRequest = 0; - if (MTP::isFloodError(error)) { + if (MTP::IsFloodError(error)) { errors->fire(tr::lng_flood_error(tr::now)); } else if (error.type() == qstr("CODE_INVALID")) { errors->fire(tr::lng_signin_wrong_code(tr::now)); @@ -461,7 +461,7 @@ void PasscodeBox::validateEmail( )).done([=](const MTPBool &result) { _setRequest = 0; resent->fire(tr::lng_cloud_password_resent(tr::now)); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _setRequest = 0; errors->fire(Lang::Hard::ServerError()); }).send(); @@ -681,9 +681,9 @@ void PasscodeBox::serverError() { closeBox(); } -bool PasscodeBox::handleCustomCheckError(const RPCError &error) { +bool PasscodeBox::handleCustomCheckError(const MTP::Error &error) { const auto &type = error.type(); - if (MTP::isFloodError(error) + if (MTP::IsFloodError(error) || type == qstr("PASSWORD_HASH_INVALID") || type == qstr("SRP_PASSWORD_CHANGED") || type == qstr("SRP_ID_INVALID")) { @@ -714,7 +714,7 @@ void PasscodeBox::sendClearCloudPassword( MTPSecureSecretSettings()) )).done([=](const MTPBool &result) { setPasswordDone({}); - }).fail([=](const RPCError &error) mutable { + }).fail([=](const MTP::Error &error) mutable { setPasswordFail({}, QString(), error); }).handleFloodErrors().send(); } @@ -745,7 +745,7 @@ void PasscodeBox::setNewCloudPassword(const QString &newPassword) { MTPSecureSecretSettings()) )).done([=](const MTPBool &result) { setPasswordDone(newPasswordBytes); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { setPasswordFail(newPasswordBytes, email, error); }).handleFloodErrors().send(); } @@ -800,7 +800,7 @@ void PasscodeBox::changeCloudPassword( sendChangeCloudPassword(check, newPassword, secureSecret); }); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { setPasswordFail(error); }).handleFloodErrors().send(); } @@ -842,7 +842,7 @@ void PasscodeBox::resetSecret( const auto empty = QByteArray(); sendChangeCloudPassword(check, newPassword, empty); }); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _setRequest = 0; if (error.type() == qstr("SRP_ID_INVALID")) { handleSrpIdInvalid(); @@ -891,7 +891,7 @@ void PasscodeBox::sendChangeCloudPassword( MTP_long(newSecureSecretId))) )).done([=](const MTPBool &result) { setPasswordDone(newPasswordBytes); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { setPasswordFail(newPasswordBytes, QString(), error); }).handleFloodErrors().send(); } @@ -939,7 +939,7 @@ void PasscodeBox::recoverByEmail() { _api.request(MTPauth_RequestPasswordRecovery( )).done([=](const MTPauth_PasswordRecovery &result) { recoverStarted(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { recoverStartFail(error); }).send(); } else { @@ -977,7 +977,7 @@ void PasscodeBox::recoverStarted(const MTPauth_PasswordRecovery &result) { recover(); } -void PasscodeBox::recoverStartFail(const RPCError &error) { +void PasscodeBox::recoverStartFail(const MTP::Error &error) { _pattern = QString(); closeBox(); } @@ -1055,7 +1055,7 @@ void RecoverBox::submit() { MTP_string(code) )).done([=](const MTPauth_Authorization &result) { codeSubmitDone(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { codeSubmitFail(error); }).handleFloodErrors().send(); }); @@ -1087,8 +1087,8 @@ void RecoverBox::codeSubmitDone(const MTPauth_Authorization &result) { Ui::LayerOption::CloseOther); } -void RecoverBox::codeSubmitFail(const RPCError &error) { - if (MTP::isFloodError(error)) { +void RecoverBox::codeSubmitFail(const MTP::Error &error) { + if (MTP::IsFloodError(error)) { _submitRequest = 0; _error = tr::lng_flood_error(tr::now); update(); @@ -1149,9 +1149,9 @@ RecoveryEmailValidation ConfirmRecoveryEmail( Box(tr::lng_cloud_password_was_set(tr::now)), Ui::LayerOption::CloseOther); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { *requestId = 0; - if (MTP::isFloodError(error)) { + if (MTP::IsFloodError(error)) { errors->fire(tr::lng_flood_error(tr::now)); } else if (error.type() == qstr("CODE_INVALID")) { errors->fire(tr::lng_signin_wrong_code(tr::now)); @@ -1177,7 +1177,7 @@ RecoveryEmailValidation ConfirmRecoveryEmail( )).done([=](const MTPBool &result) { *requestId = 0; resent->fire(tr::lng_cloud_password_resent(tr::now)); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { *requestId = 0; errors->fire(Lang::Hard::ServerError()); }).send(); @@ -1196,7 +1196,7 @@ RecoveryEmailValidation ConfirmRecoveryEmail( } [[nodiscard]] object_ptr PrePasswordErrorBox( - const RPCError &error, + const MTP::Error &error, not_null session, TextWithEntities &&about) { const auto type = [&] { diff --git a/Telegram/SourceFiles/boxes/passcode_box.h b/Telegram/SourceFiles/boxes/passcode_box.h index 4275f8fb4..80644c2be 100644 --- a/Telegram/SourceFiles/boxes/passcode_box.h +++ b/Telegram/SourceFiles/boxes/passcode_box.h @@ -55,7 +55,7 @@ public: rpl::producer<> passwordReloadNeeded() const; rpl::producer<> clearUnconfirmedPassword() const; - bool handleCustomCheckError(const RPCError &error); + bool handleCustomCheckError(const MTP::Error &error); protected: void prepare() override; @@ -81,18 +81,18 @@ private: bool onlyCheckCurrent() const; void setPasswordDone(const QByteArray &newPasswordBytes); - void setPasswordFail(const RPCError &error); + void setPasswordFail(const MTP::Error &error); void setPasswordFail( const QByteArray &newPasswordBytes, const QString &email, - const RPCError &error); + const MTP::Error &error); void validateEmail( const QString &email, int codeLength, const QByteArray &newPasswordBytes); void recoverStarted(const MTPauth_PasswordRecovery &result); - void recoverStartFail(const RPCError &error); + void recoverStartFail(const MTP::Error &error); void recover(); void submitOnlyCheckCloudPassword(const QString &oldPassword); @@ -189,7 +189,7 @@ private: void submit(); void codeChanged(); void codeSubmitDone(const MTPauth_Authorization &result); - void codeSubmitFail(const RPCError &error); + void codeSubmitFail(const MTP::Error &error); MTP::Sender _api; mtpRequestId _submitRequest = 0; @@ -216,6 +216,6 @@ struct RecoveryEmailValidation { const QString &pattern); [[nodiscard]] object_ptr PrePasswordErrorBox( - const RPCError &error, + const MTP::Error &error, not_null session, TextWithEntities &&about); diff --git a/Telegram/SourceFiles/boxes/peer_list_controllers.cpp b/Telegram/SourceFiles/boxes/peer_list_controllers.cpp index eef91d413..ff6b8b2b7 100644 --- a/Telegram/SourceFiles/boxes/peer_list_controllers.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_controllers.cpp @@ -54,7 +54,7 @@ void ShareBotGame(not_null bot, not_null chat) { )).done([=](const MTPUpdates &result) { api->applyUpdates(result, randomId); finish(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { api->sendMessageFail(error, chat); finish(); }).afterRequest( @@ -195,7 +195,7 @@ void PeerListGlobalSearchController::searchOnServer() { MTP_int(SearchPeopleLimit) )).done([=](const MTPcontacts_Found &result, mtpRequestId requestId) { searchDone(result, requestId); - }).fail([=](const RPCError &error, mtpRequestId requestId) { + }).fail([=](const MTP::Error &error, mtpRequestId requestId) { if (_requestId == requestId) { _requestId = 0; delegate()->peerListSearchRefreshRows(); diff --git a/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp b/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp index 73ff07e32..fc00d47aa 100644 --- a/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp @@ -485,7 +485,7 @@ void AddSpecialBoxController::loadMoreRows() { setDescriptionText(tr::lng_blocked_list_not_found(tr::now)); } delegate()->peerListRefreshRows(); - }).fail([this](const RPCError &error) { + }).fail([this](const MTP::Error &error) { _loadRequestId = 0; }).send(); } @@ -520,7 +520,7 @@ bool AddSpecialBoxController::checkInfoLoaded( channel->owner().processUsers(participant.vusers()); _additional.applyParticipant(participant.vparticipant()); callback(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _additional.setExternal(user); callback(); }).send(); @@ -976,7 +976,7 @@ void AddSpecialBoxSearchController::requestParticipants() { const MTPchannels_ChannelParticipants &result, mtpRequestId requestId) { searchParticipantsDone(requestId, result, perPage); - }).fail([=](const RPCError &error, mtpRequestId requestId) { + }).fail([=](const MTP::Error &error, mtpRequestId requestId) { if (_requestId == requestId) { _requestId = 0; _participantsLoaded = true; @@ -1059,7 +1059,7 @@ void AddSpecialBoxSearchController::requestGlobal() { MTP_int(perPage) )).done([=](const MTPcontacts_Found &result, mtpRequestId requestId) { searchGlobalDone(requestId, result); - }).fail([=](const RPCError &error, mtpRequestId requestId) { + }).fail([=](const MTP::Error &error, mtpRequestId requestId) { if (_requestId == requestId) { _requestId = 0; _globalLoaded = true; diff --git a/Telegram/SourceFiles/boxes/peers/edit_contact_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_contact_box.cpp index f46fd99af..59b02b443 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_contact_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_contact_box.cpp @@ -75,7 +75,7 @@ void SendRequest( lt_user, first)); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { }).send(); } diff --git a/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp index 522c0bcec..1954ebf59 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp @@ -444,7 +444,7 @@ void EditAdminBox::transferOwnership() { channel, MTP_inputUserEmpty(), MTP_inputCheckPasswordEmpty() - )).fail([=](const RPCError &error) { + )).fail([=](const MTP::Error &error) { _checkTransferRequestId = 0; if (!handleTransferPasswordError(error)) { getDelegate()->show(Box( @@ -461,7 +461,7 @@ void EditAdminBox::transferOwnership() { }).send(); } -bool EditAdminBox::handleTransferPasswordError(const RPCError &error) { +bool EditAdminBox::handleTransferPasswordError(const MTP::Error &error) { const auto session = &user()->session(); auto about = tr::lng_rights_transfer_check_about( tr::now, @@ -533,7 +533,7 @@ void EditAdminBox::sendTransferRequestFrom( lt_user, user->shortName())); Ui::hideLayer(); - }).fail(crl::guard(this, [=](const RPCError &error) { + }).fail(crl::guard(this, [=](const MTP::Error &error) { if (weak) { _transferRequestId = 0; } diff --git a/Telegram/SourceFiles/boxes/peers/edit_participant_box.h b/Telegram/SourceFiles/boxes/peers/edit_participant_box.h index 474c166c1..56f3b0a56 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participant_box.h +++ b/Telegram/SourceFiles/boxes/peers/edit_participant_box.h @@ -10,7 +10,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/abstract_box.h" #include "base/unique_qptr.h" -class RPCError; +namespace MTP { +class Error; +} // namespace MTP namespace Ui { class FlatLabel; @@ -94,7 +96,7 @@ private: not_null addRankInput(); void transferOwnership(); void transferOwnershipChecked(); - bool handleTransferPasswordError(const RPCError &error); + bool handleTransferPasswordError(const MTP::Error &error); void requestTransferPassword(not_null channel); void sendTransferRequestFrom( QPointer box, diff --git a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp index c74dfa173..5ca87bd85 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp @@ -58,7 +58,7 @@ void RemoveAdmin( if (onDone) { onDone(); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { if (onFail) { onFail(); } @@ -79,7 +79,7 @@ void AddChatParticipant( if (onDone) { onDone(); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { ShowAddParticipantsError(error.type(), chat, { 1, user }); if (onFail) { onFail(); @@ -103,7 +103,7 @@ void SaveChatAdmin( if (onDone) { onDone(); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { const auto &type = error.type(); if (retryOnNotParticipant && isAdmin @@ -136,7 +136,7 @@ void SaveChannelAdmin( if (onDone) { onDone(); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { ShowAddParticipantsError(error.type(), channel, { 1, user }); if (onFail) { onFail(); @@ -161,7 +161,7 @@ void SaveChannelRestriction( if (onDone) { onDone(); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { if (onFail) { onFail(); } @@ -182,7 +182,7 @@ void SaveChatParticipantKick( if (onDone) { onDone(); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { if (onFail) { onFail(); } @@ -1336,7 +1336,7 @@ void ParticipantsBoxController::loadMoreRows() { _onlineSorter->sort(); } delegate()->peerListRefreshRows(); - }).fail([this](const RPCError &error) { + }).fail([this](const MTP::Error &error) { _loadRequestId = 0; }).send(); } @@ -2071,7 +2071,7 @@ bool ParticipantsBoxSearchController::loadMoreRows() { const MTPchannels_ChannelParticipants &result, mtpRequestId requestId) { searchDone(requestId, result, perPage); - }).fail([=](const RPCError &error, mtpRequestId requestId) { + }).fail([=](const MTP::Error &error, mtpRequestId requestId) { if (_requestId == requestId) { _requestId = 0; _allLoaded = true; diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp index 4c81c2797..085bb8921 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp @@ -153,7 +153,7 @@ void SaveDefaultRestrictions( api->clearModifyRequest(key); api->applyUpdates(result); done(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { api->clearModifyRequest(key); if (error.type() != qstr("CHAT_NOT_MODIFIED")) { return; @@ -186,7 +186,7 @@ void SaveSlowmodeSeconds( api->applyUpdates(result); channel->setSlowmodeSeconds(seconds); done(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { api->clearModifyRequest(key); if (error.type() != qstr("CHAT_NOT_MODIFIED")) { return; @@ -235,7 +235,7 @@ void ShowEditPermissions( const auto api = &peer->session().api(); api->migrateChat(chat, [=](not_null channel) { save(channel, result); - }, [=](const RPCError &error) { + }, [=](const MTP::Error &error) { *saving = false; }); }, box->lifetime()); @@ -278,7 +278,7 @@ void ShowEditInviteLinks( const auto api = &peer->session().api(); api->migrateChat(chat, [=](not_null channel) { save(channel, result); - }, [=](const RPCError &error) { + }, [=](const MTP::Error &error) { *saving = false; }); }, box->lifetime()); @@ -716,7 +716,7 @@ void Controller::showEditLinkedChatBox() { std::move(chats), callback), Ui::LayerOption::KeepOther); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _linkedChatsRequestId = 0; }).send(); } @@ -1290,7 +1290,7 @@ void Controller::saveUsername() { TextUtilities::SingleLine(channel->name), *_savingData.username); continueSave(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { const auto &type = error.type(); if (type == qstr("USERNAME_NOT_MODIFIED")) { channel->setName( @@ -1343,7 +1343,7 @@ void Controller::saveLinkedChat() { )).done([=](const MTPBool &result) { channel->setLinkedChat(*_savingData.linkedChat); continueSave(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { const auto &type = error.type(); cancelSave(); }).send(); @@ -1358,7 +1358,7 @@ void Controller::saveTitle() { _peer->session().api().applyUpdates(result); continueSave(); }; - const auto onFail = [=](const RPCError &error) { + const auto onFail = [=](const MTP::Error &error) { const auto &type = error.type(); if (type == qstr("CHAT_NOT_MODIFIED") || type == qstr("CHAT_TITLE_NOT_MODIFIED")) { @@ -1411,7 +1411,7 @@ void Controller::saveDescription() { MTP_string(*_savingData.description) )).done([=](const MTPBool &result) { successCallback(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { const auto &type = error.type(); if (type == qstr("CHAT_ABOUT_NOT_MODIFIED")) { successCallback(); @@ -1469,7 +1469,7 @@ void Controller::togglePreHistoryHidden( )).done([=](const MTPUpdates &result) { channel->session().api().applyUpdates(result); apply(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { if (error.type() == qstr("CHAT_NOT_MODIFIED")) { apply(); } else { @@ -1491,7 +1491,7 @@ void Controller::saveSignatures() { )).done([=](const MTPUpdates &result) { channel->session().api().applyUpdates(result); continueSave(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { if (error.type() == qstr("CHAT_NOT_MODIFIED")) { continueSave(); } else { @@ -1546,7 +1546,7 @@ void Controller::deleteChannel() { channel->inputChannel )).done([=](const MTPUpdates &result) { session->api().applyUpdates(result); - //}).fail([=](const RPCError &error) { + //}).fail([=](const MTP::Error &error) { // if (error.type() == qstr("CHANNEL_TOO_LARGE")) { // Ui::show(Box(tr::lng_cant_delete_channel(tr::now))); // } diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.cpp index 6d60d8cf1..8558fd126 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.cpp @@ -525,7 +525,7 @@ void Controller::loadMoreRows() { auto slice = Api::ParseJoinedByLinkSlice(_peer, result); _allLoaded = slice.users.empty(); appendSlice(slice); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _requestId = 0; _allLoaded = true; }).send(); diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp index a1570e1c6..4ecfa9a98 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp @@ -327,7 +327,7 @@ Fn AboutGigagroupCallback(not_null channel) { channel->session().api().applyUpdates(result); Ui::hideSettingsAndLayer(); Ui::Toast::Show(tr::lng_gigagroup_done(tr::now)); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { *converting = false; }).send(); }; diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp index 876882bcd..d18977597 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp @@ -452,7 +452,7 @@ void Controller::checkUsernameAvailability() { } else { showUsernameGood(); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _checkUsernameRequestId = 0; const auto &type = error.type(); _usernameState = UsernameState::Normal; diff --git a/Telegram/SourceFiles/boxes/rate_call_box.cpp b/Telegram/SourceFiles/boxes/rate_call_box.cpp index 1e8914201..324acf172 100644 --- a/Telegram/SourceFiles/boxes/rate_call_box.cpp +++ b/Telegram/SourceFiles/boxes/rate_call_box.cpp @@ -131,7 +131,7 @@ void RateCallBox::send() { )).done([=](const MTPUpdates &updates) { _session->api().applyUpdates(updates); closeBox(); - }).fail([=](const RPCError &error) { closeBox(); }).send(); + }).fail([=](const MTP::Error &error) { closeBox(); }).send(); } void RateCallBox::updateMaxHeight() { diff --git a/Telegram/SourceFiles/boxes/sessions_box.cpp b/Telegram/SourceFiles/boxes/sessions_box.cpp index 198c0e587..17506dd9a 100644 --- a/Telegram/SourceFiles/boxes/sessions_box.cpp +++ b/Telegram/SourceFiles/boxes/sessions_box.cpp @@ -275,7 +275,7 @@ void SessionsContent::terminateOne(uint64 hash) { removeByHash(_data.list); _inner->showData(_data); }); - auto fail = crl::guard(weak, [=](const RPCError &error) { + auto fail = crl::guard(weak, [=](const MTP::Error &error) { _inner->terminatingOne(hash, false); }); _authorizations->requestTerminate( @@ -296,7 +296,7 @@ void SessionsContent::terminateAll() { }); _authorizations->requestTerminate( [=](const MTPBool &result) { reset(); }, - [=](const RPCError &result) { reset(); }); + [=](const MTP::Error &result) { reset(); }); _loading = true; }; terminate(std::move(callback), tr::lng_settings_reset_sure(tr::now)); diff --git a/Telegram/SourceFiles/boxes/share_box.cpp b/Telegram/SourceFiles/boxes/share_box.cpp index 7feba6453..40dcb3ac5 100644 --- a/Telegram/SourceFiles/boxes/share_box.cpp +++ b/Telegram/SourceFiles/boxes/share_box.cpp @@ -340,7 +340,7 @@ bool ShareBox::searchByUsername(bool searchCache) { MTP_int(SearchPeopleLimit) )).done([=](const MTPcontacts_Found &result, mtpRequestId requestId) { peopleDone(result, requestId); - }).fail([=](const RPCError &error, mtpRequestId requestId) { + }).fail([=](const MTP::Error &error, mtpRequestId requestId) { peopleFail(error, requestId); }).send(); _peopleQueries.insert(_peopleRequest, _peopleQuery); @@ -386,7 +386,7 @@ void ShareBox::peopleDone( } } -void ShareBox::peopleFail(const RPCError &error, mtpRequestId requestId) { +void ShareBox::peopleFail(const MTP::Error &error, mtpRequestId requestId) { if (_peopleRequest == requestId) { _peopleRequest = 0; _peopleFull = true; diff --git a/Telegram/SourceFiles/boxes/share_box.h b/Telegram/SourceFiles/boxes/share_box.h index b6640eb62..487b598a6 100644 --- a/Telegram/SourceFiles/boxes/share_box.h +++ b/Telegram/SourceFiles/boxes/share_box.h @@ -116,7 +116,7 @@ private: void peopleDone( const MTPcontacts_Found &result, mtpRequestId requestId); - void peopleFail(const RPCError &error, mtpRequestId requestId); + void peopleFail(const MTP::Error &error, mtpRequestId requestId); Descriptor _descriptor; MTP::Sender _api; diff --git a/Telegram/SourceFiles/boxes/sticker_set_box.cpp b/Telegram/SourceFiles/boxes/sticker_set_box.cpp index 381b5aad9..3ade84fae 100644 --- a/Telegram/SourceFiles/boxes/sticker_set_box.cpp +++ b/Telegram/SourceFiles/boxes/sticker_set_box.cpp @@ -272,7 +272,7 @@ StickerSetBox::Inner::Inner( _input )).done([=](const MTPmessages_StickerSet &result) { gotSet(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _loaded = true; Ui::show(Box(tr::lng_stickers_not_found(tr::now))); }).send(); @@ -758,7 +758,7 @@ void StickerSetBox::Inner::install() { MTP_bool(false) )).done([=](const MTPmessages_StickerSetInstallResult &result) { installDone(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { Ui::show(Box(tr::lng_stickers_not_found(tr::now))); }).send(); } diff --git a/Telegram/SourceFiles/boxes/stickers_box.cpp b/Telegram/SourceFiles/boxes/stickers_box.cpp index 6ee3d8930..6100e2f62 100644 --- a/Telegram/SourceFiles/boxes/stickers_box.cpp +++ b/Telegram/SourceFiles/boxes/stickers_box.cpp @@ -778,7 +778,7 @@ void StickersBox::installSet(uint64 setId) { MTP_boolFalse() )).done([=](const MTPmessages_StickerSetInstallResult &result) { installDone(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { installFail(error, setId); }).send(); @@ -793,7 +793,7 @@ void StickersBox::installDone(const MTPmessages_StickerSetInstallResult &result) } } -void StickersBox::installFail(const RPCError &error, uint64 setId) { +void StickersBox::installFail(const MTP::Error &error, uint64 setId) { const auto &sets = session().data().stickers().sets(); const auto it = sets.find(setId); if (it == sets.cend()) { @@ -1765,7 +1765,7 @@ void StickersBox::Inner::handleMegagroupSetAddressChange() { setMegagroupSelectedSet(MTP_inputStickerSetID( MTP_long(set->id), MTP_long(set->access))); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _megagroupSetRequestId = 0; setMegagroupSelectedSet(MTP_inputStickerSetEmpty()); }).send(); diff --git a/Telegram/SourceFiles/boxes/stickers_box.h b/Telegram/SourceFiles/boxes/stickers_box.h index e2050940c..ae9fc8b5b 100644 --- a/Telegram/SourceFiles/boxes/stickers_box.h +++ b/Telegram/SourceFiles/boxes/stickers_box.h @@ -122,7 +122,7 @@ private: QPixmap grabContentCache(); void installDone(const MTPmessages_StickerSetInstallResult &result); - void installFail(const RPCError &error, uint64 setId); + void installFail(const MTP::Error &error, uint64 setId); void preloadArchivedSets(); void requestArchivedSets(); diff --git a/Telegram/SourceFiles/boxes/url_auth_box.cpp b/Telegram/SourceFiles/boxes/url_auth_box.cpp index 0ecb7eddb..d77e8bd35 100644 --- a/Telegram/SourceFiles/boxes/url_auth_box.cpp +++ b/Telegram/SourceFiles/boxes/url_auth_box.cpp @@ -68,7 +68,7 @@ void UrlAuthBox::Activate( Request(data, item, row, column); } }); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { const auto button = HistoryMessageMarkupButton::Get( &session->data(), itemId, @@ -106,7 +106,7 @@ void UrlAuthBox::Activate( }, [&](const MTPDurlAuthResultRequest &data) { Request(data, session, url, context); }); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { HiddenUrlClickHandler::Open(url, context); }).send(); } @@ -166,7 +166,7 @@ void UrlAuthBox::Request( return url; }); finishWithUrl(to); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { finishWithUrl(url); }).send(); } @@ -217,7 +217,7 @@ void UrlAuthBox::Request( return url; }); finishWithUrl(to); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { finishWithUrl(url); }).send(); } diff --git a/Telegram/SourceFiles/boxes/username_box.cpp b/Telegram/SourceFiles/boxes/username_box.cpp index 537e65429..19d3edc97 100644 --- a/Telegram/SourceFiles/boxes/username_box.cpp +++ b/Telegram/SourceFiles/boxes/username_box.cpp @@ -120,7 +120,7 @@ void UsernameBox::save() { MTP_string(_sentUsername) )).done([=](const MTPUser &result) { updateDone(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { updateFail(error); }).send(); } @@ -135,7 +135,7 @@ void UsernameBox::check() { MTP_string(name) )).done([=](const MTPBool &result) { checkDone(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { checkFail(error); }).send(); } @@ -190,7 +190,7 @@ void UsernameBox::updateDone(const MTPUser &user) { closeBox(); } -void UsernameBox::updateFail(const RPCError &error) { +void UsernameBox::updateFail(const MTP::Error &error) { _saveRequestId = 0; const auto self = _session->user(); const auto &err = error.type(); @@ -232,7 +232,7 @@ void UsernameBox::checkDone(const MTPBool &result) { } } -void UsernameBox::checkFail(const RPCError &error) { +void UsernameBox::checkFail(const MTP::Error &error) { _checkRequestId = 0; QString err(error.type()); if (err == qstr("USERNAME_INVALID")) { diff --git a/Telegram/SourceFiles/boxes/username_box.h b/Telegram/SourceFiles/boxes/username_box.h index 10b0cb6cc..7cfad1d0e 100644 --- a/Telegram/SourceFiles/boxes/username_box.h +++ b/Telegram/SourceFiles/boxes/username_box.h @@ -32,10 +32,10 @@ protected: private: void updateDone(const MTPUser &result); - void updateFail(const RPCError &error); + void updateFail(const MTP::Error &error); void checkDone(const MTPBool &result); - void checkFail(const RPCError &error); + void checkFail(const MTP::Error &error); void save(); diff --git a/Telegram/SourceFiles/calls/calls_box_controller.cpp b/Telegram/SourceFiles/calls/calls_box_controller.cpp index e32bf71c7..af858fc93 100644 --- a/Telegram/SourceFiles/calls/calls_box_controller.cpp +++ b/Telegram/SourceFiles/calls/calls_box_controller.cpp @@ -343,7 +343,7 @@ void BoxController::loadMoreRows() { } break; default: Unexpected("Type of messages.Messages (Calls::BoxController::preloadRows)"); } - }).fail([this](const RPCError &error) { + }).fail([this](const MTP::Error &error) { _loadRequestId = 0; }).send(); } diff --git a/Telegram/SourceFiles/calls/calls_call.cpp b/Telegram/SourceFiles/calls/calls_call.cpp index bdd8fdd53..9c0c1e924 100644 --- a/Telegram/SourceFiles/calls/calls_call.cpp +++ b/Telegram/SourceFiles/calls/calls_call.cpp @@ -266,7 +266,7 @@ void Call::startOutgoing() { const auto &config = _user->session().serverConfig(); _discardByTimeoutTimer.callOnce(config.callReceiveTimeoutMs); handleUpdate(phoneCall); - }).fail([this](const RPCError &error) { + }).fail([this](const MTP::Error &error) { handleRequestError(error); }).send(); } @@ -281,7 +281,7 @@ void Call::startIncoming() { if (_state.current() == State::Starting) { setState(State::WaitingIncoming); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { handleRequestError(error); }).send(); } @@ -340,7 +340,7 @@ void Call::actuallyAnswer() { } handleUpdate(call.vphone_call()); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { handleRequestError(error); }).send(); } @@ -456,7 +456,7 @@ void Call::sendSignalingData(const QByteArray &data) { if (!mtpIsTrue(result)) { finish(FinishType::Failed); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { handleRequestError(error); }).send(); } @@ -686,7 +686,7 @@ void Call::confirmAcceptedCall(const MTPDphoneCallAccepted &call) { } createAndStartController(call.vphone_call().c_phoneCall()); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { handleRequestError(error); }).send(); } @@ -1052,7 +1052,7 @@ void Call::finish(FinishType type, const MTPPhoneCallDiscardReason &reason) { // updates being handled, but in a guarded way. crl::on_main(weak, [=] { setState(finalState); }); session->api().applyUpdates(result); - }).fail(crl::guard(weak, [this, finalState](const RPCError &error) { + }).fail(crl::guard(weak, [this, finalState](const MTP::Error &error) { setState(finalState); })).send(); } @@ -1069,7 +1069,7 @@ void Call::setFailedQueued(const QString &error) { }); } -void Call::handleRequestError(const RPCError &error) { +void Call::handleRequestError(const MTP::Error &error) { if (error.type() == qstr("USER_PRIVACY_RESTRICTED")) { Ui::show(Box(tr::lng_call_error_not_available(tr::now, lt_user, _user->name))); } else if (error.type() == qstr("PARTICIPANT_VERSION_OUTDATED")) { diff --git a/Telegram/SourceFiles/calls/calls_call.h b/Telegram/SourceFiles/calls/calls_call.h index e4dcf2d65..b84f5c51f 100644 --- a/Telegram/SourceFiles/calls/calls_call.h +++ b/Telegram/SourceFiles/calls/calls_call.h @@ -196,7 +196,7 @@ private: Failed, }; - void handleRequestError(const RPCError &error); + void handleRequestError(const MTP::Error &error); void handleControllerError(const QString &error); void finish( FinishType type, diff --git a/Telegram/SourceFiles/calls/calls_choose_join_as.cpp b/Telegram/SourceFiles/calls/calls_choose_join_as.cpp index 2a4620764..b3d60c699 100644 --- a/Telegram/SourceFiles/calls/calls_choose_join_as.cpp +++ b/Telegram/SourceFiles/calls/calls_choose_join_as.cpp @@ -272,7 +272,7 @@ void ChooseJoinAsProcess::start( _request->box = box.data(); _request->showBox(std::move(box)); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { finish({ .peer = _request->peer, .joinAs = _request->peer->session().user(), diff --git a/Telegram/SourceFiles/calls/calls_group_call.cpp b/Telegram/SourceFiles/calls/calls_group_call.cpp index 9490926f2..f3ce8a2d6 100644 --- a/Telegram/SourceFiles/calls/calls_group_call.cpp +++ b/Telegram/SourceFiles/calls/calls_group_call.cpp @@ -332,7 +332,7 @@ void GroupCall::start() { _acceptFields = true; _peer->session().api().applyUpdates(result); _acceptFields = false; - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { LOG(("Call Error: Could not create, error: %1" ).arg(error.type())); hangup(); @@ -467,7 +467,7 @@ void GroupCall::rejoin(not_null as) { applyMeInCallLocally(); maybeSendMutedUpdate(wasMuteState); _peer->session().api().applyUpdates(updates); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { const auto type = error.type(); LOG(("Call Error: Could not join, error: %1").arg(type)); @@ -603,7 +603,7 @@ void GroupCall::discard() { // updates being handled, but in a guarded way. crl::on_main(this, [=] { hangup(); }); _peer->session().api().applyUpdates(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { hangup(); }).send(); } @@ -657,7 +657,7 @@ void GroupCall::finish(FinishType type) { // updates being handled, but in a guarded way. crl::on_main(weak, [=] { setState(finalState); }); session->api().applyUpdates(result); - }).fail(crl::guard(weak, [=](const RPCError &error) { + }).fail(crl::guard(weak, [=](const MTP::Error &error) { setState(finalState); })).send(); } @@ -911,7 +911,7 @@ void GroupCall::changeTitle(const QString &title) { MTP_string(title) )).done([=](const MTPUpdates &result) { _peer->session().api().applyUpdates(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { }).send(); } @@ -938,7 +938,7 @@ void GroupCall::toggleRecording(bool enabled, const QString &title) { )).done([=](const MTPUpdates &result) { _peer->session().api().applyUpdates(result); _recordingStoppedByMe = false; - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _recordingStoppedByMe = false; }).send(); } @@ -1060,7 +1060,7 @@ void GroupCall::broadcastPartStart(std::shared_ptr task) { .status = Status::ResyncNeeded, }); }); - }).fail([=](const RPCError &error, const MTP::Response &response) { + }).fail([=](const MTP::Error &error, const MTP::Response &response) { if (error.type() == u"GROUPCALL_JOIN_MISSING"_q) { for (const auto &[task, part] : _broadcastParts) { _api.request(part.requestId).cancel(); @@ -1069,7 +1069,7 @@ void GroupCall::broadcastPartStart(std::shared_ptr task) { rejoin(); return; } - const auto status = MTP::isFloodError(error) + const auto status = MTP::IsFloodError(error) ? Status::NotReady : Status::ResyncNeeded; finish({ @@ -1248,7 +1248,7 @@ void GroupCall::checkJoined() { } else if (state() == State::Connecting) { _checkJoinedTimer.callOnce(kCheckJoinedTimeout); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { LOG(("Call Info: Rejoin after error '%1' in checkGroupCall." ).arg(error.type())); rejoin(); @@ -1320,7 +1320,7 @@ void GroupCall::sendSelfUpdate(SendUpdateType type) { )).done([=](const MTPUpdates &result) { _updateMuteRequestId = 0; _peer->session().api().applyUpdates(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _updateMuteRequestId = 0; if (error.type() == u"GROUPCALL_FORBIDDEN"_q) { LOG(("Call Info: Rejoin after error '%1' in editGroupCallMember." @@ -1384,7 +1384,7 @@ void GroupCall::editParticipant( MTPBool() )).done([=](const MTPUpdates &result) { _peer->session().api().applyUpdates(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { if (error.type() == u"GROUPCALL_FORBIDDEN"_q) { LOG(("Call Info: Rejoin after error '%1' in editGroupCallMember." ).arg(error.type())); @@ -1529,7 +1529,7 @@ void GroupCall::setAudioDuckingEnabled(bool enabled) { } } -void GroupCall::handleRequestError(const RPCError &error) { +void GroupCall::handleRequestError(const MTP::Error &error) { //if (error.type() == qstr("USER_PRIVACY_RESTRICTED")) { // Ui::show(Box(tr::lng_call_error_not_available(tr::now, lt_user, _user->name))); //} else if (error.type() == qstr("PARTICIPANT_VERSION_OUTDATED")) { diff --git a/Telegram/SourceFiles/calls/calls_group_call.h b/Telegram/SourceFiles/calls/calls_group_call.h index 79227c865..ce314216b 100644 --- a/Telegram/SourceFiles/calls/calls_group_call.h +++ b/Telegram/SourceFiles/calls/calls_group_call.h @@ -209,7 +209,7 @@ private: RaiseHand, }; - void handleRequestError(const RPCError &error); + void handleRequestError(const MTP::Error &error); void handleControllerError(const QString &error); void ensureControllerCreated(); void destroyController(); diff --git a/Telegram/SourceFiles/calls/calls_instance.cpp b/Telegram/SourceFiles/calls/calls_instance.cpp index ea875c671..c19d691a6 100644 --- a/Telegram/SourceFiles/calls/calls_instance.cpp +++ b/Telegram/SourceFiles/calls/calls_instance.cpp @@ -245,7 +245,7 @@ void Instance::refreshDhConfig() { } else { callFailed(call); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { const auto call = weak.get(); if (!call) { return; @@ -304,7 +304,7 @@ void Instance::refreshServerConfig(not_null session) { const auto &json = result.c_dataJSON().vdata().v; UpdateConfig(std::string(json.data(), json.size())); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _serverConfigRequestSession = nullptr; }).send(); } diff --git a/Telegram/SourceFiles/chat_helpers/emoji_keywords.cpp b/Telegram/SourceFiles/chat_helpers/emoji_keywords.cpp index e2f1ddf4a..68e879915 100644 --- a/Telegram/SourceFiles/chat_helpers/emoji_keywords.cpp +++ b/Telegram/SourceFiles/chat_helpers/emoji_keywords.cpp @@ -399,7 +399,7 @@ void EmojiKeywords::LangPack::refresh() { _requestId = 0; _lastRefreshTime = crl::now(); applyDifference(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _requestId = 0; _lastRefreshTime = crl::now(); }).send(); @@ -670,7 +670,7 @@ void EmojiKeywords::refreshRemoteList() { }); }) | ranges::to_vector); _langsRequestId = 0; - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _langsRequestId = 0; }).send(); } diff --git a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp index 39b9cb636..ab46361a9 100644 --- a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp @@ -1001,7 +1001,7 @@ void GifsListWidget::sendInlineRequest() { MTP_string(nextOffset) )).done([this](const MTPmessages_BotResults &result) { inlineResultsDone(result); - }).fail([this](const RPCError &error) { + }).fail([this](const MTP::Error &error) { // show error? _footer->setLoading(false); _inlineRequestId = 0; diff --git a/Telegram/SourceFiles/chat_helpers/stickers_dice_pack.cpp b/Telegram/SourceFiles/chat_helpers/stickers_dice_pack.cpp index 631cc8df0..4d607e650 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_dice_pack.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_dice_pack.cpp @@ -52,7 +52,7 @@ void DicePack::load() { result.match([&](const MTPDmessages_stickerSet &data) { applySet(data); }); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _requestId = 0; }).send(); } diff --git a/Telegram/SourceFiles/chat_helpers/stickers_emoji_pack.cpp b/Telegram/SourceFiles/chat_helpers/stickers_emoji_pack.cpp index a6fe22c1c..490f09bfc 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_emoji_pack.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_emoji_pack.cpp @@ -220,7 +220,7 @@ void EmojiPack::refresh() { result.match([&](const MTPDmessages_stickerSet &data) { applySet(data); }); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _requestId = 0; refreshDelayed(); }).send(); diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp index a53206cde..01c195aa2 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp @@ -1045,7 +1045,7 @@ void StickersListWidget::preloadMoreOfficial() { }); resizeToWidth(width()); update(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { }).send(); } @@ -1215,7 +1215,7 @@ void StickersListWidget::sendSearchRequest() { MTP_int(hash) )).done([=](const MTPmessages_FoundStickerSets &result) { searchResultsDone(result); - }).fail([this](const RPCError &error) { + }).fail([this](const MTP::Error &error) { // show error? _footer->setLoading(false); _searchRequestId = 0; @@ -3066,7 +3066,7 @@ void StickersListWidget::sendInstallRequest( session().data().stickers().applyArchivedResult( result.c_messages_stickerSetInstallResultArchive()); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { notInstalledLocally(setId); session().data().stickers().undoInstallLocally(setId); }).send(); diff --git a/Telegram/SourceFiles/core/update_checker.cpp b/Telegram/SourceFiles/core/update_checker.cpp index 850e1535e..df1d66277 100644 --- a/Telegram/SourceFiles/core/update_checker.cpp +++ b/Telegram/SourceFiles/core/update_checker.cpp @@ -183,7 +183,7 @@ private: using FileLocation = MTP::DedicatedLoader::Location; using Checker::fail; - Fn failHandler(); + Fn failHandler(); void gotMessage(const MTPmessages_Messages &result); std::optional parseMessage( @@ -1002,8 +1002,8 @@ auto MtpChecker::validateLatestLocation( return (availableVersion <= myVersion) ? FileLocation() : location; } -Fn MtpChecker::failHandler() { - return [=](const RPCError &error) { +Fn MtpChecker::failHandler() { + return [=](const MTP::Error &error) { LOG(("Update Error: MTP check failed with '%1'" ).arg(QString::number(error.code()) + ':' + error.type())); fail(); diff --git a/Telegram/SourceFiles/data/data_chat_filters.cpp b/Telegram/SourceFiles/data/data_chat_filters.cpp index 8d5e01e97..cf62f5dc4 100644 --- a/Telegram/SourceFiles/data/data_chat_filters.cpp +++ b/Telegram/SourceFiles/data/data_chat_filters.cpp @@ -256,7 +256,7 @@ void ChatFilters::load(bool force) { )).done([=](const MTPVector &result) { received(result.v); _loadRequestId = 0; - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _loadRequestId = 0; }).send(); } @@ -555,7 +555,7 @@ bool ChatFilters::loadNextExceptions(bool chatsListLoaded) { _exceptionsLoadRequestId = 0; _owner->session().data().histories().applyPeerDialogs(result); _owner->session().api().requestMoreDialogsIfNeeded(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _exceptionsLoadRequestId = 0; _owner->session().api().requestMoreDialogsIfNeeded(); }).send(); @@ -594,7 +594,7 @@ void ChatFilters::requestSuggested() { }) | ranges::to_vector; _suggestedUpdated.fire({}); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _suggestedRequestId = 0; _suggestedLastReceived = crl::now() + kRefreshSuggestedTimeout / 2; diff --git a/Telegram/SourceFiles/data/data_cloud_themes.cpp b/Telegram/SourceFiles/data/data_cloud_themes.cpp index f23664d15..6a1b3e70a 100644 --- a/Telegram/SourceFiles/data/data_cloud_themes.cpp +++ b/Telegram/SourceFiles/data/data_cloud_themes.cpp @@ -120,7 +120,7 @@ void CloudThemes::reloadCurrent() { MTP_long(fields.documentId) )).done([=](const MTPTheme &result) { applyUpdate(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _reloadCurrentTimer.callOnce(kReloadTimeout); }).send(); } @@ -149,7 +149,7 @@ void CloudThemes::resolve( MTP_long(0) )).done([=](const MTPTheme &result) { showPreview(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { if (error.type() == qstr("THEME_FORMAT_INVALID")) { Ui::show(Box( tr::lng_theme_no_desktop(tr::now))); @@ -261,7 +261,7 @@ void CloudThemes::refresh() { _updates.fire({}); }, [](const MTPDaccount_themesNotModified &) { }); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _refreshRquestId = 0; }).send(); } diff --git a/Telegram/SourceFiles/data/data_group_call.cpp b/Telegram/SourceFiles/data/data_group_call.cpp index d89109c86..902126003 100644 --- a/Telegram/SourceFiles/data/data_group_call.cpp +++ b/Telegram/SourceFiles/data/data_group_call.cpp @@ -103,7 +103,7 @@ void GroupCall::requestParticipants() { _participantsSliceAdded.fire({}); _participantsRequestId = 0; changePeerEmptyCallFlag(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _fullCount = _participants.size(); _allReceived = true; _participantsRequestId = 0; @@ -236,7 +236,7 @@ void GroupCall::reload() { _participantsSliceAdded.fire({}); }); _reloadRequestId = 0; - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _reloadRequestId = 0; }).send(); } @@ -563,7 +563,7 @@ void GroupCall::requestUnknownParticipants() { _unknownSpokenPeerIds.remove(id); } requestUnknownParticipants(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _unknownParticipantPeersRequestId = 0; for (const auto [ssrc, when] : ssrcs) { _unknownSpokenSsrcs.remove(ssrc); diff --git a/Telegram/SourceFiles/data/data_histories.cpp b/Telegram/SourceFiles/data/data_histories.cpp index 6c9eacc2a..03d0666c6 100644 --- a/Telegram/SourceFiles/data/data_histories.cpp +++ b/Telegram/SourceFiles/data/data_histories.cpp @@ -266,7 +266,7 @@ void Histories::requestDialogEntry(not_null folder) { )).done([=](const MTPmessages_PeerDialogs &result) { applyPeerDialogs(result); _dialogFolderRequests.remove(folder); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _dialogFolderRequests.remove(folder); }).send(); } @@ -346,7 +346,7 @@ void Histories::sendDialogRequests() { )).done([=](const MTPmessages_PeerDialogs &result) { applyPeerDialogs(result); finalize(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { finalize(); }).send(); } @@ -426,7 +426,7 @@ void Histories::requestFakeChatListMessage( _fakeChatListRequests.erase(history); history->setFakeChatListMessageFrom(result); finish(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _fakeChatListRequests.erase(history); history->setFakeChatListMessageFrom(MTP_messages_messages( MTP_vector(0), @@ -510,7 +510,7 @@ void Histories::sendReadRequest(not_null history, State &state) { MTP_int(tillId) )).done([=](const MTPBool &result) { finished(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { finished(); }).send(); } else { @@ -520,7 +520,7 @@ void Histories::sendReadRequest(not_null history, State &state) { )).done([=](const MTPmessages_AffectedMessages &result) { session().api().applyAffectedMessages(history->peer, result); finished(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { finished(); }).send(); } @@ -565,7 +565,7 @@ void Histories::deleteMessages( finish(); history->requestChatListMessage(); }; - const auto fail = [=](const RPCError &error) { + const auto fail = [=](const MTP::Error &error) { finish(); }; if (const auto channel = history->peer->asChannel()) { @@ -590,7 +590,7 @@ void Histories::deleteAllMessages( bool revoke) { sendRequest(history, RequestType::Delete, [=](Fn finish) { const auto peer = history->peer; - const auto fail = [=](const RPCError &error) { + const auto fail = [=](const MTP::Error &error) { finish(); }; const auto chat = peer->asChat(); @@ -600,7 +600,7 @@ void Histories::deleteAllMessages( channel->inputChannel )).done([=](const MTPUpdates &result) { session().api().applyUpdates(result); - //}).fail([=](const RPCError &error) { + //}).fail([=](const MTP::Error &error) { // if (error.type() == qstr("CHANNEL_TOO_LARGE")) { // Ui::show(Box(tr::lng_cant_delete_channel(tr::now))); // } @@ -617,7 +617,7 @@ void Histories::deleteAllMessages( chat->inputChat )).done([=](const MTPBool &result) { finish(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { if (error.type() == "PEER_ID_INVALID") { // Try to join and delete, // while delete fails for non-joined. diff --git a/Telegram/SourceFiles/data/data_replies_list.cpp b/Telegram/SourceFiles/data/data_replies_list.cpp index b2004fa79..26af2e370 100644 --- a/Telegram/SourceFiles/data/data_replies_list.cpp +++ b/Telegram/SourceFiles/data/data_replies_list.cpp @@ -412,7 +412,7 @@ void RepliesList::loadAround(MsgId id) { _skippedBefore = 0; } } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _beforeId = 0; _loadingAround = std::nullopt; finish(); @@ -460,7 +460,7 @@ void RepliesList::loadBefore() { _fullCount = _list.size(); } } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _beforeId = 0; finish(); }).send(); @@ -504,7 +504,7 @@ void RepliesList::loadAfter() { _fullCount = _list.size(); } } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _afterId = 0; finish(); }).send(); diff --git a/Telegram/SourceFiles/data/data_scheduled_messages.cpp b/Telegram/SourceFiles/data/data_scheduled_messages.cpp index 842e1ba71..36d9134e0 100644 --- a/Telegram/SourceFiles/data/data_scheduled_messages.cpp +++ b/Telegram/SourceFiles/data/data_scheduled_messages.cpp @@ -383,7 +383,7 @@ void ScheduledMessages::request(not_null history) { MTP_int(hash)) ).done([=](const MTPmessages_Messages &result) { parse(history, result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _requests.remove(history); }).send(); } diff --git a/Telegram/SourceFiles/data/data_search_controller.cpp b/Telegram/SourceFiles/data/data_search_controller.cpp index b12f7fbc5..ab53a656b 100644 --- a/Telegram/SourceFiles/data/data_search_controller.cpp +++ b/Telegram/SourceFiles/data/data_search_controller.cpp @@ -391,7 +391,7 @@ void SearchController::requestMore( parsed.noSkipRange, parsed.fullCount); finish(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { finish(); }).send(); }); diff --git a/Telegram/SourceFiles/data/stickers/data_stickers.cpp b/Telegram/SourceFiles/data/stickers/data_stickers.cpp index 13cb46bc0..1cdc60400 100644 --- a/Telegram/SourceFiles/data/stickers/data_stickers.cpp +++ b/Telegram/SourceFiles/data/stickers/data_stickers.cpp @@ -545,7 +545,7 @@ void Stickers::requestSetToPushFaved(not_null document) { } } addAnyway(std::move(list)); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { // Perhaps this is a deleted sticker pack. Add anyway. addAnyway({}); }).send(); diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h index 8716413f2..1127035a9 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h @@ -14,7 +14,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/flags.h" #include "base/object_ptr.h" -class RPCError; +namespace MTP { +class Error; +} // namespace MTP namespace Main { class Session; diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index 9e537e549..a174fa90b 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -853,7 +853,7 @@ bool Widget::onSearchMessages(bool searchCache) { _searchInHistoryRequest = 0; searchReceived(type, result, _searchRequest); finish(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _searchInHistoryRequest = 0; searchFailed(type, error, _searchRequest); finish(); @@ -880,7 +880,7 @@ bool Widget::onSearchMessages(bool searchCache) { MTP_int(SearchPerPage) )).done([=](const MTPmessages_Messages &result) { searchReceived(type, result, _searchRequest); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { searchFailed(type, error, _searchRequest); }).send(); _searchQueries.emplace(_searchRequest, _searchQuery); @@ -904,7 +904,7 @@ bool Widget::onSearchMessages(bool searchCache) { MTP_int(SearchPeopleLimit) )).done([=](const MTPcontacts_Found &result, mtpRequestId requestId) { peerSearchReceived(result, requestId); - }).fail([=](const RPCError &error, mtpRequestId requestId) { + }).fail([=](const MTP::Error &error, mtpRequestId requestId) { peopleFailed(error, requestId); }).send(); _peerSearchQueries.emplace(_peerSearchRequest, _peerSearchQuery); @@ -1011,7 +1011,7 @@ void Widget::onSearchMore() { searchReceived(type, result, _searchRequest); _searchInHistoryRequest = 0; finish(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { searchFailed(type, error, _searchRequest); _searchInHistoryRequest = 0; finish(); @@ -1044,7 +1044,7 @@ void Widget::onSearchMore() { MTP_int(SearchPerPage) )).done([=](const MTPmessages_Messages &result) { searchReceived(type, result, _searchRequest); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { searchFailed(type, error, _searchRequest); }).send(); if (!offsetId) { @@ -1084,7 +1084,7 @@ void Widget::onSearchMore() { searchReceived(type, result, _searchRequest); _searchInHistoryRequest = 0; finish(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { searchFailed(type, error, _searchRequest); _searchInHistoryRequest = 0; finish(); @@ -1233,7 +1233,7 @@ void Widget::peerSearchReceived( void Widget::searchFailed( SearchRequestType type, - const RPCError &error, + const MTP::Error &error, mtpRequestId requestId) { if (error.type() == qstr("SEARCH_QUERY_EMPTY")) { searchReceived( @@ -1253,7 +1253,7 @@ void Widget::searchFailed( } } -void Widget::peopleFailed(const RPCError &error, mtpRequestId requestId) { +void Widget::peopleFailed(const MTP::Error &error, mtpRequestId requestId) { if (_peerSearchRequest == requestId) { _peerSearchRequest = 0; _peerSearchFull = true; diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.h b/Telegram/SourceFiles/dialogs/dialogs_widget.h index aced391a6..739b3fdb2 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.h +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.h @@ -15,7 +15,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "mtproto/sender.h" #include "api/api_single_message_search.h" -class RPCError; +namespace MTP { +class Error; +} // namespace MTP namespace Main { class Session; @@ -166,9 +168,9 @@ private: void searchFailed( SearchRequestType type, - const RPCError &error, + const MTP::Error &error, mtpRequestId requestId); - void peopleFailed(const RPCError &error, mtpRequestId requestId); + void peopleFailed(const MTP::Error &error, mtpRequestId requestId); void scrollToTop(); void setupScrollUpButton(); diff --git a/Telegram/SourceFiles/export/export_api_wrap.cpp b/Telegram/SourceFiles/export/export_api_wrap.cpp index 04fb24e77..cfa1d97e9 100644 --- a/Telegram/SourceFiles/export/export_api_wrap.cpp +++ b/Telegram/SourceFiles/export/export_api_wrap.cpp @@ -11,7 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "export/data/export_data_types.h" #include "export/output/export_output_result.h" #include "export/output/export_output_file.h" -#include "mtproto/mtproto_rpc_sender.h" +#include "mtproto/mtproto_response.h" #include "base/value_ordering.h" #include "base/bytes.h" #include @@ -249,26 +249,26 @@ public: RequestBuilder( Original &&builder, - Fn commonFailHandler); + Fn commonFailHandler); [[nodiscard]] RequestBuilder &done(FnMut &&handler); [[nodiscard]] RequestBuilder &done( FnMut &&handler); [[nodiscard]] RequestBuilder &fail( - Fn &&handler); + Fn &&handler); mtpRequestId send(); private: Original _builder; - Fn _commonFailHandler; + Fn _commonFailHandler; }; template ApiWrap::RequestBuilder::RequestBuilder( Original &&builder, - Fn commonFailHandler) + Fn commonFailHandler) : _builder(std::move(builder)) , _commonFailHandler(std::move(commonFailHandler)) { } @@ -295,13 +295,13 @@ auto ApiWrap::RequestBuilder::done( template auto ApiWrap::RequestBuilder::fail( - Fn &&handler + Fn &&handler ) -> RequestBuilder& { if (handler) { auto &silence_warning = _builder.fail([ common = base::take(_commonFailHandler), specific = std::move(handler) - ](const RPCError &error) mutable { + ](const MTP::Error &error) mutable { if (!specific(error)) { common(error); } @@ -364,7 +364,7 @@ auto ApiWrap::mainRequest(Request &&request) { return RequestBuilder>( std::move(original), - [=](const RPCError &result) { error(result); }); + [=](const MTP::Error &result) { error(result); }); } template @@ -391,7 +391,7 @@ auto ApiWrap::fileRequest(const Data::FileLocation &location, int offset) { location.data, MTP_int(offset), MTP_int(kFileChunkSize)) - )).fail([=](const RPCError &result) { + )).fail([=](const MTP::Error &result) { if (result.type() == qstr("TAKEOUT_FILE_EMPTY") && _otherDataProcess != nullptr) { filePartDone( @@ -418,7 +418,7 @@ ApiWrap::ApiWrap(QPointer weak, Fn)> runner) , _fileCache(std::make_unique(kLocationCacheSize)) { } -rpl::producer ApiWrap::errors() const { +rpl::producer ApiWrap::errors() const { return _errors.events(); } @@ -688,10 +688,10 @@ void ApiWrap::startMainSession(FnMut done) { return data.vid().v; }); done(); - }).fail([=](const RPCError &result) { + }).fail([=](const MTP::Error &result) { error(result); }).toDC(MTP::ShiftDcId(0, MTP::kExportDcShift)).send(); - }).fail([=](const RPCError &result) { + }).fail([=](const MTP::Error &result) { error(result); }).send(); } @@ -1454,7 +1454,7 @@ void ApiWrap::requestChatMessages( MTP_int(0), // max_id MTP_int(0), // min_id MTP_int(0) // hash - )).fail([=](const RPCError &error) { + )).fail([=](const MTP::Error &error) { Expects(_chatProcess != nullptr); if (error.type() == qstr("CHANNEL_PRIVATE")) { @@ -1875,7 +1875,7 @@ void ApiWrap::filePartRefreshReference(int offset) { MTP_vector( 1, MTP_inputMessageID(MTP_int(origin.messageId))) - )).fail([=](const RPCError &error) { + )).fail([=](const MTP::Error &error) { filePartUnavailable(); return true; }).done([=](const MTPmessages_Messages &result) { @@ -1886,7 +1886,7 @@ void ApiWrap::filePartRefreshReference(int offset) { MTP_vector( 1, MTP_inputMessageID(MTP_int(origin.messageId))) - )).fail([=](const RPCError &error) { + )).fail([=](const MTP::Error &error) { filePartUnavailable(); return true; }).done([=](const MTPmessages_Messages &result) { @@ -1945,12 +1945,12 @@ void ApiWrap::filePartUnavailable() { base::take(_fileProcess)->done(QString()); } -void ApiWrap::error(const RPCError &error) { +void ApiWrap::error(const MTP::Error &error) { _errors.fire_copy(error); } void ApiWrap::error(const QString &text) { - error(RPCError( + error(MTP::Error( MTP_rpc_error(MTP_int(0), MTP_string("API_ERROR: " + text)))); } diff --git a/Telegram/SourceFiles/export/export_api_wrap.h b/Telegram/SourceFiles/export/export_api_wrap.h index 6ce4bfb96..f1b43cf61 100644 --- a/Telegram/SourceFiles/export/export_api_wrap.h +++ b/Telegram/SourceFiles/export/export_api_wrap.h @@ -37,7 +37,7 @@ class ApiWrap { public: ApiWrap(QPointer weak, Fn)> runner); - rpl::producer errors() const; + rpl::producer errors() const; rpl::producer ioErrors() const; struct StartInfo { @@ -203,7 +203,7 @@ private: const Data::FileLocation &location, int offset); - void error(const RPCError &error); + void error(const MTP::Error &error); void error(const QString &text); void ioError(const Output::Result &result); @@ -226,7 +226,7 @@ private: std::unique_ptr _chatProcess; QVector _splits; - rpl::event_stream _errors; + rpl::event_stream _errors; rpl::event_stream _ioErrors; }; diff --git a/Telegram/SourceFiles/export/export_controller.cpp b/Telegram/SourceFiles/export/export_controller.cpp index f442c7693..fcef0bea2 100644 --- a/Telegram/SourceFiles/export/export_controller.cpp +++ b/Telegram/SourceFiles/export/export_controller.cpp @@ -138,7 +138,7 @@ ControllerObject::ControllerObject( : _api(mtproto, weak.runner()) , _state(PasswordCheckState{}) { _api.errors( - ) | rpl::start_with_next([=](const RPCError &error) { + ) | rpl::start_with_next([=](const MTP::Error &error) { setState(ApiErrorState{ error }); }, _lifetime); @@ -211,7 +211,7 @@ bool ControllerObject::ioCatchError(Output::Result result) { // //)).done([=](const MTPaccount_Password &result) { // // _passwordRequestId = 0; // // passwordStateDone(result); -// //}).fail([=](const RPCError &error) { +// //}).fail([=](const MTP::Error &error) { // // apiError(error); // //}).send(); //} diff --git a/Telegram/SourceFiles/export/export_controller.h b/Telegram/SourceFiles/export/export_controller.h index 122657d48..b99c74d37 100644 --- a/Telegram/SourceFiles/export/export_controller.h +++ b/Telegram/SourceFiles/export/export_controller.h @@ -8,7 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #pragma once #include "base/variant.h" -#include "mtproto/mtproto_rpc_sender.h" +#include "mtproto/mtproto_response.h" #include #include @@ -81,7 +81,7 @@ struct ProcessingState { }; struct ApiErrorState { - RPCError data; + MTP::Error data; }; struct OutputErrorState { diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp index 069ec5b1a..f0b9c6d37 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp @@ -697,7 +697,7 @@ void InnerWidget::preloadMore(Direction direction) { if (!loadedFlag) { addEvents(direction, results.vevents().v); } - }).fail([this, &requestId, &loadedFlag](const RPCError &error) { + }).fail([this, &requestId, &loadedFlag](const MTP::Error &error) { requestId = 0; loadedFlag = true; update(); @@ -1326,7 +1326,7 @@ void InnerWidget::suggestRestrictUser(not_null user) { MTP_int(0)); editRestrictions(hasAdminRights, bannedRights); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { auto bannedRights = MTP_chatBannedRights( MTP_flags(0), MTP_int(0)); diff --git a/Telegram/SourceFiles/history/history_message.cpp b/Telegram/SourceFiles/history/history_message.cpp index 070b8e4c7..6e01d5681 100644 --- a/Telegram/SourceFiles/history/history_message.cpp +++ b/Telegram/SourceFiles/history/history_message.cpp @@ -330,7 +330,7 @@ void FastShareMessage(not_null item) { Ui::hideLayer(); } finish(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { finish(); }).afterRequest(history->sendRequestId).send(); return history->sendRequestId; diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 88e9e8e45..9d6495cf8 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -1235,7 +1235,7 @@ void HistoryWidget::updateInlineBotQuery() { MTP_string(username) )).done([=](const MTPcontacts_ResolvedPeer &result) { inlineBotResolveDone(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { inlineBotResolveFail(error, username); }).send(); } else { @@ -2476,7 +2476,7 @@ void HistoryWidget::unreadCountUpdated() { } } -void HistoryWidget::messagesFailed(const RPCError &error, int requestId) { +void HistoryWidget::messagesFailed(const MTP::Error &error, int requestId) { if (error.type() == qstr("CHANNEL_PRIVATE") && _peer->isChannel() && _peer->asChannel()->invitePeekExpires()) { @@ -2714,7 +2714,7 @@ void HistoryWidget::firstLoadMessages() { )).done([=](const MTPmessages_Messages &result) { messagesReceived(history->peer, result, _firstLoadRequest); finish(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { messagesFailed(error, _firstLoadRequest); finish(); }).send(); @@ -2765,7 +2765,7 @@ void HistoryWidget::loadMessages() { )).done([=](const MTPmessages_Messages &result) { messagesReceived(history->peer, result, _preloadRequest); finish(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { messagesFailed(error, _preloadRequest); finish(); }).send(); @@ -2816,7 +2816,7 @@ void HistoryWidget::loadMessagesDown() { )).done([=](const MTPmessages_Messages &result) { messagesReceived(history->peer, result, _preloadDownRequest); finish(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { messagesFailed(error, _preloadDownRequest); finish(); }).send(); @@ -2880,7 +2880,7 @@ void HistoryWidget::delayedShowAt(MsgId showAtMsgId) { )).done([=](const MTPmessages_Messages &result) { messagesReceived(history->peer, result, _delayedShowAtRequest); finish(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { messagesFailed(error, _delayedShowAtRequest); finish(); }).send(); @@ -3105,7 +3105,7 @@ void HistoryWidget::saveEditMsg() { } }; - const auto fail = [=](const RPCError &error, mtpRequestId requestId) { + const auto fail = [=](const MTP::Error &error, mtpRequestId requestId) { if (const auto editDraft = history->localEditDraft()) { if (editDraft->saveRequestId == requestId) { editDraft->saveRequestId = 0; @@ -3785,7 +3785,7 @@ void HistoryWidget::inlineBotResolveDone( } void HistoryWidget::inlineBotResolveFail( - const RPCError &error, + const MTP::Error &error, const QString &username) { _inlineBotResolveRequestId = 0; if (username == _inlineBotUsername) { diff --git a/Telegram/SourceFiles/history/history_widget.h b/Telegram/SourceFiles/history/history_widget.h index 65df86b0e..a2d699110 100644 --- a/Telegram/SourceFiles/history/history_widget.h +++ b/Telegram/SourceFiles/history/history_widget.h @@ -19,12 +19,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/flags.h" #include "base/timer.h" -class RPCError; struct FileLoadResult; struct SendingAlbum; enum class SendMediaType; class MessageLinksParser; +namespace MTP { +class Error; +} // namespace MTP + namespace Data { enum class PreviewState : char; } // namespace Data @@ -526,7 +529,7 @@ private: void requestPreview(); void gotPreview(QString links, const MTPMessageMedia &media, mtpRequestId req); void messagesReceived(PeerData *peer, const MTPmessages_Messages &messages, int requestId); - void messagesFailed(const RPCError &error, int requestId); + void messagesFailed(const MTP::Error &error, int requestId); void addMessagesToFront(PeerData *peer, const QVector &messages); void addMessagesToBack(PeerData *peer, const QVector &messages); @@ -577,7 +580,7 @@ private: void handleSupportSwitch(not_null updated); void inlineBotResolveDone(const MTPcontacts_ResolvedPeer &result); - void inlineBotResolveFail(const RPCError &error, const QString &username); + void inlineBotResolveFail(const MTP::Error &error, const QString &username); bool isRecording() const; diff --git a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp index dabc2afb5..40716555e 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp @@ -1577,7 +1577,7 @@ void ComposeControls::inlineBotResolveDone( } void ComposeControls::inlineBotResolveFail( - const RPCError &error, + const MTP::Error &error, const QString &username) { _inlineBotResolveRequestId = 0; if (username == _inlineBotUsername) { @@ -2360,7 +2360,7 @@ void ComposeControls::updateInlineBotQuery() { MTPcontacts_ResolveUsername(MTP_string(username)) ).done([=](const MTPcontacts_ResolvedPeer &result) { inlineBotResolveDone(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { inlineBotResolveFail(error, username); }).send(); } else { diff --git a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.h b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.h index 1504e5dcb..96a5982e8 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.h +++ b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.h @@ -250,7 +250,7 @@ private: void applyInlineBotQuery(UserData *bot, const QString &query); void inlineBotResolveDone(const MTPcontacts_ResolvedPeer &result); - void inlineBotResolveFail(const RPCError &error, const QString &username); + void inlineBotResolveFail(const MTP::Error &error, const QString &username); [[nodiscard]] Data::DraftKey draftKey( DraftType type = DraftType::Normal) const; diff --git a/Telegram/SourceFiles/history/view/controls/history_view_ttl_button.cpp b/Telegram/SourceFiles/history/view/controls/history_view_ttl_button.cpp index 841fffb48..1adcb2a42 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_ttl_button.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_ttl_button.cpp @@ -76,7 +76,7 @@ void AutoDeleteSettingsBox( if (const auto strong = state->weak.data()) { strong->closeBox(); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { state->savingRequestId = 0; }).send(); }; diff --git a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp index 2c2abf2a3..2d6784e6a 100644 --- a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp +++ b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp @@ -1109,7 +1109,7 @@ void SendReport( MTP_string(comment) )).done([=](const MTPBool &result) { Ui::Toast::Show(tr::lng_report_thanks(tr::now)); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { }).send(); } else { auto apiIds = QVector(); @@ -1124,7 +1124,7 @@ void SendReport( MTP_string(comment) )).done([=](const MTPBool &result) { Ui::Toast::Show(tr::lng_report_thanks(tr::now)); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { }).send(); } } diff --git a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp index a8a96f894..057e69826 100644 --- a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp @@ -967,7 +967,7 @@ void RepliesWidget::edit( } }; - const auto fail = [=](const RPCError &error, mtpRequestId requestId) { + const auto fail = [=](const MTP::Error &error, mtpRequestId requestId) { if (requestId == *saveEditMsgRequestId) { *saveEditMsgRequestId = 0; } diff --git a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp index 017956038..0729a35bb 100644 --- a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp @@ -597,7 +597,7 @@ void ScheduledWidget::edit( } }; - const auto fail = [=](const RPCError &error, mtpRequestId requestId) { + const auto fail = [=](const MTP::Error &error, mtpRequestId requestId) { if (requestId == *saveEditMsgRequestId) { *saveEditMsgRequestId = 0; } diff --git a/Telegram/SourceFiles/info/polls/info_polls_results_inner_widget.cpp b/Telegram/SourceFiles/info/polls/info_polls_results_inner_widget.cpp index 48017e7a1..7fd591eef 100644 --- a/Telegram/SourceFiles/info/polls/info_polls_results_inner_widget.cpp +++ b/Telegram/SourceFiles/info/polls/info_polls_results_inner_widget.cpp @@ -298,7 +298,7 @@ void ListController::loadMoreRows() { delegate()->peerListRefreshRows(); } _loadRequestId = 0; - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _loadRequestId = 0; }).send(); } diff --git a/Telegram/SourceFiles/inline_bots/inline_results_widget.cpp b/Telegram/SourceFiles/inline_bots/inline_results_widget.cpp index b599c3e7c..aa54c9b1e 100644 --- a/Telegram/SourceFiles/inline_bots/inline_results_widget.cpp +++ b/Telegram/SourceFiles/inline_bots/inline_results_widget.cpp @@ -448,7 +448,7 @@ void Widget::onInlineRequest() { MTP_string(nextOffset) )).done([=](const MTPmessages_BotResults &result) { inlineResultsDone(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { // show error? _requesting.fire(false); _inlineRequestId = 0; diff --git a/Telegram/SourceFiles/intro/intro_code.cpp b/Telegram/SourceFiles/intro/intro_code.cpp index 710931dab..5fe6a35de 100644 --- a/Telegram/SourceFiles/intro/intro_code.cpp +++ b/Telegram/SourceFiles/intro/intro_code.cpp @@ -266,8 +266,8 @@ void CodeWidget::codeSubmitDone(const MTPauth_Authorization &result) { }); } -void CodeWidget::codeSubmitFail(const RPCError &error) { - if (MTP::isFloodError(error)) { +void CodeWidget::codeSubmitFail(const MTP::Error &error) { + if (MTP::IsFloodError(error)) { stopCheck(); _sentRequest = 0; showCodeError(tr::lng_flood_error()); @@ -288,7 +288,7 @@ void CodeWidget::codeSubmitFail(const RPCError &error) { _sentRequest = api().request(MTPaccount_GetPassword( )).done([=](const MTPaccount_Password &result) { gotPassword(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { codeSubmitFail(error); }).handleFloodErrors().send(); } else if (Logs::DebugEnabled()) { // internal server error @@ -391,7 +391,7 @@ void CodeWidget::submit() { MTP_string(_sentCode) )).done([=](const MTPauth_Authorization &result) { codeSubmitDone(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { codeSubmitFail(error); }).handleFloodErrors().send(); } @@ -405,7 +405,7 @@ void CodeWidget::noTelegramCode() { MTP_bytes(getData()->phoneHash) )).done([=](const MTPauth_SentCode &result) { noTelegramCodeDone(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { noTelegramCodeFail(error); }).handleFloodErrors().send(); } @@ -433,8 +433,8 @@ void CodeWidget::noTelegramCodeDone(const MTPauth_SentCode &result) { updateDescText(); } -void CodeWidget::noTelegramCodeFail(const RPCError &error) { - if (MTP::isFloodError(error)) { +void CodeWidget::noTelegramCodeFail(const MTP::Error &error) { + if (MTP::IsFloodError(error)) { _noTelegramCodeRequestId = 0; showCodeError(tr::lng_flood_error()); return; diff --git a/Telegram/SourceFiles/intro/intro_code.h b/Telegram/SourceFiles/intro/intro_code.h index e98285a0b..d267c477d 100644 --- a/Telegram/SourceFiles/intro/intro_code.h +++ b/Telegram/SourceFiles/intro/intro_code.h @@ -74,14 +74,14 @@ private: void updateControlsGeometry(); void codeSubmitDone(const MTPauth_Authorization &result); - void codeSubmitFail(const RPCError &error); + void codeSubmitFail(const MTP::Error &error); void showCodeError(rpl::producer text); void callDone(const MTPauth_SentCode &v); void gotPassword(const MTPaccount_Password &result); void noTelegramCodeDone(const MTPauth_SentCode &result); - void noTelegramCodeFail(const RPCError &result); + void noTelegramCodeFail(const MTP::Error &result); void stopCheck(); diff --git a/Telegram/SourceFiles/intro/intro_password_check.cpp b/Telegram/SourceFiles/intro/intro_password_check.cpp index bd67e4c47..e4bad8942 100644 --- a/Telegram/SourceFiles/intro/intro_password_check.cpp +++ b/Telegram/SourceFiles/intro/intro_password_check.cpp @@ -133,8 +133,8 @@ void PasswordCheckWidget::pwdSubmitDone(bool recover, const MTPauth_Authorizatio finish(d.vuser()); } -void PasswordCheckWidget::pwdSubmitFail(const RPCError &error) { - if (MTP::isFloodError(error)) { +void PasswordCheckWidget::pwdSubmitFail(const MTP::Error &error) { + if (MTP::IsFloodError(error)) { _sentRequest = 0; showError(tr::lng_flood_error()); _pwdField->showError(); @@ -213,7 +213,7 @@ void PasswordCheckWidget::passwordChecked() { MTPauth_CheckPassword(check.result) ).done([=](const MTPauth_Authorization &result) { pwdSubmitDone(false, result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { pwdSubmitFail(error); }).handleFloodErrors().send(); } @@ -222,8 +222,8 @@ void PasswordCheckWidget::serverError() { showError(rpl::single(Lang::Hard::ServerError())); } -void PasswordCheckWidget::codeSubmitFail(const RPCError &error) { - if (MTP::isFloodError(error)) { +void PasswordCheckWidget::codeSubmitFail(const MTP::Error &error) { + if (MTP::IsFloodError(error)) { showError(tr::lng_flood_error()); _codeField->showError(); return; @@ -258,7 +258,7 @@ void PasswordCheckWidget::recoverStarted(const MTPauth_PasswordRecovery &result) updateDescriptionText(); } -void PasswordCheckWidget::recoverStartFail(const RPCError &error) { +void PasswordCheckWidget::recoverStartFail(const MTP::Error &error) { _pwdField->show(); _pwdHint->show(); _codeField->hide(); @@ -287,7 +287,7 @@ void PasswordCheckWidget::toRecover() { MTPauth_RequestPasswordRecovery() ).done([=](const MTPauth_PasswordRecovery &result) { recoverStarted(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { recoverStartFail(error); }).send(); } @@ -343,7 +343,7 @@ void PasswordCheckWidget::submit() { MTPauth_RecoverPassword(MTP_string(code)) ).done([=](const MTPauth_Authorization &result) { pwdSubmitDone(true, result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { codeSubmitFail(error); }).handleFloodErrors().send(); }); diff --git a/Telegram/SourceFiles/intro/intro_password_check.h b/Telegram/SourceFiles/intro/intro_password_check.h index e237ab601..aae6e9855 100644 --- a/Telegram/SourceFiles/intro/intro_password_check.h +++ b/Telegram/SourceFiles/intro/intro_password_check.h @@ -49,9 +49,9 @@ private: void updateControlsGeometry(); void pwdSubmitDone(bool recover, const MTPauth_Authorization &result); - void pwdSubmitFail(const RPCError &error); - void codeSubmitFail(const RPCError &error); - void recoverStartFail(const RPCError &error); + void pwdSubmitFail(const MTP::Error &error); + void codeSubmitFail(const MTP::Error &error); + void recoverStartFail(const MTP::Error &error); void recoverStarted(const MTPauth_PasswordRecovery &result); diff --git a/Telegram/SourceFiles/intro/intro_phone.cpp b/Telegram/SourceFiles/intro/intro_phone.cpp index 13aae8323..48820b699 100644 --- a/Telegram/SourceFiles/intro/intro_phone.cpp +++ b/Telegram/SourceFiles/intro/intro_phone.cpp @@ -176,7 +176,7 @@ void PhoneWidget::submit() { MTP_codeSettings(MTP_flags(0)) )).done([=](const MTPauth_SentCode &result) { phoneSubmitDone(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { phoneSubmitFail(error); }).handleFloodErrors().send(); } @@ -222,8 +222,8 @@ void PhoneWidget::phoneSubmitDone(const MTPauth_SentCode &result) { goNext(); } -void PhoneWidget::phoneSubmitFail(const RPCError &error) { - if (MTP::isFloodError(error)) { +void PhoneWidget::phoneSubmitFail(const MTP::Error &error) { + if (MTP::IsFloodError(error)) { stopCheck(); _sentRequest = 0; showPhoneError(tr::lng_flood_error()); diff --git a/Telegram/SourceFiles/intro/intro_phone.h b/Telegram/SourceFiles/intro/intro_phone.h index 80b86f270..3770df59c 100644 --- a/Telegram/SourceFiles/intro/intro_phone.h +++ b/Telegram/SourceFiles/intro/intro_phone.h @@ -50,7 +50,7 @@ private: void countryChanged(); void phoneSubmitDone(const MTPauth_SentCode &result); - void phoneSubmitFail(const RPCError &error); + void phoneSubmitFail(const MTP::Error &error); QString fullNumber() const; void stopCheck(); diff --git a/Telegram/SourceFiles/intro/intro_qr.cpp b/Telegram/SourceFiles/intro/intro_qr.cpp index c5bed139a..67a548126 100644 --- a/Telegram/SourceFiles/intro/intro_qr.cpp +++ b/Telegram/SourceFiles/intro/intro_qr.cpp @@ -298,7 +298,7 @@ void QrWidget::refreshCode() { MTP_vector(0) )).done([=](const MTPauth_LoginToken &result) { handleTokenResult(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { showTokenError(error); }).send(); } @@ -321,7 +321,7 @@ void QrWidget::handleTokenResult(const MTPauth_LoginToken &result) { }); } -void QrWidget::showTokenError(const RPCError &error) { +void QrWidget::showTokenError(const MTP::Error &error) { _requestId = 0; if (error.type() == qstr("SESSION_PASSWORD_NEEDED")) { sendCheckPasswordRequest(); @@ -345,7 +345,7 @@ void QrWidget::importTo(MTP::DcId dcId, const QByteArray &token) { MTP_bytes(token) )).done([=](const MTPauth_LoginToken &result) { handleTokenResult(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { showTokenError(error); }).toDC(dcId).send(); } @@ -391,7 +391,7 @@ void QrWidget::sendCheckPasswordRequest() { getData()->pwdNotEmptyPassport = data.is_has_secure_values(); goReplace(Animate::Forward); }); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { showTokenError(error); }).send(); } diff --git a/Telegram/SourceFiles/intro/intro_qr.h b/Telegram/SourceFiles/intro/intro_qr.h index 563a4a4a8..99d19a316 100644 --- a/Telegram/SourceFiles/intro/intro_qr.h +++ b/Telegram/SourceFiles/intro/intro_qr.h @@ -47,7 +47,7 @@ private: void checkForTokenUpdate(const MTPUpdates &updates); void checkForTokenUpdate(const MTPUpdate &update); void handleTokenResult(const MTPauth_LoginToken &result); - void showTokenError(const RPCError &error); + void showTokenError(const MTP::Error &error); void importTo(MTP::DcId dcId, const QByteArray &token); void showToken(const QByteArray &token); void done(const MTPauth_Authorization &authorization); diff --git a/Telegram/SourceFiles/intro/intro_signup.cpp b/Telegram/SourceFiles/intro/intro_signup.cpp index a6e406839..e8d8b3dbf 100644 --- a/Telegram/SourceFiles/intro/intro_signup.cpp +++ b/Telegram/SourceFiles/intro/intro_signup.cpp @@ -117,8 +117,8 @@ void SignupWidget::nameSubmitDone(const MTPauth_Authorization &result) { finish(d.vuser(), _photo->takeResultImage()); } -void SignupWidget::nameSubmitFail(const RPCError &error) { - if (MTP::isFloodError(error)) { +void SignupWidget::nameSubmitFail(const MTP::Error &error) { + if (MTP::IsFloodError(error)) { showError(tr::lng_flood_error()); if (_invertOrder) { _first->setFocus(); @@ -192,7 +192,7 @@ void SignupWidget::submit() { MTP_string(_lastName) )).done([=](const MTPauth_Authorization &result) { nameSubmitDone(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { nameSubmitFail(error); }).handleFloodErrors().send(); }; diff --git a/Telegram/SourceFiles/intro/intro_signup.h b/Telegram/SourceFiles/intro/intro_signup.h index fbd5acdb9..f6c5fbe8e 100644 --- a/Telegram/SourceFiles/intro/intro_signup.h +++ b/Telegram/SourceFiles/intro/intro_signup.h @@ -40,7 +40,7 @@ private: void updateControlsGeometry(); void nameSubmitDone(const MTPauth_Authorization &result); - void nameSubmitFail(const RPCError &error); + void nameSubmitFail(const MTP::Error &error); object_ptr _photo; object_ptr _first; diff --git a/Telegram/SourceFiles/intro/intro_step.cpp b/Telegram/SourceFiles/intro/intro_step.cpp index ea4f05bd5..fcfcf16ae 100644 --- a/Telegram/SourceFiles/intro/intro_step.cpp +++ b/Telegram/SourceFiles/intro/intro_step.cpp @@ -166,7 +166,7 @@ void Step::finish(const MTPUser &user, QImage &&photo) { api().request(MTPmessages_GetDialogFilters( )).done([=](const MTPVector &result) { createSession(user, photo, result.v); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { createSession(user, photo, QVector()); }).send(); } diff --git a/Telegram/SourceFiles/intro/intro_widget.cpp b/Telegram/SourceFiles/intro/intro_widget.cpp index d9ef403d5..259125d4a 100644 --- a/Telegram/SourceFiles/intro/intro_widget.cpp +++ b/Telegram/SourceFiles/intro/intro_widget.cpp @@ -491,7 +491,7 @@ void Widget::resetAccount() { StackAction::Replace, Animate::Forward); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _resetRequest = 0; const auto &type = error.type(); diff --git a/Telegram/SourceFiles/lang/lang_cloud_manager.cpp b/Telegram/SourceFiles/lang/lang_cloud_manager.cpp index 89a06d37f..f9d5aa3f6 100644 --- a/Telegram/SourceFiles/lang/lang_cloud_manager.cpp +++ b/Telegram/SourceFiles/lang/lang_cloud_manager.cpp @@ -226,7 +226,7 @@ void CloudManager::requestLangPackDifference(Pack pack) { )).done([=](const MTPLangPackDifference &result) { packRequestId(pack) = 0; applyLangPackDifference(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { packRequestId(pack) = 0; }).send(); } else { @@ -236,7 +236,7 @@ void CloudManager::requestLangPackDifference(Pack pack) { )).done([=](const MTPLangPackDifference &result) { packRequestId(pack) = 0; applyLangPackDifference(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { packRequestId(pack) = 0; }).send(); } @@ -314,7 +314,7 @@ void CloudManager::requestLanguageList() { _languagesChanged.notify(); } _languagesRequestId = 0; - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _languagesRequestId = 0; }).send(); } @@ -453,7 +453,7 @@ void CloudManager::sendSwitchingToLanguageRequest() { Ui::show(Box(data)); } }); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _switchingToLanguageRequest = 0; if (error.type() == "LANG_CODE_NOT_SUPPORTED") { Ui::show(Box(tr::lng_language_not_found(tr::now))); @@ -500,7 +500,7 @@ void CloudManager::switchToLanguage(const Language &data) { tr::lng_cancel(tr::now), [=] { performSwitchAndRestart(data); }), Ui::LayerOption::KeepOther); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _getKeysForSwitchRequestId = 0; }).send(); } diff --git a/Telegram/SourceFiles/main/main_account.cpp b/Telegram/SourceFiles/main/main_account.cpp index e9b0b8141..c3b46b187 100644 --- a/Telegram/SourceFiles/main/main_account.cpp +++ b/Telegram/SourceFiles/main/main_account.cpp @@ -423,7 +423,7 @@ void Account::startMtp(std::unique_ptr config) { _mtp->setUpdatesHandler([=](const MTP::Response &message) { checkForUpdates(message) || checkForNewSession(message); }); - _mtp->setGlobalFailHandler([=](const RPCError &, const MTP::Response &) { + _mtp->setGlobalFailHandler([=](const MTP::Error &, const MTP::Response &) { if (const auto session = maybeSession()) { crl::on_main(session, [=] { logOut(); }); } diff --git a/Telegram/SourceFiles/main/main_app_config.cpp b/Telegram/SourceFiles/main/main_app_config.cpp index 00f5082b9..30727becc 100644 --- a/Telegram/SourceFiles/main/main_app_config.cpp +++ b/Telegram/SourceFiles/main/main_app_config.cpp @@ -51,7 +51,7 @@ void AppConfig::refresh() { DEBUG_LOG(("getAppConfig result handled.")); } _refreshed.fire({}); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _requestId = 0; refreshDelayed(); }).send(); diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 5023c853b..f2cba8591 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -1335,7 +1335,7 @@ void MainWidget::viewsIncrement() { MTP_bool(true) )).done([=](const MTPmessages_MessageViews &result, mtpRequestId requestId) { viewsIncrementDone(ids, result, requestId); - }).fail([=](const RPCError &error, mtpRequestId requestId) { + }).fail([=](const MTP::Error &error, mtpRequestId requestId) { viewsIncrementFail(error, requestId); }).afterDelay(5).send(); @@ -1382,7 +1382,7 @@ void MainWidget::viewsIncrementDone( } } -void MainWidget::viewsIncrementFail(const RPCError &error, mtpRequestId requestId) { +void MainWidget::viewsIncrementFail(const MTP::Error &error, mtpRequestId requestId) { for (auto i = _viewsIncrementRequests.begin(); i != _viewsIncrementRequests.cend(); ++i) { if (i->second == requestId) { _viewsIncrementRequests.erase(i); diff --git a/Telegram/SourceFiles/mainwidget.h b/Telegram/SourceFiles/mainwidget.h index 370b0fe8a..62246291c 100644 --- a/Telegram/SourceFiles/mainwidget.h +++ b/Telegram/SourceFiles/mainwidget.h @@ -15,7 +15,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "mtproto/sender.h" #include "data/data_pts_waiter.h" -class RPCError; struct HistoryMessageMarkupButton; class MainWindow; class ConfirmBox; @@ -25,6 +24,10 @@ struct FileLoadResult; class History; class Image; +namespace MTP { +class Error; +} // namespace MTP + namespace Api { struct SendAction; } // namespace Api @@ -321,7 +324,7 @@ private: QVector ids, const MTPmessages_MessageViews &result, mtpRequestId requestId); - void viewsIncrementFail(const RPCError &error, mtpRequestId requestId); + void viewsIncrementFail(const MTP::Error &error, mtpRequestId requestId); void refreshResizeAreas(); template diff --git a/Telegram/SourceFiles/mtproto/config_loader.h b/Telegram/SourceFiles/mtproto/config_loader.h index 969295138..9a0feb915 100644 --- a/Telegram/SourceFiles/mtproto/config_loader.h +++ b/Telegram/SourceFiles/mtproto/config_loader.h @@ -10,7 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/timer.h" #include "base/weak_ptr.h" #include "base/bytes.h" -#include "mtproto/mtproto_rpc_sender.h" +#include "mtproto/mtproto_response.h" namespace MTP { diff --git a/Telegram/SourceFiles/mtproto/dedicated_file_loader.cpp b/Telegram/SourceFiles/mtproto/dedicated_file_loader.cpp index 7db41b7c3..562c0f54e 100644 --- a/Telegram/SourceFiles/mtproto/dedicated_file_loader.cpp +++ b/Telegram/SourceFiles/mtproto/dedicated_file_loader.cpp @@ -119,7 +119,7 @@ void WeakInstance::die() { if (_instance) { _instance->cancel(requestId); } - fail(RPCError::Local( + fail(Error::Local( "UNAVAILABLE", "MTP instance is not available.")); } @@ -134,9 +134,9 @@ bool WeakInstance::removeRequest(mtpRequestId requestId) { } void WeakInstance::reportUnavailable( - Fn callback) { + Fn callback) { InvokeQueued(this, [=] { - callback(RPCError::Local( + callback(Error::Local( "UNAVAILABLE", "MTP instance is not available.")); }); @@ -360,8 +360,8 @@ void DedicatedLoader::gotPart(int offset, const MTPupload_File &result) { sendRequest(); } -Fn DedicatedLoader::failHandler() { - return [=](const RPCError &error) { +Fn DedicatedLoader::failHandler() { + return [=](const Error &error) { LOG(("Update Error: MTP load failed with '%1'" ).arg(QString::number(error.code()) + ':' + error.type())); threadSafeFailed(); @@ -411,7 +411,7 @@ void ResolveChannel( failed(); } }; - const auto failHandler = [=](const RPCError &error) { + const auto failHandler = [=](const Error &error) { LOG(("Dedicated MTP Error: Resolve failed with '%1'" ).arg(QString::number(error.code()) + ':' + error.type())); fail(); @@ -447,7 +447,7 @@ void StartDedicatedLoader( *file) : nullptr); }; - const auto failHandler = [=](const RPCError &error) { + const auto failHandler = [=](const Error &error) { LOG(("Update Error: MTP check failed with '%1'" ).arg(QString::number(error.code()) + ':' + error.type())); ready(nullptr); diff --git a/Telegram/SourceFiles/mtproto/dedicated_file_loader.h b/Telegram/SourceFiles/mtproto/dedicated_file_loader.h index 2b7e50922..4c13841db 100644 --- a/Telegram/SourceFiles/mtproto/dedicated_file_loader.h +++ b/Telegram/SourceFiles/mtproto/dedicated_file_loader.h @@ -23,7 +23,7 @@ public: void send( const Request &request, Fn done, - Fn fail, + Fn fail, ShiftedDcId dcId = 0); [[nodiscard]] base::weak_ptr session() const; @@ -35,11 +35,11 @@ public: private: void die(); bool removeRequest(mtpRequestId requestId); - void reportUnavailable(Fn callback); + void reportUnavailable(Fn callback); base::weak_ptr _session; Instance *_instance = nullptr; - std::map> _requests; + std::map> _requests; rpl::lifetime _lifetime; }; @@ -133,7 +133,7 @@ private: void startLoading() override; void sendRequest(); void gotPart(int offset, const MTPupload_File &result); - Fn failHandler(); + Fn failHandler(); static constexpr auto kRequestsCount = 2; static constexpr auto kNextRequestDelay = crl::time(20); @@ -166,7 +166,7 @@ template void WeakInstance::send( const Request &request, Fn done, - Fn fail, + Fn fail, MTP::ShiftedDcId dcId) { using Result = typename Request::ResponseType; if (!valid()) { @@ -186,9 +186,9 @@ void WeakInstance::send( return true; }); const auto onFail = crl::guard((QObject*)this, [=]( - const RPCError &error, + const Error &error, const Response &response) { - if (MTP::isDefaultHandledError(error)) { + if (MTP::IsDefaultHandledError(error)) { return false; } if (removeRequest(response.requestId)) { diff --git a/Telegram/SourceFiles/mtproto/mtp_instance.cpp b/Telegram/SourceFiles/mtproto/mtp_instance.cpp index 444e16622..8a781c2a9 100644 --- a/Telegram/SourceFiles/mtproto/mtp_instance.cpp +++ b/Telegram/SourceFiles/mtproto/mtp_instance.cpp @@ -142,17 +142,17 @@ public: bool rpcErrorOccured( const Response &response, const FailHandler &onFail, - const RPCError &error); + const Error &error); inline bool rpcErrorOccured( const Response &response, const ResponseHandler &handler, - const RPCError &error) { + const Error &error) { return rpcErrorOccured(response, handler.fail, error); } void setUpdatesHandler(Fn handler); void setGlobalFailHandler( - Fn handler); + Fn handler); void setStateChangedHandler(Fn handler); void setSessionResetHandler(Fn handler); void clearGlobalHandlers(); @@ -180,12 +180,12 @@ private: void importDone( const MTPauth_Authorization &result, const Response &response); - bool importFail(const RPCError &error, const Response &response); + bool importFail(const Error &error, const Response &response); void exportDone( const MTPauth_ExportedAuthorization &result, const Response &response); - bool exportFail(const RPCError &error, const Response &response); - bool onErrorDefault(const RPCError &error, const Response &response); + bool exportFail(const Error &error, const Response &response); + bool onErrorDefault(const Error &error, const Response &response); void unpaused(); @@ -204,7 +204,7 @@ private: void requestConfigIfExpired(); void configLoadDone(const MTPConfig &result); - bool configLoadFail(const RPCError &error); + bool configLoadFail(const Error &error); std::optional queryRequestByDc( mtpRequestId requestId) const; @@ -271,7 +271,7 @@ private: std::map> _authWaiters; Fn _updatesHandler; - Fn _globalFailHandler; + Fn _globalFailHandler; Fn _stateChangedHandler; Fn _sessionResetHandler; @@ -463,7 +463,7 @@ void Instance::Private::requestConfig() { _instance, _userPhone, [=](const MTPConfig &result) { configLoadDone(result); }, - [=](const RPCError &error, const Response &) { + [=](const Error &error, const Response &) { return configLoadFail(error); }); _configLoader->load(); @@ -664,7 +664,7 @@ void Instance::Private::logout(Fn done) { _instance->send(MTPauth_LogOut(), [=](Response) { done(); return true; - }, [=](const RPCError&, Response) { + }, [=](const Error&, Response) { done(); return true; }); @@ -686,7 +686,7 @@ void Instance::Private::logoutGuestDcs() { const Response &response) { logoutGuestDone(response.requestId); return true; - }, [=](const RPCError &, const Response &response) { + }, [=](const Error &, const Response &response) { logoutGuestDone(response.requestId); return true; }, shiftedDcId); @@ -879,8 +879,8 @@ void Instance::Private::configLoadDone(const MTPConfig &result) { requestConfigIfExpired(); } -bool Instance::Private::configLoadFail(const RPCError &error) { - if (isDefaultHandledError(error)) return false; +bool Instance::Private::configLoadFail(const Error &error) { + if (IsDefaultHandledError(error)) return false; // loadingConfig = false; LOG(("MTP Error: failed to get config!")); @@ -1040,7 +1040,7 @@ void Instance::Private::processCallback(const Response &response) { } } if (handler.done || handler.fail) { - const auto handleError = [&](const RPCError &error) { + const auto handleError = [&](const Error &error) { DEBUG_LOG(("RPC Info: " "error received, code %1, type %2, description: %3" ).arg(error.code() @@ -1056,20 +1056,20 @@ void Instance::Private::processCallback(const Response &response) { auto from = response.reply.constData(); if (response.reply.isEmpty()) { - handleError(RPCError::Local( + handleError(Error::Local( "RESPONSE_PARSE_FAILED", "Empty response.")); } else if (*from == mtpc_rpc_error) { auto error = MTPRpcError(); handleError( - RPCError(error.read(from, from + response.reply.size()) + Error(error.read(from, from + response.reply.size()) ? error - : RPCError::MTPLocal( + : Error::MTPLocal( "RESPONSE_PARSE_FAILED", "Error parse failed."))); } else { if (handler.done && !handler.done(response)) { - handleError(RPCError::Local( + handleError(Error::Local( "RESPONSE_PARSE_FAILED", "Response parse failed.")); } @@ -1102,8 +1102,8 @@ void Instance::Private::onSessionReset(ShiftedDcId dcWithShift) { bool Instance::Private::rpcErrorOccured( const Response &response, const FailHandler &onFail, - const RPCError &error) { // return true if need to clean request data - if (isDefaultHandledError(error)) { + const Error &error) { // return true if need to clean request data + if (IsDefaultHandledError(error)) { if (onFail && onFail(error, response)) { return true; } @@ -1136,7 +1136,7 @@ void Instance::Private::importDone( // // Don't log out on export/import problems, perhaps this is a server side error. // - //const auto error = RPCError::Local( + //const auto error = Error::Local( // "AUTH_IMPORT_FAIL", // QString("did not find import request in requestsByDC, " // "request %1").arg(requestId)); @@ -1174,9 +1174,9 @@ void Instance::Private::importDone( } bool Instance::Private::importFail( - const RPCError &error, + const Error &error, const Response &response) { - if (isDefaultHandledError(error)) { + if (IsDefaultHandledError(error)) { return false; } @@ -1200,7 +1200,7 @@ void Instance::Private::exportDone( // // Don't log out on export/import problems, perhaps this is a server side error. // - //const auto error = RPCError::Local( + //const auto error = Error::Local( // "AUTH_IMPORT_FAIL", // QString("did not find target dcWithShift, request %1" // ).arg(requestId)); @@ -1222,16 +1222,16 @@ void Instance::Private::exportDone( } importDone(result, response); return true; - }, [this](const RPCError &error, const Response &response) { + }, [this](const Error &error, const Response &response) { return importFail(error, response); }, it->second); _authExportRequests.erase(response.requestId); } bool Instance::Private::exportFail( - const RPCError &error, + const Error &error, const Response &response) { - if (isDefaultHandledError(error)) { + if (IsDefaultHandledError(error)) { return false; } @@ -1249,12 +1249,12 @@ bool Instance::Private::exportFail( } bool Instance::Private::onErrorDefault( - const RPCError &error, + const Error &error, const Response &response) { const auto requestId = response.requestId; const auto &type = error.type(); const auto code = error.code(); - if (!isFloodError(error) && type != qstr("AUTH_KEY_UNREGISTERED")) { + if (!IsFloodError(error) && type != qstr("AUTH_KEY_UNREGISTERED")) { int breakpoint = 0; } auto badGuestDc = (code == 400) && (type == qsl("FILE_ID_INVALID")); @@ -1291,7 +1291,7 @@ bool Instance::Private::onErrorDefault( // } // exportDone(result, response); // return true; - // }, [this](const RPCError &error, const Response &response) { + // }, [this](const Error &error, const Response &response) { // return exportFail(error, response); // }); // _authExportRequests.emplace(exportRequestId, newdcWithShift); @@ -1377,7 +1377,7 @@ bool Instance::Private::onErrorDefault( } exportDone(result, response); return true; - }, [this](const RPCError &error, const Response &response) { + }, [this](const Error &error, const Response &response) { return exportFail(error, response); }); _authExportRequests.emplace(exportRequestId, abs(dcWithShift)); @@ -1588,8 +1588,8 @@ void Instance::Private::scheduleKeyDestroy(ShiftedDcId shiftedDcId) { _instance->send(MTPauth_LogOut(), [=](const Response &) { performKeyDestroy(shiftedDcId); return true; - }, [=](const RPCError &error, const Response &) { - if (isDefaultHandledError(error)) { + }, [=](const Error &error, const Response &) { + if (IsDefaultHandledError(error)) { return false; } performKeyDestroy(shiftedDcId); @@ -1628,7 +1628,7 @@ void Instance::Private::performKeyDestroy(ShiftedDcId shiftedDcId) { }); _instance->keyWasPossiblyDestroyed(shiftedDcId); return true; - }, [=](const RPCError &error, const Response &response) { + }, [=](const Error &error, const Response &response) { LOG(("MTP Error: key %1 destruction resulted in error: %2" ).arg(shiftedDcId).arg(error.type())); _instance->keyWasPossiblyDestroyed(shiftedDcId); @@ -1668,7 +1668,7 @@ void Instance::Private::setUpdatesHandler( } void Instance::Private::setGlobalFailHandler( - Fn handler) { + Fn handler) { _globalFailHandler = std::move(handler); } @@ -1895,7 +1895,7 @@ void Instance::setUpdatesHandler(Fn handler) { } void Instance::setGlobalFailHandler( - Fn handler) { + Fn handler) { _private->setGlobalFailHandler(std::move(handler)); } @@ -1936,7 +1936,7 @@ void Instance::processUpdate(const Response &message) { bool Instance::rpcErrorOccured( const Response &response, const FailHandler &onFail, - const RPCError &error) { + const Error &error) { return _private->rpcErrorOccured(response, onFail, error); } diff --git a/Telegram/SourceFiles/mtproto/mtp_instance.h b/Telegram/SourceFiles/mtproto/mtp_instance.h index 8598d19ba..135c64838 100644 --- a/Telegram/SourceFiles/mtproto/mtp_instance.h +++ b/Telegram/SourceFiles/mtproto/mtp_instance.h @@ -8,7 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #pragma once #include "mtproto/details/mtproto_serialized_request.h" -#include "mtproto/mtproto_rpc_sender.h" +#include "mtproto/mtproto_response.h" namespace MTP { namespace details { @@ -104,7 +104,7 @@ public: void setUpdatesHandler(Fn handler); void setGlobalFailHandler( - Fn handler); + Fn handler); void setStateChangedHandler( Fn handler); void setSessionResetHandler(Fn handler); @@ -121,7 +121,7 @@ public: bool rpcErrorOccured( const Response &response, const FailHandler &onFail, - const RPCError &err); + const Error &err); // Thread-safe. bool isKeysDestroyer() const; diff --git a/Telegram/SourceFiles/mtproto/mtproto_concurrent_sender.cpp b/Telegram/SourceFiles/mtproto/mtproto_concurrent_sender.cpp index a03658066..93a00302d 100644 --- a/Telegram/SourceFiles/mtproto/mtproto_concurrent_sender.cpp +++ b/Telegram/SourceFiles/mtproto/mtproto_concurrent_sender.cpp @@ -8,23 +8,23 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "mtproto/mtproto_concurrent_sender.h" #include "mtproto/mtp_instance.h" -#include "mtproto/mtproto_rpc_sender.h" +#include "mtproto/mtproto_response.h" #include "mtproto/facade.h" namespace MTP { class ConcurrentSender::HandlerMaker final { public: - static ::MTP::DoneHandler MakeDone( + static DoneHandler MakeDone( not_null sender, Fn)> runner); - static ::MTP::FailHandler MakeFail( + static FailHandler MakeFail( not_null sender, Fn)> runner, FailSkipPolicy skipPolicy); }; -::MTP::DoneHandler ConcurrentSender::HandlerMaker::MakeDone( +DoneHandler ConcurrentSender::HandlerMaker::MakeDone( not_null sender, Fn)> runner) { return [ @@ -42,7 +42,7 @@ public: }; } -::MTP::FailHandler ConcurrentSender::HandlerMaker::MakeFail( +FailHandler ConcurrentSender::HandlerMaker::MakeFail( not_null sender, Fn)> runner, FailSkipPolicy skipPolicy) { @@ -50,14 +50,13 @@ public: weak = base::make_weak(sender.get()), runner = std::move(runner), skipPolicy - ](const RPCError &error, const Response &response) mutable { + ](const Error &error, const Response &response) mutable { if (skipPolicy == FailSkipPolicy::Simple) { - if (MTP::isDefaultHandledError(error)) { + if (IsDefaultHandledError(error)) { return false; } } else if (skipPolicy == FailSkipPolicy::HandleFlood) { - if (MTP::isDefaultHandledError(error) - && !MTP::isFloodError(error)) { + if (IsDefaultHandledError(error) && !IsFloodError(error)) { return false; } } @@ -160,7 +159,7 @@ void ConcurrentSender::senderRequestDone( if (!handlers->done(requestId, result)) { handlers->fail( requestId, - RPCError::Local( + Error::Local( "RESPONSE_PARSE_FAILED", "ConcurrentSender::senderRequestDone")); } @@ -169,7 +168,7 @@ void ConcurrentSender::senderRequestDone( void ConcurrentSender::senderRequestFail( mtpRequestId requestId, - const RPCError &error) { + const Error &error) { if (auto handlers = _requests.take(requestId)) { handlers->fail(requestId, error); } diff --git a/Telegram/SourceFiles/mtproto/mtproto_concurrent_sender.h b/Telegram/SourceFiles/mtproto/mtproto_concurrent_sender.h index 0c0971805..d82f588eb 100644 --- a/Telegram/SourceFiles/mtproto/mtproto_concurrent_sender.h +++ b/Telegram/SourceFiles/mtproto/mtproto_concurrent_sender.h @@ -20,10 +20,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #define MTP_SENDER_USE_GENERIC_HANDLERS #endif // !_DEBUG -class RPCError; namespace MTP { +class Error; class Instance; class ConcurrentSender : public base::has_weak_ptr { @@ -35,15 +35,9 @@ class ConcurrentSender : public base::has_weak_ptr { auto with_instance(Method &&method) -> std::enable_if_t>>; - using DoneHandler = FnMut; - using FailHandler = FnMut; struct Handlers { - DoneHandler done; - FailHandler fail; + FnMut done; + FnMut fail; }; enum class FailSkipPolicy { @@ -120,9 +114,9 @@ public: FnMut &&handler); [[nodiscard]] SpecificRequestBuilder &fail(Fn &&handler); [[nodiscard]] SpecificRequestBuilder &fail( - Fn &&handler); + Fn &&handler); [[nodiscard]] SpecificRequestBuilder &fail( - Fn &&handler); + Fn &&handler); #else // !MTP_SENDER_USE_GENERIC_HANDLERS template [[nodiscard]] SpecificRequestBuilder &done(Handler &&handler); @@ -185,7 +179,7 @@ private: bytes::const_span result); void senderRequestFail( mtpRequestId requestId, - const RPCError &error); + const Error &error); void senderRequestCancel(mtpRequestId requestId); void senderRequestCancelAll(); void senderRequestDetach(mtpRequestId requestId); @@ -280,11 +274,11 @@ auto ConcurrentSender::SpecificRequestBuilder::done( template auto ConcurrentSender::SpecificRequestBuilder::fail( - Fn &&handler + Fn &&handler ) -> SpecificRequestBuilder & { setFailHandler([handler = std::move(handler)]( mtpRequestId requestId, - const RPCError &error) { + const Error &error) { handler(error); }); return *this; @@ -292,7 +286,7 @@ auto ConcurrentSender::SpecificRequestBuilder::fail( template auto ConcurrentSender::SpecificRequestBuilder::fail( - Fn &&handler + Fn &&handler ) -> SpecificRequestBuilder & { setFailHandler(std::move(handler)); return *this; @@ -304,7 +298,7 @@ auto ConcurrentSender::SpecificRequestBuilder::fail( ) -> SpecificRequestBuilder & { setFailHandler([handler = std::move(handler)]( mtpRequestId requestId, - const RPCError &error) { + const Error &error) { handler(); }); return *this; @@ -353,10 +347,10 @@ auto ConcurrentSender::SpecificRequestBuilder::fail( constexpr auto takesFull = rpl::details::is_callable_plain_v< Handler, mtpRequestId, - RPCError>; + Error>; constexpr auto takesError = rpl::details::is_callable_plain_v< Handler, - RPCError>; + Error>; constexpr auto takesNone = rpl::details::is_callable_plain_v; if constexpr (takesFull) { @@ -364,13 +358,13 @@ auto ConcurrentSender::SpecificRequestBuilder::fail( } else if constexpr (takesError) { setFailHandler([handler = std::forward(handler)]( mtpRequestId requestId, - const RPCError &error) { + const Error &error) { handler(error); }); } else if constexpr (takesNone) { setFailHandler([handler = std::forward(handler)]( mtpRequestId requestId, - const RPCError &error) { + const Error &error) { handler(); }); } else { diff --git a/Telegram/SourceFiles/mtproto/mtproto_rpc_sender.cpp b/Telegram/SourceFiles/mtproto/mtproto_response.cpp similarity index 76% rename from Telegram/SourceFiles/mtproto/mtproto_rpc_sender.cpp rename to Telegram/SourceFiles/mtproto/mtproto_response.cpp index 203a759af..ea3f3e2d0 100644 --- a/Telegram/SourceFiles/mtproto/mtproto_rpc_sender.cpp +++ b/Telegram/SourceFiles/mtproto/mtproto_response.cpp @@ -5,10 +5,11 @@ the official desktop application for the Telegram messaging service. For license and copyright information please follow this link: https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ -#include "mtproto/mtproto_rpc_sender.h" +#include "mtproto/mtproto_response.h" #include +namespace MTP { namespace { [[nodiscard]] MTPrpcError ParseError(const mtpBuffer &reply) { @@ -16,14 +17,12 @@ namespace { auto from = reply.constData(); return result.read(from, from + reply.size()) ? result - : RPCError::MTPLocal( - "RESPONSE_PARSE_FAILED", - "Error parse failed."); + : Error::MTPLocal("RESPONSE_PARSE_FAILED", "Error parse failed."); } } // namespace -RPCError::RPCError(const MTPrpcError &error) +Error::Error(const MTPrpcError &error) : _code(error.c_rpc_error().verror_code().v) { QString text = qs(error.c_rpc_error().verror_message()); if (_code < 0 || _code >= 500) { @@ -45,22 +44,22 @@ RPCError::RPCError(const MTPrpcError &error) } } -RPCError::RPCError(const mtpBuffer &reply) : RPCError(ParseError(reply)) { +Error::Error(const mtpBuffer &reply) : Error(ParseError(reply)) { } -int32 RPCError::code() const { +int32 Error::code() const { return _code; } -const QString &RPCError::type() const { +const QString &Error::type() const { return _type; } -const QString &RPCError::description() const { +const QString &Error::description() const { return _description; } -MTPrpcError RPCError::MTPLocal( +MTPrpcError Error::MTPLocal( const QString &type, const QString &description) { return MTP_rpc_error( @@ -73,8 +72,10 @@ MTPrpcError RPCError::MTPLocal( : QString())).toUtf8())); } -RPCError RPCError::Local( +Error Error::Local( const QString &type, const QString &description) { - return RPCError(MTPLocal(type, description)); + return Error(MTPLocal(type, description)); } + +} // namespace MTP diff --git a/Telegram/SourceFiles/mtproto/mtproto_rpc_sender.h b/Telegram/SourceFiles/mtproto/mtproto_response.h similarity index 67% rename from Telegram/SourceFiles/mtproto/mtproto_rpc_sender.h rename to Telegram/SourceFiles/mtproto/mtproto_response.h index d2723fd77..784e9b5e2 100644 --- a/Telegram/SourceFiles/mtproto/mtproto_rpc_sender.h +++ b/Telegram/SourceFiles/mtproto/mtproto_response.h @@ -9,10 +9,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/flat_set.h" -class RPCError { +namespace MTP { + +class Error { public: - explicit RPCError(const MTPrpcError &error); - explicit RPCError(const mtpBuffer &reply); + explicit Error(const MTPrpcError &error); + explicit Error(const mtpBuffer &reply); enum { NoError, @@ -23,7 +25,7 @@ public: [[nodiscard]] const QString &type() const; [[nodiscard]] const QString &description() const; - [[nodiscard]] static RPCError Local( + [[nodiscard]] static Error Local( const QString &type, const QString &description); [[nodiscard]] static MTPrpcError MTPLocal( @@ -36,18 +38,16 @@ private: }; -namespace MTP { - -inline bool isFloodError(const RPCError &error) { +inline bool IsFloodError(const Error &error) { return error.type().startsWith(qstr("FLOOD_WAIT_")); } -inline bool isTemporaryError(const RPCError &error) { - return error.code() < 0 || error.code() >= 500 || isFloodError(error); +inline bool IsTemporaryError(const Error &error) { + return error.code() < 0 || error.code() >= 500 || IsFloodError(error); } -inline bool isDefaultHandledError(const RPCError &error) { - return isTemporaryError(error); +inline bool IsDefaultHandledError(const Error &error) { + return IsTemporaryError(error); } struct Response { @@ -57,7 +57,7 @@ struct Response { }; using DoneHandler = FnMut; -using FailHandler = Fn; +using FailHandler = Fn; struct ResponseHandler { DoneHandler done; diff --git a/Telegram/SourceFiles/mtproto/sender.h b/Telegram/SourceFiles/mtproto/sender.h index 2af657032..632f817f4 100644 --- a/Telegram/SourceFiles/mtproto/sender.h +++ b/Telegram/SourceFiles/mtproto/sender.h @@ -8,7 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #pragma once #include "base/variant.h" -#include "mtproto/mtproto_rpc_sender.h" +#include "mtproto/mtproto_response.h" #include "mtproto/mtp_instance.h" #include "mtproto/facade.h" @@ -28,9 +28,9 @@ class Sender { HandleAll, }; using FailPlainHandler = Fn; - using FailErrorHandler = Fn; - using FailRequestIdHandler = Fn; - using FailFullHandler = Fn; + using FailErrorHandler = Fn; + using FailRequestIdHandler = Fn; + using FailFullHandler = Fn; template static constexpr bool IsCallable @@ -83,13 +83,13 @@ class Sender { sender, handler = std::forward(handler), skipPolicy - ](const RPCError &error, const Response &response) { + ](const Error &error, const Response &response) { if (skipPolicy == FailSkipPolicy::Simple) { - if (isDefaultHandledError(error)) { + if (IsDefaultHandledError(error)) { return false; } } else if (skipPolicy == FailSkipPolicy::HandleFlood) { - if (isDefaultHandledError(error) && !isFloodError(error)) { + if (IsDefaultHandledError(error) && !IsFloodError(error)) { return false; } } @@ -101,17 +101,17 @@ class Sender { return true; } else if constexpr (IsCallable< Handler, - const RPCError&, + const Error&, const Response&>) { onstack(error, response); } else if constexpr (IsCallable< Handler, - const RPCError&, + const Error&, mtpRequestId>) { onstack(error, response.requestId); } else if constexpr (IsCallable< Handler, - const RPCError&>) { + const Error&>) { onstack(error); } else if constexpr (IsCallable) { onstack(); @@ -252,14 +252,14 @@ public: [[nodiscard]] SpecificRequestBuilder &fail( Fn callback) noexcept { setFailHandler(std::move(callback)); return *this; } [[nodiscard]] SpecificRequestBuilder &fail( Fn callback) noexcept { setFailHandler(std::move(callback)); return *this; @@ -270,7 +270,7 @@ public: return *this; } [[nodiscard]] SpecificRequestBuilder &fail( - Fn callback) noexcept { + Fn callback) noexcept { setFailHandler(std::move(callback)); return *this; } diff --git a/Telegram/SourceFiles/mtproto/session.h b/Telegram/SourceFiles/mtproto/session.h index 95ac0da70..8c7b5668b 100644 --- a/Telegram/SourceFiles/mtproto/session.h +++ b/Telegram/SourceFiles/mtproto/session.h @@ -8,7 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #pragma once #include "base/timer.h" -#include "mtproto/mtproto_rpc_sender.h" +#include "mtproto/mtproto_response.h" #include "mtproto/mtproto_proxy_data.h" #include "mtproto/details/mtproto_serialized_request.h" diff --git a/Telegram/SourceFiles/mtproto/session_private.cpp b/Telegram/SourceFiles/mtproto/session_private.cpp index ce37352c1..2574c23ba 100644 --- a/Telegram/SourceFiles/mtproto/session_private.cpp +++ b/Telegram/SourceFiles/mtproto/session_private.cpp @@ -12,7 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "mtproto/details/mtproto_dump_to_text.h" #include "mtproto/details/mtproto_rsa_public_key.h" #include "mtproto/session.h" -#include "mtproto/mtproto_rpc_sender.h" +#include "mtproto/mtproto_response.h" #include "mtproto/mtproto_dc_options.h" #include "mtproto/connection_abstract.h" #include "platform/platform_specific.h" diff --git a/Telegram/SourceFiles/passport/passport_form_controller.cpp b/Telegram/SourceFiles/passport/passport_form_controller.cpp index a1288a8b8..30516bd12 100644 --- a/Telegram/SourceFiles/passport/passport_form_controller.cpp +++ b/Telegram/SourceFiles/passport/passport_form_controller.cpp @@ -771,7 +771,7 @@ std::vector> FormController::submitGetErrors() { + st::defaultToast.durationFadeOut), this, [=] { cancel(); }); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _submitRequestId = 0; if (handleAppUpdateError(error.type())) { } else if (AcceptErrorRequiresRestart(error.type())) { @@ -894,7 +894,7 @@ void FormController::submitPassword( bytes::make_span(password), 0); // secure_secret_id } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _passwordCheckRequestId = 0; if (error.type() == qstr("SRP_ID_INVALID")) { handleSrpIdInvalid(_passwordCheckRequestId); @@ -902,7 +902,7 @@ void FormController::submitPassword( // Force reload and show form. _password = PasswordSettings(); reloadPassword(); - } else if (MTP::isFloodError(error)) { + } else if (MTP::IsFloodError(error)) { _passwordError.fire(tr::lng_flood_error(tr::now)); } else if (error.type() == qstr("PASSWORD_HASH_INVALID") || error.type() == qstr("SRP_PASSWORD_CHANGED")) { @@ -973,7 +973,7 @@ void FormController::checkSavedPasswordSettings( session().data().forgetPassportCredentials(); showForm(); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _passwordCheckRequestId = 0; if (error.type() != qstr("SRP_ID_INVALID") || !handleSrpIdInvalid(_passwordCheckRequestId)) { @@ -1013,7 +1013,7 @@ void FormController::recoverPassword() { ) | rpl::start_with_next([=] { box->closeBox(); }, box->lifetime()); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _recoverRequestId = 0; _view->show(Box(Lang::Hard::ServerError() + '\n' @@ -1038,7 +1038,7 @@ void FormController::cancelPassword() { )).done([=](const MTPBool &result) { _passwordRequestId = 0; reloadPassword(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _passwordRequestId = 0; reloadPassword(); }).send(); @@ -1118,7 +1118,7 @@ void FormController::resetSecret( )).done([=](const MTPBool &result) { _saveSecretRequestId = 0; generateSecret(password); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _saveSecretRequestId = 0; if (error.type() != qstr("SRP_ID_INVALID") || !handleSrpIdInvalid(_saveSecretRequestId)) { @@ -1651,7 +1651,7 @@ void FormController::verify( )).done([=](const MTPBool &result) { savePlainTextValue(nonconst); clearValueVerification(nonconst); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { nonconst->verification.requestId = 0; if (error.type() == qstr("PHONE_CODE_INVALID")) { verificationError( @@ -1668,7 +1668,7 @@ void FormController::verify( )).done([=](const MTPBool &result) { savePlainTextValue(nonconst); clearValueVerification(nonconst); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { nonconst->verification.requestId = 0; if (error.type() == qstr("CODE_INVALID")) { verificationError( @@ -1896,7 +1896,7 @@ void FormController::deleteValueEdit(not_null value) { )).done([=](const MTPBool &result) { resetValue(*nonconst); _valueSaveFinished.fire_copy(value); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { nonconst->saveRequestId = 0; valueSaveShowError(nonconst, error); }).send(); @@ -2049,7 +2049,7 @@ void FormController::sendSaveRequest( value->fillDataFrom(std::move(refreshed)); _valueSaveFinished.fire_copy(value); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { value->saveRequestId = 0; const auto code = error.type(); if (handleAppUpdateError(code)) { @@ -2161,7 +2161,7 @@ void FormController::startPhoneVerification(not_null value) { } break; } _verificationNeeded.fire_copy(value); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { value->verification.requestId = 0; valueSaveShowError(value, error); }).send(); @@ -2179,7 +2179,7 @@ void FormController::startEmailVerification(not_null value) { ? data.vlength().v : -1; _verificationNeeded.fire_copy(value); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { valueSaveShowError(value, error); }).send(); } @@ -2200,7 +2200,7 @@ void FormController::requestPhoneCall(not_null value) { void FormController::valueSaveShowError( not_null value, - const RPCError &error) { + const MTP::Error &error) { _view->show(Box( Lang::Hard::SecureSaveError() + "\n" + error.type())); valueSaveFailed(value); @@ -2265,7 +2265,7 @@ void FormController::saveSecret( for (const auto &callback : base::take(_secretCallbacks)) { callback(); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _saveSecretRequestId = 0; if (error.type() != qstr("SRP_ID_INVALID") || !handleSrpIdInvalid(_saveSecretRequestId)) { @@ -2296,7 +2296,7 @@ void FormController::requestForm() { )).done([=](const MTPaccount_AuthorizationForm &result) { _formRequestId = 0; formDone(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { formFail(error.type()); }).send(); } @@ -2503,7 +2503,7 @@ void FormController::requestConfig() { _configRequestId = 0; ConfigInstance() = ParseConfig(result); showForm(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _configRequestId = 0; showForm(); }).send(); @@ -2578,7 +2578,7 @@ void FormController::requestPassword() { )).done([=](const MTPaccount_Password &result) { _passwordRequestId = 0; passwordDone(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { formFail(error.type()); }).send(); } diff --git a/Telegram/SourceFiles/passport/passport_form_controller.h b/Telegram/SourceFiles/passport/passport_form_controller.h index 8491cc4a9..74db59cee 100644 --- a/Telegram/SourceFiles/passport/passport_form_controller.h +++ b/Telegram/SourceFiles/passport/passport_form_controller.h @@ -496,7 +496,7 @@ private: QString getPlainTextFromValue(not_null value) const; void startPhoneVerification(not_null value); void startEmailVerification(not_null value); - void valueSaveShowError(not_null value, const RPCError &error); + void valueSaveShowError(not_null value, const MTP::Error &error); void valueSaveFailed(not_null value); void requestPhoneCall(not_null value); void verificationError( diff --git a/Telegram/SourceFiles/settings/settings_main.cpp b/Telegram/SourceFiles/settings/settings_main.cpp index 086a19841..f2e77d1f1 100644 --- a/Telegram/SourceFiles/settings/settings_main.cpp +++ b/Telegram/SourceFiles/settings/settings_main.cpp @@ -321,7 +321,7 @@ void SetupHelp( Ui::showPeerHistory(user, ShowAtUnreadMsgId); } }); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { *requestId = 0; }).send(); }); diff --git a/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp b/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp index f31e59a60..1ee57041e 100644 --- a/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp +++ b/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp @@ -246,7 +246,7 @@ void BlockedBoxController::loadMoreRows() { } break; default: Unexpected("Bad type() in MTPcontacts_GetBlocked() result."); } - }).fail([this](const RPCError &error) { + }).fail([this](const MTP::Error &error) { _loadRequestId = 0; }).send(); } diff --git a/Telegram/SourceFiles/storage/download_manager_mtproto.cpp b/Telegram/SourceFiles/storage/download_manager_mtproto.cpp index 1af23d665..9e26edd6c 100644 --- a/Telegram/SourceFiles/storage/download_manager_mtproto.cpp +++ b/Telegram/SourceFiles/storage/download_manager_mtproto.cpp @@ -9,7 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "mtproto/facade.h" #include "mtproto/mtproto_auth_key.h" -#include "mtproto/mtproto_rpc_sender.h" +#include "mtproto/mtproto_response.h" #include "main/main_session.h" #include "apiwrap.h" #include "base/openssl_help.h" @@ -521,7 +521,7 @@ mtpRequestId DownloadMtprotoTask::sendRequest( MTP_int(limit) )).done([=](const MTPupload_CdnFile &result, mtpRequestId id) { cdnPartLoaded(result, id); - }).fail([=](const RPCError &error, mtpRequestId id) { + }).fail([=](const MTP::Error &error, mtpRequestId id) { cdnPartFailed(error, id); }).toDC(shiftedDcId).send(); } @@ -534,7 +534,7 @@ mtpRequestId DownloadMtprotoTask::sendRequest( MTP_int(limit) )).done([=](const MTPupload_WebFile &result, mtpRequestId id) { webPartLoaded(result, id); - }).fail([=](const RPCError &error, mtpRequestId id) { + }).fail([=](const MTP::Error &error, mtpRequestId id) { partFailed(error, id); }).toDC(shiftedDcId).send(); }, [&](const GeoPointLocation &location) { @@ -554,7 +554,7 @@ mtpRequestId DownloadMtprotoTask::sendRequest( MTP_int(limit) )).done([=](const MTPupload_WebFile &result, mtpRequestId id) { webPartLoaded(result, id); - }).fail([=](const RPCError &error, mtpRequestId id) { + }).fail([=](const MTP::Error &error, mtpRequestId id) { partFailed(error, id); }).toDC(shiftedDcId).send(); }, [&](const StorageFileLocation &location) { @@ -566,7 +566,7 @@ mtpRequestId DownloadMtprotoTask::sendRequest( MTP_int(limit) )).done([=](const MTPupload_File &result, mtpRequestId id) { normalPartLoaded(result, id); - }).fail([=](const RPCError &error, mtpRequestId id) { + }).fail([=](const MTP::Error &error, mtpRequestId id) { normalPartFailed(reference, error, id); }).toDC(shiftedDcId).send(); }); @@ -594,7 +594,7 @@ void DownloadMtprotoTask::requestMoreCdnFileHashes() { MTP_int(requestData.offset) )).done([=](const MTPVector &result, mtpRequestId id) { getCdnFileHashesDone(result, id); - }).fail([=](const RPCError &error, mtpRequestId id) { + }).fail([=](const MTP::Error &error, mtpRequestId id) { cdnPartFailed(error, id); }).toDC(shiftedDcId).send(); placeSentRequest(_cdnHashesRequestId, requestData); @@ -649,7 +649,7 @@ void DownloadMtprotoTask::cdnPartLoaded(const MTPupload_CdnFile &result, mtpRequ data.vrequest_token() )).done([=](const MTPVector &result, mtpRequestId id) { reuploadDone(result, id); - }).fail([=](const RPCError &error, mtpRequestId id) { + }).fail([=](const MTP::Error &error, mtpRequestId id) { cdnPartFailed(error, id); }).toDC(shiftedDcId).send(); placeSentRequest(requestId, requestData); @@ -880,9 +880,9 @@ void DownloadMtprotoTask::partLoaded( bool DownloadMtprotoTask::normalPartFailed( QByteArray fileReference, - const RPCError &error, + const MTP::Error &error, mtpRequestId requestId) { - if (MTP::isDefaultHandledError(error)) { + if (MTP::IsDefaultHandledError(error)) { return false; } if (error.code() == 400 @@ -898,9 +898,9 @@ bool DownloadMtprotoTask::normalPartFailed( } bool DownloadMtprotoTask::partFailed( - const RPCError &error, + const MTP::Error &error, mtpRequestId requestId) { - if (MTP::isDefaultHandledError(error)) { + if (MTP::IsDefaultHandledError(error)) { return false; } cancelOnFail(); @@ -908,9 +908,9 @@ bool DownloadMtprotoTask::partFailed( } bool DownloadMtprotoTask::cdnPartFailed( - const RPCError &error, + const MTP::Error &error, mtpRequestId requestId) { - if (MTP::isDefaultHandledError(error)) { + if (MTP::IsDefaultHandledError(error)) { return false; } diff --git a/Telegram/SourceFiles/storage/download_manager_mtproto.h b/Telegram/SourceFiles/storage/download_manager_mtproto.h index 9c467c16f..a8adc26bf 100644 --- a/Telegram/SourceFiles/storage/download_manager_mtproto.h +++ b/Telegram/SourceFiles/storage/download_manager_mtproto.h @@ -12,7 +12,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/weak_ptr.h" class ApiWrap; -class RPCError; + +namespace MTP { +class Error; +} // namespace MTP namespace Storage { @@ -219,12 +222,12 @@ private: void partLoaded(int offset, const QByteArray &bytes); - bool partFailed(const RPCError &error, mtpRequestId requestId); + bool partFailed(const MTP::Error &error, mtpRequestId requestId); bool normalPartFailed( QByteArray fileReference, - const RPCError &error, + const MTP::Error &error, mtpRequestId requestId); - bool cdnPartFailed(const RPCError &error, mtpRequestId requestId); + bool cdnPartFailed(const MTP::Error &error, mtpRequestId requestId); [[nodiscard]] mtpRequestId sendRequest(const RequestData &requestData); void placeSentRequest( diff --git a/Telegram/SourceFiles/storage/file_upload.cpp b/Telegram/SourceFiles/storage/file_upload.cpp index 2fd2ce0b2..4f63f172d 100644 --- a/Telegram/SourceFiles/storage/file_upload.cpp +++ b/Telegram/SourceFiles/storage/file_upload.cpp @@ -586,7 +586,7 @@ void Uploader::sendNext() { MTP_bytes(toSend) )).done([=](const MTPBool &result, mtpRequestId requestId) { partLoaded(result, requestId); - }).fail([=](const RPCError &error, mtpRequestId requestId) { + }).fail([=](const MTP::Error &error, mtpRequestId requestId) { partFailed(error, requestId); }).toDC(MTP::uploadDcId(todc)).send(); } else { @@ -596,7 +596,7 @@ void Uploader::sendNext() { MTP_bytes(toSend) )).done([=](const MTPBool &result, mtpRequestId requestId) { partLoaded(result, requestId); - }).fail([=](const RPCError &error, mtpRequestId requestId) { + }).fail([=](const MTP::Error &error, mtpRequestId requestId) { partFailed(error, requestId); }).toDC(MTP::uploadDcId(todc)).send(); } @@ -615,7 +615,7 @@ void Uploader::sendNext() { MTP_bytes(part.value()) )).done([=](const MTPBool &result, mtpRequestId requestId) { partLoaded(result, requestId); - }).fail([=](const RPCError &error, mtpRequestId requestId) { + }).fail([=](const MTP::Error &error, mtpRequestId requestId) { partFailed(error, requestId); }).toDC(MTP::uploadDcId(todc)).send(); requestsSent.emplace(requestId, part.value()); @@ -734,7 +734,7 @@ void Uploader::partLoaded(const MTPBool &result, mtpRequestId requestId) { sendNext(); } -void Uploader::partFailed(const RPCError &error, mtpRequestId requestId) { +void Uploader::partFailed(const MTP::Error &error, mtpRequestId requestId) { // failed to upload current file if ((requestsSent.find(requestId) != requestsSent.cend()) || (docRequestsSent.find(requestId) != docRequestsSent.cend())) { diff --git a/Telegram/SourceFiles/storage/file_upload.h b/Telegram/SourceFiles/storage/file_upload.h index c4ab8ce12..9c319dcea 100644 --- a/Telegram/SourceFiles/storage/file_upload.h +++ b/Telegram/SourceFiles/storage/file_upload.h @@ -123,7 +123,7 @@ private: struct File; void partLoaded(const MTPBool &result, mtpRequestId requestId); - void partFailed(const RPCError &error, mtpRequestId requestId); + void partFailed(const MTP::Error &error, mtpRequestId requestId); void processPhotoProgress(const FullMsgId &msgId); void processPhotoFailed(const FullMsgId &msgId); diff --git a/Telegram/SourceFiles/support/support_helper.cpp b/Telegram/SourceFiles/support/support_helper.cpp index 940b25388..6252fd036 100644 --- a/Telegram/SourceFiles/support/support_helper.cpp +++ b/Telegram/SourceFiles/support/support_helper.cpp @@ -279,7 +279,7 @@ Helper::Helper(not_null session) result.match([&](const MTPDhelp_supportName &data) { setSupportName(qs(data.vname())); }); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { setSupportName( qsl("[rand^") + QString::number(Core::Sandbox::Instance().installationTag()) @@ -544,7 +544,7 @@ void Helper::saveInfo( )).done([=](const MTPhelp_UserInfo &result) { applyInfo(user, result); done(true); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { done(false); }).send(); } diff --git a/Telegram/SourceFiles/window/themes/window_theme_editor_box.cpp b/Telegram/SourceFiles/window/themes/window_theme_editor_box.cpp index f343907d8..927e02bee 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_editor_box.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme_editor_box.cpp @@ -545,7 +545,7 @@ Fn SavePreparedTheme( MTPInputThemeSettings() )).done([=](const MTPTheme &result) { finish(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { fail(SaveErrorType::Other, error.type()); }).send(); }; @@ -568,7 +568,7 @@ Fn SavePreparedTheme( MTPInputThemeSettings() )).done([=](const MTPTheme &result) { finish(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { fail(SaveErrorType::Other, error.type()); }).send(); }; @@ -586,7 +586,7 @@ Fn SavePreparedTheme( } else { updateTheme(result); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { fail(SaveErrorType::Other, error.type()); }).send(); }; @@ -635,7 +635,7 @@ Fn SavePreparedTheme( MTPInputThemeSettings() )).done([=](const MTPTheme &result) { save(); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { if (error.type() == qstr("THEME_FILE_INVALID")) { save(); } else { @@ -771,7 +771,7 @@ void SaveTheme( result.match([&](const MTPDtheme &data) { save(CloudTheme::Parse(&window->account().session(), data)); }); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { save(CloudTheme()); }).send(); } else { diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index 3fc73504b..2f7b0247a 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -813,7 +813,7 @@ void PeerMenuCreatePoll( const auto api = &peer->session().api(); api->createPoll(result.poll, action, crl::guard(box, [=] { box->closeBox(); - }), crl::guard(box, [=](const RPCError &error) { + }), crl::guard(box, [=](const MTP::Error &error) { *lock = false; box->submitFailed(tr::lng_attach_failed(tr::now)); })); @@ -1036,7 +1036,7 @@ QPointer ShowSendNowMessagesBox( MTP_vector(ids) )).done([=](const MTPUpdates &result) { session->api().applyUpdates(result); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { session->api().sendMessageFail(error, history->peer); }).send(); if (callback) { diff --git a/Telegram/SourceFiles/window/window_session_controller.cpp b/Telegram/SourceFiles/window/window_session_controller.cpp index dc13a5cb9..0cfbd4007 100644 --- a/Telegram/SourceFiles/window/window_session_controller.cpp +++ b/Telegram/SourceFiles/window/window_session_controller.cpp @@ -134,7 +134,7 @@ void SessionNavigation::resolveUsername( if (const auto peerId = peerFromMTP(d.vpeer())) { done(_session->data().peer(peerId)); } - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _resolveRequestId = 0; if (error.code() == 400) { Ui::show(Box( @@ -167,7 +167,7 @@ void SessionNavigation::resolveChannelById( fail(); } }); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { fail(); }).send(); } @@ -338,7 +338,7 @@ void SessionNavigation::showRepliesForMessage( commentId)); } }); - }).fail([=](const RPCError &error) { + }).fail([=](const MTP::Error &error) { _showingRepliesRequestId = 0; if (error.type() == u"CHANNEL_PRIVATE"_q || error.type() == u"USER_BANNED_IN_CHANNEL"_q) { diff --git a/Telegram/cmake/td_mtproto.cmake b/Telegram/cmake/td_mtproto.cmake index 8535fb1ec..2c134a40d 100644 --- a/Telegram/cmake/td_mtproto.cmake +++ b/Telegram/cmake/td_mtproto.cmake @@ -48,8 +48,8 @@ PRIVATE mtproto/mtproto_pch.h mtproto/mtproto_proxy_data.cpp mtproto/mtproto_proxy_data.h - mtproto/mtproto_rpc_sender.cpp - mtproto/mtproto_rpc_sender.h + mtproto/mtproto_response.cpp + mtproto/mtproto_response.h ) target_include_directories(td_mtproto