From 29d0c8c2eca5cbb196d8d66910aac0e200a736f1 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 28 Apr 2023 17:43:57 +0400 Subject: [PATCH] Update API scheme to layer 159. --- Telegram/Resources/tl/api.tl | 31 +++++++++++-------- Telegram/SourceFiles/api/api_updates.cpp | 6 ++-- Telegram/SourceFiles/api/api_user_privacy.cpp | 21 ++++++------- Telegram/SourceFiles/api/api_user_privacy.h | 1 + Telegram/SourceFiles/data/data_poll.cpp | 18 +++++------ Telegram/SourceFiles/data/data_poll.h | 2 +- .../history/view/media/history_view_poll.cpp | 14 ++++----- .../polls/info_polls_results_inner_widget.cpp | 27 ++++++++-------- 8 files changed, 63 insertions(+), 57 deletions(-) diff --git a/Telegram/Resources/tl/api.tl b/Telegram/Resources/tl/api.tl index 6a606b743..aa3934e16 100644 --- a/Telegram/Resources/tl/api.tl +++ b/Telegram/Resources/tl/api.tl @@ -370,7 +370,7 @@ updateDeleteScheduledMessages#90866cee peer:Peer messages:Vector = Update; updateTheme#8216fba3 theme:Theme = Update; updateGeoLiveViewed#871fb939 peer:Peer msg_id:int = Update; updateLoginToken#564fe691 = Update; -updateMessagePollVote#106395c9 poll_id:long user_id:long options:Vector qts:int = Update; +updateMessagePollVote#24f40e77 poll_id:long peer:Peer options:Vector qts:int = Update; updateDialogFilter#26ffde7d flags:# id:int filter:flags.0?DialogFilter = Update; updateDialogFilterOrder#a5d72105 order:Vector = Update; updateDialogFilters#3504914f = Update; @@ -514,6 +514,7 @@ inputPrivacyKeyProfilePhoto#5719bacc = InputPrivacyKey; inputPrivacyKeyPhoneNumber#352dafa = InputPrivacyKey; inputPrivacyKeyAddedByPhone#d1219bdd = InputPrivacyKey; inputPrivacyKeyVoiceMessages#aee69d68 = InputPrivacyKey; +inputPrivacyKeyAbout#3823cc40 = InputPrivacyKey; privacyKeyStatusTimestamp#bc2eab30 = PrivacyKey; privacyKeyChatInvite#500e6dfa = PrivacyKey; @@ -524,6 +525,7 @@ privacyKeyProfilePhoto#96151fed = PrivacyKey; privacyKeyPhoneNumber#d19ae46d = PrivacyKey; privacyKeyAddedByPhone#42ffd42b = PrivacyKey; privacyKeyVoiceMessages#697f414 = PrivacyKey; +privacyKeyAbout#a486b761 = PrivacyKey; inputPrivacyValueAllowContacts#d09e07b = InputPrivacyRule; inputPrivacyValueAllowAll#184b35ce = InputPrivacyRule; @@ -1135,7 +1137,7 @@ poll#86e18161 id:long flags:# closed:flags.0?true public_voters:flags.1?true mul pollAnswerVoters#3b6ddad2 flags:# chosen:flags.0?true correct:flags.1?true option:bytes voters:int = PollAnswerVoters; -pollResults#dcb82ea3 flags:# min:flags.0?true results:flags.1?Vector total_voters:flags.2?int recent_voters:flags.3?Vector solution:flags.4?string solution_entities:flags.4?Vector = PollResults; +pollResults#7adf2420 flags:# min:flags.0?true results:flags.1?Vector total_voters:flags.2?int recent_voters:flags.3?Vector solution:flags.4?string solution_entities:flags.4?Vector = PollResults; chatOnlines#f041e250 onlines:int = ChatOnlines; @@ -1156,7 +1158,7 @@ codeSettings#ad253d78 flags:# allow_flashcall:flags.0?true current_number:flags. wallPaperSettings#1dc1bca4 flags:# blur:flags.1?true motion:flags.2?true background_color:flags.0?int second_background_color:flags.4?int third_background_color:flags.5?int fourth_background_color:flags.6?int intensity:flags.3?int rotation:flags.4?int = WallPaperSettings; -autoDownloadSettings#8efab953 flags:# disabled:flags.0?true video_preload_large:flags.1?true audio_preload_next:flags.2?true phonecalls_less_data:flags.3?true photo_size_max:int video_size_max:long file_size_max:long video_upload_maxbitrate:int = AutoDownloadSettings; +autoDownloadSettings#baa57628 flags:# disabled:flags.0?true video_preload_large:flags.1?true audio_preload_next:flags.2?true phonecalls_less_data:flags.3?true photo_size_max:int video_size_max:long file_size_max:long video_upload_maxbitrate:int small_queue_active_operations_max:int large_queue_active_operations_max:int = AutoDownloadSettings; account.autoDownloadSettings#63cacf26 low:AutoDownloadSettings medium:AutoDownloadSettings high:AutoDownloadSettings = account.AutoDownloadSettings; @@ -1217,11 +1219,7 @@ themeSettings#fa58b6d4 flags:# message_colors_animated:flags.2?true base_theme:B webPageAttributeTheme#54b56617 flags:# documents:flags.0?Vector settings:flags.1?ThemeSettings = WebPageAttribute; -messageUserVote#34d247b4 user_id:long option:bytes date:int = MessageUserVote; -messageUserVoteInputOption#3ca5b0ec user_id:long date:int = MessageUserVote; -messageUserVoteMultiple#8a65e557 user_id:long options:Vector date:int = MessageUserVote; - -messages.votesList#823f649 flags:# count:int votes:Vector users:Vector next_offset:flags.0?string = messages.VotesList; +messages.votesList#4899484e flags:# count:int votes:Vector chats:Vector users:Vector next_offset:flags.0?string = messages.VotesList; bankCardOpenUrl#f568028a url:string name:string = BankCardOpenUrl; @@ -1346,7 +1344,7 @@ account.resetPasswordFailedWait#e3779861 retry_date:int = account.ResetPasswordR account.resetPasswordRequestedWait#e9effc7d until_date:int = account.ResetPasswordResult; account.resetPasswordOk#e926d63e = account.ResetPasswordResult; -sponsoredMessage#fc25b828 flags:# recommended:flags.5?true show_peer_photo:flags.6?true random_id:bytes from_id:flags.3?Peer chat_invite:flags.4?ChatInvite chat_invite_hash:flags.4?string channel_post:flags.2?int start_param:flags.0?string message:string entities:flags.1?Vector sponsor_info:flags.7?string additional_info:flags.8?string = SponsoredMessage; +sponsoredMessage#daafff6b flags:# recommended:flags.5?true show_peer_photo:flags.6?true random_id:bytes from_id:flags.3?Peer chat_invite:flags.4?ChatInvite chat_invite_hash:flags.4?string channel_post:flags.2?int start_param:flags.0?string webpage:flags.9?SponsoredWebPage message:string entities:flags.1?Vector sponsor_info:flags.7?string additional_info:flags.8?string = SponsoredMessage; messages.sponsoredMessages#c9ee1d87 flags:# posts_between:flags.0?int messages:Vector chats:Vector users:Vector = messages.SponsoredMessages; messages.sponsoredMessagesEmpty#1839490f = messages.SponsoredMessages; @@ -1378,7 +1376,7 @@ availableReaction#c077ec01 flags:# inactive:flags.0?true premium:flags.2?true re messages.availableReactionsNotModified#9f071957 = messages.AvailableReactions; messages.availableReactions#768e3aad hash:int reactions:Vector = messages.AvailableReactions; -messagePeerReaction#8c79b63c flags:# big:flags.0?true unread:flags.1?true peer_id:Peer date:int reaction:Reaction = MessagePeerReaction; +messagePeerReaction#8c79b63c flags:# big:flags.0?true unread:flags.1?true my:flags.2?true peer_id:Peer date:int reaction:Reaction = MessagePeerReaction; groupCallStreamChannel#80eb48af channel:int scale:int last_timestamp_ms:long = GroupCallStreamChannel; @@ -1543,6 +1541,12 @@ chatlists.chatlistUpdates#93bd878d missing_peers:Vector chats:Vector bots.botInfo#e8a775b0 name:string about:string description:string = bots.BotInfo; +messagePeerVote#b6cc2d5c peer:Peer option:bytes date:int = MessagePeerVote; +messagePeerVoteInputOption#74cda504 peer:Peer date:int = MessagePeerVote; +messagePeerVoteMultiple#4628f6e6 peer:Peer options:Vector date:int = MessagePeerVote; + +sponsoredWebPage#3db8ec63 flags:# url:string site_name:string photo:flags.0?Photo = SponsoredWebPage; + ---functions--- invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X; @@ -1663,6 +1667,7 @@ account.getDefaultGroupPhotoEmojis#915860ae hash:long = EmojiList; account.getAutoSaveSettings#adcbbcda = account.AutoSaveSettings; account.saveAutoSaveSettings#d69b8361 flags:# users:flags.0?true chats:flags.1?true broadcasts:flags.2?true peer:flags.3?InputPeer settings:AutoSaveSettings = Bool; account.deleteAutoSaveExceptions#53bc0020 = Bool; +account.invalidateSignInCodes#ca8ae8ba codes:Vector = Bool; users.getUsers#d91a548 id:Vector = Vector; users.getFullUser#b60f5918 id:InputUser = users.UserFull; @@ -1768,7 +1773,6 @@ messages.setInlineGameScore#15ad9f64 flags:# edit_message:flags.0?true force:fla messages.getGameHighScores#e822649d peer:InputPeer id:int user_id:InputUser = messages.HighScores; messages.getInlineGameHighScores#f635e1b id:InputBotInlineMessageID user_id:InputUser = messages.HighScores; messages.getCommonChats#e40ca104 user_id:InputUser max_id:long limit:int = messages.Chats; -messages.getAllChats#875f74be except_ids:Vector = messages.Chats; messages.getWebPage#32ca8f91 url:string hash:int = WebPage; messages.toggleDialogPin#a731e257 flags:# pinned:flags.0?true peer:InputDialogPeer = Bool; messages.reorderPinnedDialogs#3b1adf37 flags:# force:flags.0?true folder_id:int order:Vector = Bool; @@ -1882,7 +1886,7 @@ messages.requestAppWebView#8c5a3b3c flags:# write_allowed:flags.0?true peer:Inpu messages.setChatWallPaper#8ffacae1 flags:# peer:InputPeer wallpaper:flags.0?InputWallPaper settings:flags.2?WallPaperSettings id:flags.1?int = Updates; updates.getState#edd4882a = updates.State; -updates.getDifference#25939651 flags:# pts:int pts_total_limit:flags.0?int date:int qts:int = updates.Difference; +updates.getDifference#19c2f763 flags:# pts:int pts_limit:flags.1?int pts_total_limit:flags.0?int date:int qts:int qts_limit:flags.2?int = updates.Difference; updates.getChannelDifference#3173d78 flags:# force:flags.0?true channel:InputChannel filter:ChannelMessagesFilter pts:int limit:int = updates.ChannelDifference; photos.updateProfilePhoto#9e82039 flags:# fallback:flags.0?true bot:flags.1?InputUser id:InputPhoto = photos.Photo; @@ -1979,6 +1983,7 @@ channels.reorderPinnedForumTopics#2950a18f flags:# force:flags.0?true channel:In channels.toggleAntiSpam#68f3e4eb channel:InputChannel enabled:Bool = Updates; channels.reportAntiSpamFalsePositive#a850a693 channel:InputChannel msg_id:int = Bool; channels.toggleParticipantsHidden#6a6e7854 channel:InputChannel enabled:Bool = Updates; +channels.clickSponsoredMessage#18afbc93 channel:InputChannel random_id:bytes = Bool; bots.sendCustomRequest#aa2769ed custom_method:string params:DataJSON = DataJSON; bots.answerWebhookJSONQuery#e6213f4d query_id:long data:DataJSON = Bool; @@ -2075,4 +2080,4 @@ chatlists.hideChatlistUpdates#66e486fb chatlist:InputChatlist = Bool; chatlists.getLeaveChatlistSuggestions#fdbcd714 chatlist:InputChatlist = Vector; chatlists.leaveChatlist#74fae13a chatlist:InputChatlist peers:Vector = Updates; -// LAYER 158 +// LAYER 159 diff --git a/Telegram/SourceFiles/api/api_updates.cpp b/Telegram/SourceFiles/api/api_updates.cpp index 59f8b098b..4a8ce5173 100644 --- a/Telegram/SourceFiles/api/api_updates.cpp +++ b/Telegram/SourceFiles/api/api_updates.cpp @@ -677,9 +677,11 @@ void Updates::getDifference() { api().request(MTPupdates_GetDifference( MTP_flags(0), MTP_int(_ptsWaiter.current()), - MTPint(), + MTPint(), // pts_limit + MTPint(), // pts_total_limit MTP_int(_updatesDate), - MTP_int(_updatesQts) + MTP_int(_updatesQts), + MTPint() // qts_limit )).done([=](const MTPupdates_Difference &result) { differenceDone(result); }).fail([=](const MTP::Error &error) { diff --git a/Telegram/SourceFiles/api/api_user_privacy.cpp b/Telegram/SourceFiles/api/api_user_privacy.cpp index 8c97479c6..6cd57e2ec 100644 --- a/Telegram/SourceFiles/api/api_user_privacy.cpp +++ b/Telegram/SourceFiles/api/api_user_privacy.cpp @@ -177,18 +177,13 @@ MTPInputPrivacyKey KeyToTL(UserPrivacy::Key key) { case Key::Calls: return MTP_inputPrivacyKeyPhoneCall(); case Key::Invites: return MTP_inputPrivacyKeyChatInvite(); case Key::PhoneNumber: return MTP_inputPrivacyKeyPhoneNumber(); - case Key::AddedByPhone: - return MTP_inputPrivacyKeyAddedByPhone(); - case Key::LastSeen: - return MTP_inputPrivacyKeyStatusTimestamp(); - case Key::CallsPeer2Peer: - return MTP_inputPrivacyKeyPhoneP2P(); - case Key::Forwards: - return MTP_inputPrivacyKeyForwards(); - case Key::ProfilePhoto: - return MTP_inputPrivacyKeyProfilePhoto(); - case Key::Voices: - return MTP_inputPrivacyKeyVoiceMessages(); + case Key::AddedByPhone: return MTP_inputPrivacyKeyAddedByPhone(); + case Key::LastSeen: return MTP_inputPrivacyKeyStatusTimestamp(); + case Key::CallsPeer2Peer: return MTP_inputPrivacyKeyPhoneP2P(); + case Key::Forwards: return MTP_inputPrivacyKeyForwards(); + case Key::ProfilePhoto: return MTP_inputPrivacyKeyProfilePhoto(); + case Key::Voices: return MTP_inputPrivacyKeyVoiceMessages(); + case Key::About: return MTP_inputPrivacyKeyAbout(); } Unexpected("Key in Api::UserPrivacy::KetToTL."); } @@ -214,6 +209,8 @@ std::optional TLToKey(mtpTypeId type) { case mtpc_inputPrivacyKeyProfilePhoto: return Key::ProfilePhoto; case mtpc_privacyKeyVoiceMessages: case mtpc_inputPrivacyKeyVoiceMessages: return Key::Voices; + case mtpc_privacyKeyAbout: + case mtpc_inputPrivacyKeyAbout: return Key::About; } return std::nullopt; } diff --git a/Telegram/SourceFiles/api/api_user_privacy.h b/Telegram/SourceFiles/api/api_user_privacy.h index 39d8025b5..905d298e7 100644 --- a/Telegram/SourceFiles/api/api_user_privacy.h +++ b/Telegram/SourceFiles/api/api_user_privacy.h @@ -29,6 +29,7 @@ public: Forwards, ProfilePhoto, Voices, + About, }; enum class Option { Everyone, diff --git a/Telegram/SourceFiles/data/data_poll.cpp b/Telegram/SourceFiles/data/data_poll.cpp index ce2cbee35..efe928960 100644 --- a/Telegram/SourceFiles/data/data_poll.cpp +++ b/Telegram/SourceFiles/data/data_poll.cpp @@ -139,19 +139,19 @@ bool PollData::applyResults(const MTPPollResults &results) { recentVoters, recent->v, ranges::equal_to(), - bareProj, - &MTPlong::v); + &PeerData::id, + peerFromMTP); if (recentChanged) { changed = true; recentVoters = ranges::views::all( recent->v - ) | ranges::views::transform([&](MTPlong userId) { - const auto user = _owner->user(userId.v); - return user->isMinimalLoaded() ? user.get() : nullptr; - }) | ranges::views::filter([](UserData *user) { - return user != nullptr; - }) | ranges::views::transform([](UserData *user) { - return not_null(user); + ) | ranges::views::transform([&](MTPPeer peerId) { + const auto peer = _owner->peer(peerFromMTP(peerId)); + return peer->isMinimalLoaded() ? peer.get() : nullptr; + }) | ranges::views::filter([](PeerData *peer) { + return peer != nullptr; + }) | ranges::views::transform([](PeerData *peer) { + return not_null(peer); }) | ranges::to_vector; } } diff --git a/Telegram/SourceFiles/data/data_poll.h b/Telegram/SourceFiles/data/data_poll.h index 72d2731d6..4f428479b 100644 --- a/Telegram/SourceFiles/data/data_poll.h +++ b/Telegram/SourceFiles/data/data_poll.h @@ -67,7 +67,7 @@ struct PollData { PollId id = 0; QString question; std::vector answers; - std::vector> recentVoters; + std::vector> recentVoters; std::vector sendingVotes; TextWithEntities solution; TimeId closePeriod = 0; diff --git a/Telegram/SourceFiles/history/view/media/history_view_poll.cpp b/Telegram/SourceFiles/history/view/media/history_view_poll.cpp index b991e911f..c08d8fde5 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_poll.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_poll.cpp @@ -182,7 +182,7 @@ struct Poll::CloseInformation { }; struct Poll::RecentVoter { - not_null user; + not_null peer; mutable Ui::PeerUserpicView userpic; }; @@ -487,20 +487,20 @@ void Poll::updateRecentVoters() { _recentVoters, sliced, ranges::equal_to(), - &RecentVoter::user); + &RecentVoter::peer); if (changed) { auto updated = ranges::views::all( sliced - ) | ranges::views::transform([](not_null user) { - return RecentVoter{ user }; + ) | ranges::views::transform([](not_null peer) { + return RecentVoter{ peer }; }) | ranges::to_vector; const auto has = hasHeavyPart(); if (has) { for (auto &voter : updated) { const auto i = ranges::find( _recentVoters, - voter.user, - &RecentVoter::user); + voter.peer, + &RecentVoter::peer); if (i != end(_recentVoters)) { voter.userpic = std::move(i->userpic); } @@ -892,7 +892,7 @@ void Poll::paintRecentVoters( auto created = false; for (auto &recent : _recentVoters) { const auto was = !recent.userpic.null(); - recent.user->paintUserpic(p, recent.userpic, x, y, size); + recent.peer->paintUserpic(p, recent.userpic, x, y, size); if (!was && !recent.userpic.null()) { created = true; } 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 c4086ff5a..5fc2308a5 100644 --- a/Telegram/SourceFiles/info/polls/info_polls_results_inner_widget.cpp +++ b/Telegram/SourceFiles/info/polls/info_polls_results_inner_widget.cpp @@ -143,12 +143,12 @@ private: QString loadForOffset; int leftToLoad = 0; int fullCount = 0; - std::vector> preloaded; + std::vector> preloaded; bool wasLoading = false; }; - bool appendRow(not_null user); - std::unique_ptr createRow(not_null user) const; + bool appendRow(not_null peer); + std::unique_ptr createRow(not_null peer) const; void addPreloaded(); bool addPreloadedPage(); void preloadedAdded(); @@ -163,7 +163,7 @@ private: QString _offset; mtpRequestId _loadRequestId = 0; QString _loadForOffset; - std::vector> _preloaded; + std::vector> _preloaded; rpl::variable _count = 0; rpl::variable _fullCount; rpl::variable _leftToLoad; @@ -227,16 +227,17 @@ void ListController::loadMoreRows() { _offset = data.vnext_offset().value_or_empty(); auto &owner = session().data(); owner.processUsers(data.vusers()); + owner.processChats(data.vchats()); auto add = limit - kLeavePreloaded; for (const auto &vote : data.vvotes().v) { vote.match([&](const auto &data) { - const auto user = owner.user(data.vuser_id().v); - if (user->isMinimalLoaded()) { + const auto peer = owner.peer(peerFromMTP(data.vpeer())); + if (peer->isMinimalLoaded()) { if (add) { - appendRow(user); + appendRow(peer); --add; } else { - _preloaded.push_back(user); + _preloaded.push_back(peer); } } }); @@ -393,17 +394,17 @@ void ListController::rowClicked(not_null row) { _showPeerInfoRequests.fire(row->peer()); } -bool ListController::appendRow(not_null user) { - if (delegate()->peerListFindRow(user->id.value)) { +bool ListController::appendRow(not_null peer) { + if (delegate()->peerListFindRow(peer->id.value)) { return false; } - delegate()->peerListAppendRow(createRow(user)); + delegate()->peerListAppendRow(createRow(peer)); return true; } std::unique_ptr ListController::createRow( - not_null user) const { - auto row = std::make_unique(user); + not_null peer) const { + auto row = std::make_unique(peer); row->setCustomStatus(QString()); return row; }