Update API scheme to layer 159.

This commit is contained in:
John Preston 2023-04-28 17:43:57 +04:00
parent 59bb46aa40
commit 29d0c8c2ec
8 changed files with 63 additions and 57 deletions

View File

@ -370,7 +370,7 @@ updateDeleteScheduledMessages#90866cee peer:Peer messages:Vector<int> = 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<bytes> qts:int = Update;
updateMessagePollVote#24f40e77 poll_id:long peer:Peer options:Vector<bytes> qts:int = Update;
updateDialogFilter#26ffde7d flags:# id:int filter:flags.0?DialogFilter = Update;
updateDialogFilterOrder#a5d72105 order:Vector<int> = 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<PollAnswerVoters> total_voters:flags.2?int recent_voters:flags.3?Vector<long> solution:flags.4?string solution_entities:flags.4?Vector<MessageEntity> = PollResults;
pollResults#7adf2420 flags:# min:flags.0?true results:flags.1?Vector<PollAnswerVoters> total_voters:flags.2?int recent_voters:flags.3?Vector<Peer> solution:flags.4?string solution_entities:flags.4?Vector<MessageEntity> = 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<Document> 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<bytes> date:int = MessageUserVote;
messages.votesList#823f649 flags:# count:int votes:Vector<MessageUserVote> users:Vector<User> next_offset:flags.0?string = messages.VotesList;
messages.votesList#4899484e flags:# count:int votes:Vector<MessagePeerVote> chats:Vector<Chat> users:Vector<User> 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<MessageEntity> 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<MessageEntity> sponsor_info:flags.7?string additional_info:flags.8?string = SponsoredMessage;
messages.sponsoredMessages#c9ee1d87 flags:# posts_between:flags.0?int messages:Vector<SponsoredMessage> chats:Vector<Chat> users:Vector<User> = 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<AvailableReaction> = 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<Peer> chats:Vector<Chat>
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<bytes> 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<string> = Bool;
users.getUsers#d91a548 id:Vector<InputUser> = Vector<User>;
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<long> = 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<InputDialogPeer> = 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<Peer>;
chatlists.leaveChatlist#74fae13a chatlist:InputChatlist peers:Vector<InputPeer> = Updates;
// LAYER 158
// LAYER 159

View File

@ -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) {

View File

@ -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<UserPrivacy::Key> 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;
}

View File

@ -29,6 +29,7 @@ public:
Forwards,
ProfilePhoto,
Voices,
About,
};
enum class Option {
Everyone,

View File

@ -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<UserData*>(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;
}
}

View File

@ -67,7 +67,7 @@ struct PollData {
PollId id = 0;
QString question;
std::vector<PollAnswer> answers;
std::vector<not_null<UserData*>> recentVoters;
std::vector<not_null<PeerData*>> recentVoters;
std::vector<QByteArray> sendingVotes;
TextWithEntities solution;
TimeId closePeriod = 0;

View File

@ -182,7 +182,7 @@ struct Poll::CloseInformation {
};
struct Poll::RecentVoter {
not_null<UserData*> user;
not_null<PeerData*> 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<UserData*> user) {
return RecentVoter{ user };
) | ranges::views::transform([](not_null<PeerData*> 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;
}

View File

@ -143,12 +143,12 @@ private:
QString loadForOffset;
int leftToLoad = 0;
int fullCount = 0;
std::vector<not_null<UserData*>> preloaded;
std::vector<not_null<PeerData*>> preloaded;
bool wasLoading = false;
};
bool appendRow(not_null<UserData*> user);
std::unique_ptr<PeerListRow> createRow(not_null<UserData*> user) const;
bool appendRow(not_null<PeerData*> peer);
std::unique_ptr<PeerListRow> createRow(not_null<PeerData*> peer) const;
void addPreloaded();
bool addPreloadedPage();
void preloadedAdded();
@ -163,7 +163,7 @@ private:
QString _offset;
mtpRequestId _loadRequestId = 0;
QString _loadForOffset;
std::vector<not_null<UserData*>> _preloaded;
std::vector<not_null<PeerData*>> _preloaded;
rpl::variable<int> _count = 0;
rpl::variable<int> _fullCount;
rpl::variable<int> _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<PeerListRow*> row) {
_showPeerInfoRequests.fire(row->peer());
}
bool ListController::appendRow(not_null<UserData*> user) {
if (delegate()->peerListFindRow(user->id.value)) {
bool ListController::appendRow(not_null<PeerData*> peer) {
if (delegate()->peerListFindRow(peer->id.value)) {
return false;
}
delegate()->peerListAppendRow(createRow(user));
delegate()->peerListAppendRow(createRow(peer));
return true;
}
std::unique_ptr<PeerListRow> ListController::createRow(
not_null<UserData*> user) const {
auto row = std::make_unique<PeerListRow>(user);
not_null<PeerData*> peer) const {
auto row = std::make_unique<PeerListRow>(peer);
row->setCustomStatus(QString());
return row;
}