From 4f7c7286327e8909d5f0b2102f22f4f470320317 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 19 Nov 2021 23:04:40 +0400 Subject: [PATCH] Update API scheme on layer 135. --- Telegram/Resources/tl/api.tl | 19 +++--- Telegram/SourceFiles/api/api_updates.cpp | 6 +- Telegram/SourceFiles/apiwrap.cpp | 60 +++++++++++-------- Telegram/SourceFiles/apiwrap.h | 5 +- .../SourceFiles/boxes/delete_messages_box.cpp | 2 +- .../SourceFiles/boxes/sticker_set_box.cpp | 5 +- Telegram/SourceFiles/boxes/stickers_box.cpp | 11 +++- .../chat_helpers/stickers_dice_pack.cpp | 5 +- .../chat_helpers/stickers_emoji_pack.cpp | 10 +++- .../chat_helpers/stickers_list_widget.cpp | 30 ++++++---- .../SourceFiles/data/data_file_origin.cpp | 1 + Telegram/SourceFiles/data/data_user.cpp | 1 - .../data/stickers/data_stickers.cpp | 43 +++++++------ .../SourceFiles/data/stickers/data_stickers.h | 4 +- .../export/data/export_data_types.cpp | 15 +++-- .../export/data/export_data_types.h | 2 +- .../SourceFiles/export/export_api_wrap.cpp | 17 +++--- Telegram/SourceFiles/main/main_session.cpp | 7 +-- Telegram/SourceFiles/main/main_session.h | 2 +- 19 files changed, 141 insertions(+), 104 deletions(-) diff --git a/Telegram/Resources/tl/api.tl b/Telegram/Resources/tl/api.tl index f2a919806..139cc03b4 100644 --- a/Telegram/Resources/tl/api.tl +++ b/Telegram/Resources/tl/api.tl @@ -222,7 +222,7 @@ inputPeerNotifySettings#9c3d198e flags:# show_previews:flags.0?Bool silent:flags peerNotifySettings#af509d20 flags:# show_previews:flags.0?Bool silent:flags.1?Bool mute_until:flags.2?int sound:flags.3?string = PeerNotifySettings; -peerSettings#733f2961 flags:# report_spam:flags.0?true add_contact:flags.1?true block_contact:flags.2?true share_contact:flags.3?true need_contacts_exception:flags.4?true report_geo:flags.5?true autoarchived:flags.7?true invite_members:flags.8?true geo_distance:flags.6?int = PeerSettings; +peerSettings#a8228d2e flags:# report_spam:flags.0?true add_contact:flags.1?true block_contact:flags.2?true share_contact:flags.3?true need_contacts_exception:flags.4?true report_geo:flags.5?true autoarchived:flags.7?true invite_members:flags.8?true geo_distance:flags.6?int request_chat:flags.9?Peer request_chat_date:flags.9?int = PeerSettings; wallPaper#a437c3ed id:long flags:# creator:flags.0?true default:flags.1?true pattern:flags.3?true dark:flags.4?true access_hash:long slug:string document:Document settings:flags.2?WallPaperSettings = WallPaper; wallPaperNoFile#e0804116 id:long flags:# default:flags.1?true dark:flags.4?true settings:flags.2?WallPaperSettings = WallPaper; @@ -236,7 +236,7 @@ inputReportReasonCopyright#9b89f93a = ReportReason; inputReportReasonGeoIrrelevant#dbd4feed = ReportReason; inputReportReasonFake#f5ddd6e7 = ReportReason; -userFull#d697ff05 flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true user:User about:flags.1?string settings:PeerSettings profile_photo:flags.2?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int ttl_period:flags.14?int theme_emoticon:flags.15?string = UserFull; +userFull#cf366521 flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true id:long about:flags.1?string settings:PeerSettings profile_photo:flags.2?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int ttl_period:flags.14?int theme_emoticon:flags.15?string private_forward_name:flags.16?string = UserFull; contact#145ade0b user_id:long mutual:Bool = Contact; @@ -568,6 +568,7 @@ inputStickerSetAnimatedEmojiAnimations#cde3739 = InputStickerSet; stickerSet#d7df217a flags:# archived:flags.1?true official:flags.2?true masks:flags.3?true animated:flags.5?true installed_date:flags.0?int id:long access_hash:long title:string short_name:string thumbs:flags.4?Vector thumb_dc_id:flags.4?int thumb_version:flags.4?int count:int hash:int = StickerSet; messages.stickerSet#b60a24a6 set:StickerSet packs:Vector documents:Vector = messages.StickerSet; +messages.stickerSetNotModified#d3f924eb = messages.StickerSet; botCommand#c27ac8c7 command:string description:string = BotCommand; @@ -1292,6 +1293,10 @@ messages.searchResultsPositions#53b22baf count:int positions:Vector chats:Vector users:Vector = channels.SendAsPeers; +users.userFull#3b6d152e full_user:UserFull chats:Vector users:Vector = users.UserFull; + +messages.peerSettings#6880b94d settings:PeerSettings chats:Vector users:Vector = messages.PeerSettings; + ---functions--- invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X; @@ -1397,7 +1402,7 @@ account.setAuthorizationTTL#bf899aa0 authorization_ttl_days:int = Bool; account.changeAuthorizationSettings#432910d5 hash:long encrypted_requests_disabled:Bool = Bool; users.getUsers#d91a548 id:Vector = Vector; -users.getFullUser#ca30a5b1 id:InputUser = UserFull; +users.getFullUser#b60f5918 id:InputUser = users.UserFull; users.setSecureValueErrors#90c894b5 id:InputUser errors:Vector = Bool; contacts.getContactIDs#7adc669d hash:long = Vector; @@ -1434,7 +1439,7 @@ messages.sendMessage#d9d75a4 flags:# no_webpage:flags.1?true silent:flags.5?true messages.sendMedia#e25ff8e0 flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true peer:InputPeer reply_to_msg_id:flags.0?int media:InputMedia message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; messages.forwardMessages#cc30290b flags:# silent:flags.5?true background:flags.6?true with_my_score:flags.8?true drop_author:flags.11?true drop_media_captions:flags.12?true from_peer:InputPeer id:Vector random_id:Vector to_peer:InputPeer schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; messages.reportSpam#cf1592db peer:InputPeer = Bool; -messages.getPeerSettings#3672e09c peer:InputPeer = PeerSettings; +messages.getPeerSettings#efd9a6a2 peer:InputPeer = messages.PeerSettings; messages.report#8953ab4e peer:InputPeer id:Vector reason:ReportReason message:string = Bool; messages.getChats#49e9528f id:Vector = messages.Chats; messages.getFullChat#aeb00b34 chat_id:long = messages.ChatFull; @@ -1461,7 +1466,7 @@ messages.getWebPagePreview#8b68b0cc flags:# message:string entities:flags.3?Vect messages.exportChatInvite#a02ce5d5 flags:# legacy_revoke_permanent:flags.2?true request_needed:flags.3?true peer:InputPeer expire_date:flags.0?int usage_limit:flags.1?int title:flags.4?string = ExportedChatInvite; messages.checkChatInvite#3eadb1bb hash:string = ChatInvite; messages.importChatInvite#6c50051c hash:string = Updates; -messages.getStickerSet#2619a90e stickerset:InputStickerSet = messages.StickerSet; +messages.getStickerSet#c8a0ec74 stickerset:InputStickerSet hash:int = messages.StickerSet; messages.installStickerSet#c78fe460 stickerset:InputStickerSet archived:Bool = messages.StickerSetInstallResult; messages.uninstallStickerSet#f96e55de stickerset:InputStickerSet = Bool; messages.startBot#e6df7378 bot:InputUser peer:InputPeer random_id:long start_param:string = Updates; @@ -1614,8 +1619,7 @@ help.getCountriesList#735787a8 lang_code:string hash:int = help.CountriesList; channels.readHistory#cc104937 channel:InputChannel max_id:int = Bool; channels.deleteMessages#84c1fd4e channel:InputChannel id:Vector = messages.AffectedMessages; -channels.deleteUserHistory#d10dd71b channel:InputChannel user_id:InputUser = messages.AffectedHistory; -channels.reportSpam#fe087810 channel:InputChannel user_id:InputUser id:Vector = Bool; +channels.reportSpam#f44a8315 channel:InputChannel participant:InputPeer id:Vector = Bool; channels.getMessages#ad8c9a23 channel:InputChannel id:Vector = messages.Messages; channels.getParticipants#77ced9d0 channel:InputChannel filter:ChannelParticipantsFilter offset:int limit:int hash:long = channels.ChannelParticipants; channels.getParticipant#a0ab6cc6 channel:InputChannel participant:InputPeer = channels.ChannelParticipant; @@ -1651,6 +1655,7 @@ channels.convertToGigagroup#b290c69 channel:InputChannel = Updates; channels.viewSponsoredMessage#beaedb94 channel:InputChannel random_id:bytes = Bool; channels.getSponsoredMessages#ec210fbf channel:InputChannel = messages.SponsoredMessages; channels.getSendAs#dc770ee peer:InputPeer = channels.SendAsPeers; +channels.deleteParticipantHistory#367544db channel:InputChannel participant:InputPeer = messages.AffectedHistory; bots.sendCustomRequest#aa2769ed custom_method:string params:DataJSON = DataJSON; bots.answerWebhookJSONQuery#e6213f4d query_id:long data:DataJSON = Bool; diff --git a/Telegram/SourceFiles/api/api_updates.cpp b/Telegram/SourceFiles/api/api_updates.cpp index 5dd2d8744..68701250f 100644 --- a/Telegram/SourceFiles/api/api_updates.cpp +++ b/Telegram/SourceFiles/api/api_updates.cpp @@ -2214,7 +2214,11 @@ void Updates::feedUpdate(const MTPUpdate &update) { ////// Cloud sticker sets case mtpc_updateNewStickerSet: { const auto &d = update.c_updateNewStickerSet(); - session().data().stickers().newSetReceived(d.vstickerset()); + d.vstickerset().match([&](const MTPDmessages_stickerSet &data) { + session().data().stickers().newSetReceived(data); + }, [](const MTPDmessages_stickerSetNotModified &) { + LOG(("API Error: Unexpected messages.stickerSetNotModified.")); + }); } break; case mtpc_updateStickerSetsOrder: { diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index 750c522aa..bdf844f47 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -1040,7 +1040,11 @@ void ApiWrap::requestFullPeer(not_null peer) { } return request(MTPusers_GetFullUser( user->inputUser - )).done([=](const MTPUserFull &result, mtpRequestId requestId) { + )).done([=](const MTPusers_UserFull &result, mtpRequestId requestId) { + result.match([&](const MTPDusers_userFull &data) { + _session->data().processUsers(data.vusers()); + _session->data().processChats(data.vchats()); + }); gotUserFull(user, result, requestId); }).fail(failHandler).send(); } else if (const auto chat = peer->asChat()) { @@ -1072,12 +1076,6 @@ void ApiWrap::processFullPeer( gotChatFull(peer, result, mtpRequestId(0)); } -void ApiWrap::processFullPeer( - not_null user, - const MTPUserFull &result) { - gotUserFull(user, result, mtpRequestId(0)); -} - void ApiWrap::gotChatFull( not_null peer, const MTPmessages_ChatFull &result, @@ -1117,18 +1115,20 @@ void ApiWrap::gotChatFull( void ApiWrap::gotUserFull( not_null user, - const MTPUserFull &result, + const MTPusers_UserFull &result, mtpRequestId req) { - const auto &d = result.c_userFull(); - if (user == _session->user() && !_session->validateSelf(d.vuser())) { - constexpr auto kRequestUserAgainTimeout = crl::time(10000); - base::call_delayed(kRequestUserAgainTimeout, _session, [=] { - requestFullPeer(user); + result.match([&](const MTPDusers_userFull &data) { + data.vfull_user().match([&](const MTPDuserFull &fields) { + if (user == _session->user() && !_session->validateSelf(fields.vid().v)) { + constexpr auto kRequestUserAgainTimeout = crl::time(10000); + base::call_delayed(kRequestUserAgainTimeout, _session, [=] { + requestFullPeer(user); + }); + return; + } + Data::ApplyUserUpdate(user, fields); }); - return; - } - Data::ApplyUserUpdate(user, d); - + }); if (req) { const auto i = _fullPeerRequests.find(user); if (i != _fullPeerRequests.cend() && i.value() == req) { @@ -1184,9 +1184,13 @@ void ApiWrap::requestPeerSettings(not_null peer) { } request(MTPmessages_GetPeerSettings( peer->input - )).done([=](const MTPPeerSettings &result) { - peer->setSettings(result); - _requestedPeerSettings.erase(peer); + )).done([=](const MTPmessages_PeerSettings &result) { + result.match([&](const MTPDmessages_peerSettings &data) { + _session->data().processUsers(data.vusers()); + _session->data().processChats(data.vchats()); + peer->setSettings(data.vsettings()); + _requestedPeerSettings.erase(peer); + }); }).fail([=](const MTP::Error &error) { _requestedPeerSettings.erase(peer); }).send(); @@ -1775,9 +1779,9 @@ void ApiWrap::deleteAllFromUser( void ApiWrap::deleteAllFromUserSend( not_null channel, not_null from) { - request(MTPchannels_DeleteUserHistory( + request(MTPchannels_DeleteParticipantHistory( channel->inputChannel, - from->inputUser + from->input )).done([=](const MTPmessages_AffectedHistory &result) { const auto offset = applyAffectedHistory(channel, result); if (offset > 0) { @@ -1834,7 +1838,8 @@ void ApiWrap::requestStickerSets() { MTP_long(i.key()), MTP_long(i.value().first)); i.value().second = request(MTPmessages_GetStickerSet( - id + id, + MTP_int(0) // hash )).done([=, setId = i.key()](const MTPmessages_StickerSet &result) { gotStickerSet(setId, result); }).fail([=, setId = i.key()](const MTP::Error &error) { @@ -2589,7 +2594,11 @@ void ApiWrap::applyNotifySettings( void ApiWrap::gotStickerSet(uint64 setId, const MTPmessages_StickerSet &result) { _stickerSetRequests.remove(setId); - _session->data().stickers().feedSetFull(result); + result.match([&](const MTPDmessages_stickerSet &data) { + _session->data().stickers().feedSetFull(data); + }, [](const MTPDmessages_stickerSetNotModified &) { + LOG(("API Error: Unexpected messages.stickerSetNotModified.")); + }); } void ApiWrap::requestWebPageDelayed(WebPageData *page) { @@ -2846,7 +2855,8 @@ void ApiWrap::refreshFileReference( request(MTPmessages_GetStickerSet( MTP_inputStickerSetID( MTP_long(data.setId), - MTP_long(data.accessHash))), + MTP_long(data.accessHash)), + MTP_int(0)), // hash [=] { crl::on_main(_session, [=] { local().writeInstalledStickers(); local().writeRecentStickers(); diff --git a/Telegram/SourceFiles/apiwrap.h b/Telegram/SourceFiles/apiwrap.h index 6fced4cc2..f8fdbe4ca 100644 --- a/Telegram/SourceFiles/apiwrap.h +++ b/Telegram/SourceFiles/apiwrap.h @@ -210,9 +210,6 @@ public: void processFullPeer( not_null peer, const MTPmessages_ChatFull &result); - void processFullPeer( - not_null user, - const MTPUserFull &result); void migrateChat( not_null chat, @@ -459,7 +456,7 @@ private: mtpRequestId req); void gotUserFull( not_null user, - const MTPUserFull &result, + const MTPusers_UserFull &result, mtpRequestId req); void applyLastParticipantsList( not_null channel, diff --git a/Telegram/SourceFiles/boxes/delete_messages_box.cpp b/Telegram/SourceFiles/boxes/delete_messages_box.cpp index f099b3bca..e1c5050ba 100644 --- a/Telegram/SourceFiles/boxes/delete_messages_box.cpp +++ b/Telegram/SourceFiles/boxes/delete_messages_box.cpp @@ -487,7 +487,7 @@ void DeleteMessagesBox::deleteAndClear() { _moderateInChannel->session().api().request( MTPchannels_ReportSpam( _moderateInChannel->inputChannel, - _moderateFrom->inputUser, + _moderateFrom->input, MTP_vector(1, MTP_int(_ids[0].msg))) ).send(); } diff --git a/Telegram/SourceFiles/boxes/sticker_set_box.cpp b/Telegram/SourceFiles/boxes/sticker_set_box.cpp index 7aacd11fd..6e66ce602 100644 --- a/Telegram/SourceFiles/boxes/sticker_set_box.cpp +++ b/Telegram/SourceFiles/boxes/sticker_set_box.cpp @@ -367,7 +367,8 @@ StickerSetBox::Inner::Inner( , _input(set) , _previewTimer([=] { showPreview(); }) { _api.request(MTPmessages_GetStickerSet( - Data::InputStickerSet(_input) + Data::InputStickerSet(_input), + MTP_int(0) // hash )).done([=](const MTPmessages_StickerSet &result) { gotSet(result); }).fail([=](const MTP::Error &error) { @@ -463,6 +464,8 @@ void StickerSetBox::Inner::gotSet(const MTPmessages_StickerSet &set) { set->setThumbnail(_setThumbnail); } }); + }, [&](const MTPDmessages_stickerSetNotModified &data) { + LOG(("API Error: Unexpected messages.stickerSetNotModified.")); }); if (_pack.isEmpty()) { diff --git a/Telegram/SourceFiles/boxes/stickers_box.cpp b/Telegram/SourceFiles/boxes/stickers_box.cpp index fcdab0848..ce2774c99 100644 --- a/Telegram/SourceFiles/boxes/stickers_box.cpp +++ b/Telegram/SourceFiles/boxes/stickers_box.cpp @@ -1887,11 +1887,16 @@ void StickersBox::Inner::handleMegagroupSetAddressChange() { } } else if (!_megagroupSetRequestId) { _megagroupSetRequestId = _api.request(MTPmessages_GetStickerSet( - MTP_inputStickerSetShortName(MTP_string(text)) + MTP_inputStickerSetShortName(MTP_string(text)), + MTP_int(0) // hash )).done([=](const MTPmessages_StickerSet &result) { _megagroupSetRequestId = 0; - auto set = session().data().stickers().feedSetFull(result); - setMegagroupSelectedSet(set->identifier()); + result.match([&](const MTPDmessages_stickerSet &data) { + const auto set = session().data().stickers().feedSetFull(data); + setMegagroupSelectedSet(set->identifier()); + }, [](const MTPDmessages_stickerSetNotModified &) { + LOG(("API Error: Unexpected messages.stickerSetNotModified.")); + }); }).fail([=](const MTP::Error &error) { _megagroupSetRequestId = 0; setMegagroupSelectedSet({}); diff --git a/Telegram/SourceFiles/chat_helpers/stickers_dice_pack.cpp b/Telegram/SourceFiles/chat_helpers/stickers_dice_pack.cpp index 4c2335b55..b1fb1a35f 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_dice_pack.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_dice_pack.cpp @@ -47,10 +47,13 @@ void DicePack::load() { return; } _requestId = _session->api().request(MTPmessages_GetStickerSet( - MTP_inputStickerSetDice(MTP_string(_emoji)) + MTP_inputStickerSetDice(MTP_string(_emoji)), + MTP_int(0) // hash )).done([=](const MTPmessages_StickerSet &result) { result.match([&](const MTPDmessages_stickerSet &data) { applySet(data); + }, [](const MTPDmessages_stickerSetNotModified &) { + LOG(("API Error: Unexpected messages.stickerSetNotModified.")); }); }).fail([=](const MTP::Error &error) { _requestId = 0; diff --git a/Telegram/SourceFiles/chat_helpers/stickers_emoji_pack.cpp b/Telegram/SourceFiles/chat_helpers/stickers_emoji_pack.cpp index b00db95ba..fee492880 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_emoji_pack.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_emoji_pack.cpp @@ -231,12 +231,15 @@ void EmojiPack::refresh() { return; } _requestId = _session->api().request(MTPmessages_GetStickerSet( - MTP_inputStickerSetAnimatedEmoji() + MTP_inputStickerSetAnimatedEmoji(), + MTP_int(0) // hash )).done([=](const MTPmessages_StickerSet &result) { _requestId = 0; refreshAnimations(); result.match([&](const MTPDmessages_stickerSet &data) { applySet(data); + }, [](const MTPDmessages_stickerSetNotModified &) { + LOG(("API Error: Unexpected messages.stickerSetNotModified.")); }); }).fail([=](const MTP::Error &error) { _requestId = 0; @@ -249,12 +252,15 @@ void EmojiPack::refreshAnimations() { return; } _animationsRequestId = _session->api().request(MTPmessages_GetStickerSet( - MTP_inputStickerSetAnimatedEmojiAnimations() + MTP_inputStickerSetAnimatedEmojiAnimations(), + MTP_int(0) // hash )).done([=](const MTPmessages_StickerSet &result) { _animationsRequestId = 0; refreshDelayed(); result.match([&](const MTPDmessages_stickerSet &data) { applyAnimationsSet(data); + }, [](const MTPDmessages_stickerSetNotModified &) { + LOG(("API Error: Unexpected messages.stickerSetNotModified.")); }); }).fail([=](const MTP::Error &error) { _animationsRequestId = 0; diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp index 9db3b019a..c907c5f5e 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp @@ -2778,16 +2778,21 @@ void StickersListWidget::refreshMegagroupStickers(GroupStickersPlace place) { } _megagroupSetIdRequested = set.id; _api.request(MTPmessages_GetStickerSet( - Data::InputStickerSet(set) + Data::InputStickerSet(set), + MTP_int(0) // hash )).done([=](const MTPmessages_StickerSet &result) { - if (const auto set = session().data().stickers().feedSetFull(result)) { - refreshStickers(); - if (set->id == _megagroupSetIdRequested) { - _megagroupSetIdRequested = 0; - } else { - LOG(("API Error: Got different set.")); + result.match([&](const MTPDmessages_stickerSet &data) { + if (const auto set = session().data().stickers().feedSetFull(data)) { + refreshStickers(); + if (set->id == _megagroupSetIdRequested) { + _megagroupSetIdRequested = 0; + } else { + LOG(("API Error: Got different set.")); + } } - } + }, [](const MTPDmessages_stickerSetNotModified &) { + LOG(("API Error: Unexpected messages.stickerSetNotModified.")); + }); }).send(); } @@ -3117,9 +3122,14 @@ void StickersListWidget::installSet(uint64 setId) { const auto input = set->mtpInput(); if ((set->flags & SetFlag::NotLoaded) || set->stickers.empty()) { _api.request(MTPmessages_GetStickerSet( - input + input, + MTP_int(0) // hash )).done([=](const MTPmessages_StickerSet &result) { - session().data().stickers().feedSetFull(result); + result.match([&](const MTPDmessages_stickerSet &data) { + session().data().stickers().feedSetFull(data); + }, [](const MTPDmessages_stickerSetNotModified &) { + LOG(("API Error: Unexpected messages.stickerSetNotModified.")); + }); sendInstallRequest(setId, input); }).send(); } else { diff --git a/Telegram/SourceFiles/data/data_file_origin.cpp b/Telegram/SourceFiles/data/data_file_origin.cpp index 4eeca4535..f55cd470f 100644 --- a/Telegram/SourceFiles/data/data_file_origin.cpp +++ b/Telegram/SourceFiles/data/data_file_origin.cpp @@ -140,6 +140,7 @@ struct FileReferenceAccumulator { void push(const MTPmessages_StickerSet &data) { data.match([&](const MTPDmessages_stickerSet &data) { push(data.vdocuments()); + }, [](const MTPDmessages_stickerSetNotModified &data) { }); } void push(const MTPmessages_SavedGifs &data) { diff --git a/Telegram/SourceFiles/data/data_user.cpp b/Telegram/SourceFiles/data/data_user.cpp index 43aa88743..bf714b4e8 100644 --- a/Telegram/SourceFiles/data/data_user.cpp +++ b/Telegram/SourceFiles/data/data_user.cpp @@ -188,7 +188,6 @@ bool UserData::hasCalls() const { namespace Data { void ApplyUserUpdate(not_null user, const MTPDuserFull &update) { - user->owner().processUser(update.vuser()); if (const auto photo = update.vprofile_photo()) { user->owner().processPhoto(*photo); } diff --git a/Telegram/SourceFiles/data/stickers/data_stickers.cpp b/Telegram/SourceFiles/data/stickers/data_stickers.cpp index 09293c429..86ed5b3a4 100644 --- a/Telegram/SourceFiles/data/stickers/data_stickers.cpp +++ b/Telegram/SourceFiles/data/stickers/data_stickers.cpp @@ -518,25 +518,27 @@ void Stickers::requestSetToPushFaved(not_null document) { setIsFaved(document, std::move(list)); }; session().api().request(MTPmessages_GetStickerSet( - Data::InputStickerSet(document->sticker()->set) + Data::InputStickerSet(document->sticker()->set), + MTP_int(0) // hash )).done([=](const MTPmessages_StickerSet &result) { - Expects(result.type() == mtpc_messages_stickerSet); - - auto list = std::vector>(); - auto &d = result.c_messages_stickerSet(); - list.reserve(d.vpacks().v.size()); - for (const auto &mtpPack : d.vpacks().v) { - auto &pack = mtpPack.c_stickerPack(); - for (const auto &documentId : pack.vdocuments().v) { - if (documentId.v == document->id) { - if (const auto emoji = Ui::Emoji::Find(qs(mtpPack.c_stickerPack().vemoticon()))) { - list.emplace_back(emoji); + result.match([&](const MTPDmessages_stickerSet &data) { + auto list = std::vector>(); + list.reserve(data.vpacks().v.size()); + for (const auto &mtpPack : data.vpacks().v) { + auto &pack = mtpPack.c_stickerPack(); + for (const auto &documentId : pack.vdocuments().v) { + if (documentId.v == document->id) { + if (const auto emoji = Ui::Emoji::Find(qs(mtpPack.c_stickerPack().vemoticon()))) { + list.emplace_back(emoji); + } + break; } - break; } } - } - addAnyway(std::move(list)); + addAnyway(std::move(list)); + }, [](const MTPDmessages_stickerSetNotModified &) { + LOG(("API Error: Unexpected messages.stickerSetNotModified.")); + }); }).fail([=](const MTP::Error &error) { // Perhaps this is a deleted sticker pack. Add anyway. addAnyway({}); @@ -1230,11 +1232,9 @@ StickersSet *Stickers::feedSet(const MTPDstickerSet &data) { return it->second.get(); } -StickersSet *Stickers::feedSetFull(const MTPmessages_StickerSet &data) { - Expects(data.type() == mtpc_messages_stickerSet); - Expects(data.c_messages_stickerSet().vset().type() == mtpc_stickerSet); +StickersSet *Stickers::feedSetFull(const MTPDmessages_stickerSet &d) { + Expects(d.vset().type() == mtpc_stickerSet); - const auto &d = data.c_messages_stickerSet(); const auto &s = d.vset().c_stickerSet(); auto &sets = setsRef(); @@ -1353,8 +1353,7 @@ StickersSet *Stickers::feedSetFull(const MTPmessages_StickerSet &data) { return set; } -void Stickers::newSetReceived(const MTPmessages_StickerSet &data) { - const auto &set = data.c_messages_stickerSet(); +void Stickers::newSetReceived(const MTPDmessages_stickerSet &set) { const auto &s = set.vset().c_stickerSet(); if (!s.vinstalled_date()) { LOG(("API Error: " @@ -1374,7 +1373,7 @@ void Stickers::newSetReceived(const MTPmessages_StickerSet &data) { order.insert(insertAtIndex, s.vid().v); } - feedSetFull(data); + feedSetFull(set); } QString Stickers::getSetTitle(const MTPDstickerSet &s) { diff --git a/Telegram/SourceFiles/data/stickers/data_stickers.h b/Telegram/SourceFiles/data/stickers/data_stickers.h index 3550e4a44..b381e0b49 100644 --- a/Telegram/SourceFiles/data/stickers/data_stickers.h +++ b/Telegram/SourceFiles/data/stickers/data_stickers.h @@ -198,8 +198,8 @@ public: not_null document); StickersSet *feedSet(const MTPDstickerSet &data); - StickersSet *feedSetFull(const MTPmessages_StickerSet &data); - void newSetReceived(const MTPmessages_StickerSet &data); + StickersSet *feedSetFull(const MTPDmessages_stickerSet &d); + void newSetReceived(const MTPDmessages_stickerSet &set); QString getSetTitle(const MTPDstickerSet &s); diff --git a/Telegram/SourceFiles/export/data/export_data_types.cpp b/Telegram/SourceFiles/export/data/export_data_types.cpp index 3410d7403..2048feb41 100644 --- a/Telegram/SourceFiles/export/data/export_data_types.cpp +++ b/Telegram/SourceFiles/export/data/export_data_types.cpp @@ -1283,15 +1283,14 @@ std::map ParseMessagesList( return result; } -PersonalInfo ParsePersonalInfo(const MTPUserFull &data) { - Expects(data.type() == mtpc_userFull); - - const auto &fields = data.c_userFull(); +PersonalInfo ParsePersonalInfo(const MTPDusers_userFull &data) { auto result = PersonalInfo(); - result.user = ParseUser(fields.vuser()); - if (const auto about = fields.vabout()) { - result.bio = ParseString(*about); - } + result.user = ParseUser(data.vusers().v[0]); + data.vfull_user().match([&](const MTPDuserFull &data) { + if (const auto about = data.vabout()) { + result.bio = ParseString(*about); + } + }); return result; } diff --git a/Telegram/SourceFiles/export/data/export_data_types.h b/Telegram/SourceFiles/export/data/export_data_types.h index 677bfb3a8..495446814 100644 --- a/Telegram/SourceFiles/export/data/export_data_types.h +++ b/Telegram/SourceFiles/export/data/export_data_types.h @@ -255,7 +255,7 @@ struct PersonalInfo { Utf8String bio; }; -PersonalInfo ParsePersonalInfo(const MTPUserFull &data); +PersonalInfo ParsePersonalInfo(const MTPDusers_userFull &data); struct TopPeer { Peer peer; diff --git a/Telegram/SourceFiles/export/export_api_wrap.cpp b/Telegram/SourceFiles/export/export_api_wrap.cpp index bd62779cc..464f7ff90 100644 --- a/Telegram/SourceFiles/export/export_api_wrap.cpp +++ b/Telegram/SourceFiles/export/export_api_wrap.cpp @@ -674,15 +674,14 @@ void ApiWrap::startMainSession(FnMut done) { void ApiWrap::requestPersonalInfo(FnMut done) { mainRequest(MTPusers_GetFullUser( _user - )).done([=, done = std::move(done)](const MTPUserFull &result) mutable { - Expects(result.type() == mtpc_userFull); - - const auto &full = result.c_userFull(); - if (full.vuser().type() == mtpc_user) { - done(Data::ParsePersonalInfo(result)); - } else { - error("Bad user type."); - } + )).done([=, done = std::move(done)](const MTPusers_UserFull &result) mutable { + result.match([&](const MTPDusers_userFull &data) { + if (!data.vusers().v.empty()) { + done(Data::ParsePersonalInfo(data)); + } else { + error("Bad user type."); + } + }); }).send(); } diff --git a/Telegram/SourceFiles/main/main_session.cpp b/Telegram/SourceFiles/main/main_session.cpp index 4507d75d1..b329e30bc 100644 --- a/Telegram/SourceFiles/main/main_session.cpp +++ b/Telegram/SourceFiles/main/main_session.cpp @@ -220,11 +220,8 @@ PeerId Session::userPeerId() const { return _user->id; } -bool Session::validateSelf(const MTPUser &user) { - if (user.type() != mtpc_user || !user.c_user().is_self()) { - LOG(("API Error: bad self user received.")); - return false; - } else if (UserId(user.c_user().vid()) != userId()) { +bool Session::validateSelf(UserId id) { + if (id != userId()) { LOG(("Auth Error: wrong self user received.")); crl::on_main(this, [=] { _account->logOut(); }); return false; diff --git a/Telegram/SourceFiles/main/main_session.h b/Telegram/SourceFiles/main/main_session.h index 44693c498..004a15b4d 100644 --- a/Telegram/SourceFiles/main/main_session.h +++ b/Telegram/SourceFiles/main/main_session.h @@ -82,7 +82,7 @@ public: [[nodiscard]] not_null user() const { return _user; } - bool validateSelf(const MTPUser &user); + bool validateSelf(UserId id); [[nodiscard]] Data::Changes &changes() const { return *_changes;