Update API scheme on layer 135.

This commit is contained in:
John Preston 2021-11-19 23:04:40 +04:00
parent 7d89952541
commit 4f7c728632
19 changed files with 141 additions and 104 deletions

View file

@ -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; 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; 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; 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; inputReportReasonGeoIrrelevant#dbd4feed = ReportReason;
inputReportReasonFake#f5ddd6e7 = 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; 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<PhotoSize> thumb_dc_id:flags.4?int thumb_version:flags.4?int count:int hash:int = StickerSet; 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<PhotoSize> thumb_dc_id:flags.4?int thumb_version:flags.4?int count:int hash:int = StickerSet;
messages.stickerSet#b60a24a6 set:StickerSet packs:Vector<StickerPack> documents:Vector<Document> = messages.StickerSet; messages.stickerSet#b60a24a6 set:StickerSet packs:Vector<StickerPack> documents:Vector<Document> = messages.StickerSet;
messages.stickerSetNotModified#d3f924eb = messages.StickerSet;
botCommand#c27ac8c7 command:string description:string = BotCommand; botCommand#c27ac8c7 command:string description:string = BotCommand;
@ -1292,6 +1293,10 @@ messages.searchResultsPositions#53b22baf count:int positions:Vector<SearchResult
channels.sendAsPeers#8356cda9 peers:Vector<Peer> chats:Vector<Chat> users:Vector<User> = channels.SendAsPeers; channels.sendAsPeers#8356cda9 peers:Vector<Peer> chats:Vector<Chat> users:Vector<User> = channels.SendAsPeers;
users.userFull#3b6d152e full_user:UserFull chats:Vector<Chat> users:Vector<User> = users.UserFull;
messages.peerSettings#6880b94d settings:PeerSettings chats:Vector<Chat> users:Vector<User> = messages.PeerSettings;
---functions--- ---functions---
invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X; 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; account.changeAuthorizationSettings#432910d5 hash:long encrypted_requests_disabled:Bool = Bool;
users.getUsers#d91a548 id:Vector<InputUser> = Vector<User>; users.getUsers#d91a548 id:Vector<InputUser> = Vector<User>;
users.getFullUser#ca30a5b1 id:InputUser = UserFull; users.getFullUser#b60f5918 id:InputUser = users.UserFull;
users.setSecureValueErrors#90c894b5 id:InputUser errors:Vector<SecureValueError> = Bool; users.setSecureValueErrors#90c894b5 id:InputUser errors:Vector<SecureValueError> = Bool;
contacts.getContactIDs#7adc669d hash:long = Vector<int>; contacts.getContactIDs#7adc669d hash:long = Vector<int>;
@ -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<MessageEntity> schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; 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<MessageEntity> 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<int> random_id:Vector<long> to_peer:InputPeer 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<int> random_id:Vector<long> to_peer:InputPeer schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates;
messages.reportSpam#cf1592db peer:InputPeer = Bool; 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<int> reason:ReportReason message:string = Bool; messages.report#8953ab4e peer:InputPeer id:Vector<int> reason:ReportReason message:string = Bool;
messages.getChats#49e9528f id:Vector<long> = messages.Chats; messages.getChats#49e9528f id:Vector<long> = messages.Chats;
messages.getFullChat#aeb00b34 chat_id:long = messages.ChatFull; 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.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.checkChatInvite#3eadb1bb hash:string = ChatInvite;
messages.importChatInvite#6c50051c hash:string = Updates; 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.installStickerSet#c78fe460 stickerset:InputStickerSet archived:Bool = messages.StickerSetInstallResult;
messages.uninstallStickerSet#f96e55de stickerset:InputStickerSet = Bool; messages.uninstallStickerSet#f96e55de stickerset:InputStickerSet = Bool;
messages.startBot#e6df7378 bot:InputUser peer:InputPeer random_id:long start_param:string = Updates; 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.readHistory#cc104937 channel:InputChannel max_id:int = Bool;
channels.deleteMessages#84c1fd4e channel:InputChannel id:Vector<int> = messages.AffectedMessages; channels.deleteMessages#84c1fd4e channel:InputChannel id:Vector<int> = messages.AffectedMessages;
channels.deleteUserHistory#d10dd71b channel:InputChannel user_id:InputUser = messages.AffectedHistory; channels.reportSpam#f44a8315 channel:InputChannel participant:InputPeer id:Vector<int> = Bool;
channels.reportSpam#fe087810 channel:InputChannel user_id:InputUser id:Vector<int> = Bool;
channels.getMessages#ad8c9a23 channel:InputChannel id:Vector<InputMessage> = messages.Messages; channels.getMessages#ad8c9a23 channel:InputChannel id:Vector<InputMessage> = messages.Messages;
channels.getParticipants#77ced9d0 channel:InputChannel filter:ChannelParticipantsFilter offset:int limit:int hash:long = channels.ChannelParticipants; channels.getParticipants#77ced9d0 channel:InputChannel filter:ChannelParticipantsFilter offset:int limit:int hash:long = channels.ChannelParticipants;
channels.getParticipant#a0ab6cc6 channel:InputChannel participant:InputPeer = channels.ChannelParticipant; 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.viewSponsoredMessage#beaedb94 channel:InputChannel random_id:bytes = Bool;
channels.getSponsoredMessages#ec210fbf channel:InputChannel = messages.SponsoredMessages; channels.getSponsoredMessages#ec210fbf channel:InputChannel = messages.SponsoredMessages;
channels.getSendAs#dc770ee peer:InputPeer = channels.SendAsPeers; 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.sendCustomRequest#aa2769ed custom_method:string params:DataJSON = DataJSON;
bots.answerWebhookJSONQuery#e6213f4d query_id:long data:DataJSON = Bool; bots.answerWebhookJSONQuery#e6213f4d query_id:long data:DataJSON = Bool;

View file

@ -2214,7 +2214,11 @@ void Updates::feedUpdate(const MTPUpdate &update) {
////// Cloud sticker sets ////// Cloud sticker sets
case mtpc_updateNewStickerSet: { case mtpc_updateNewStickerSet: {
const auto &d = update.c_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; } break;
case mtpc_updateStickerSetsOrder: { case mtpc_updateStickerSetsOrder: {

View file

@ -1040,7 +1040,11 @@ void ApiWrap::requestFullPeer(not_null<PeerData*> peer) {
} }
return request(MTPusers_GetFullUser( return request(MTPusers_GetFullUser(
user->inputUser 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); gotUserFull(user, result, requestId);
}).fail(failHandler).send(); }).fail(failHandler).send();
} else if (const auto chat = peer->asChat()) { } else if (const auto chat = peer->asChat()) {
@ -1072,12 +1076,6 @@ void ApiWrap::processFullPeer(
gotChatFull(peer, result, mtpRequestId(0)); gotChatFull(peer, result, mtpRequestId(0));
} }
void ApiWrap::processFullPeer(
not_null<UserData*> user,
const MTPUserFull &result) {
gotUserFull(user, result, mtpRequestId(0));
}
void ApiWrap::gotChatFull( void ApiWrap::gotChatFull(
not_null<PeerData*> peer, not_null<PeerData*> peer,
const MTPmessages_ChatFull &result, const MTPmessages_ChatFull &result,
@ -1117,18 +1115,20 @@ void ApiWrap::gotChatFull(
void ApiWrap::gotUserFull( void ApiWrap::gotUserFull(
not_null<UserData*> user, not_null<UserData*> user,
const MTPUserFull &result, const MTPusers_UserFull &result,
mtpRequestId req) { mtpRequestId req) {
const auto &d = result.c_userFull(); result.match([&](const MTPDusers_userFull &data) {
if (user == _session->user() && !_session->validateSelf(d.vuser())) { data.vfull_user().match([&](const MTPDuserFull &fields) {
constexpr auto kRequestUserAgainTimeout = crl::time(10000); if (user == _session->user() && !_session->validateSelf(fields.vid().v)) {
base::call_delayed(kRequestUserAgainTimeout, _session, [=] { constexpr auto kRequestUserAgainTimeout = crl::time(10000);
requestFullPeer(user); base::call_delayed(kRequestUserAgainTimeout, _session, [=] {
requestFullPeer(user);
});
return;
}
Data::ApplyUserUpdate(user, fields);
}); });
return; });
}
Data::ApplyUserUpdate(user, d);
if (req) { if (req) {
const auto i = _fullPeerRequests.find(user); const auto i = _fullPeerRequests.find(user);
if (i != _fullPeerRequests.cend() && i.value() == req) { if (i != _fullPeerRequests.cend() && i.value() == req) {
@ -1184,9 +1184,13 @@ void ApiWrap::requestPeerSettings(not_null<PeerData*> peer) {
} }
request(MTPmessages_GetPeerSettings( request(MTPmessages_GetPeerSettings(
peer->input peer->input
)).done([=](const MTPPeerSettings &result) { )).done([=](const MTPmessages_PeerSettings &result) {
peer->setSettings(result); result.match([&](const MTPDmessages_peerSettings &data) {
_requestedPeerSettings.erase(peer); _session->data().processUsers(data.vusers());
_session->data().processChats(data.vchats());
peer->setSettings(data.vsettings());
_requestedPeerSettings.erase(peer);
});
}).fail([=](const MTP::Error &error) { }).fail([=](const MTP::Error &error) {
_requestedPeerSettings.erase(peer); _requestedPeerSettings.erase(peer);
}).send(); }).send();
@ -1775,9 +1779,9 @@ void ApiWrap::deleteAllFromUser(
void ApiWrap::deleteAllFromUserSend( void ApiWrap::deleteAllFromUserSend(
not_null<ChannelData*> channel, not_null<ChannelData*> channel,
not_null<UserData*> from) { not_null<UserData*> from) {
request(MTPchannels_DeleteUserHistory( request(MTPchannels_DeleteParticipantHistory(
channel->inputChannel, channel->inputChannel,
from->inputUser from->input
)).done([=](const MTPmessages_AffectedHistory &result) { )).done([=](const MTPmessages_AffectedHistory &result) {
const auto offset = applyAffectedHistory(channel, result); const auto offset = applyAffectedHistory(channel, result);
if (offset > 0) { if (offset > 0) {
@ -1834,7 +1838,8 @@ void ApiWrap::requestStickerSets() {
MTP_long(i.key()), MTP_long(i.key()),
MTP_long(i.value().first)); MTP_long(i.value().first));
i.value().second = request(MTPmessages_GetStickerSet( i.value().second = request(MTPmessages_GetStickerSet(
id id,
MTP_int(0) // hash
)).done([=, setId = i.key()](const MTPmessages_StickerSet &result) { )).done([=, setId = i.key()](const MTPmessages_StickerSet &result) {
gotStickerSet(setId, result); gotStickerSet(setId, result);
}).fail([=, setId = i.key()](const MTP::Error &error) { }).fail([=, setId = i.key()](const MTP::Error &error) {
@ -2589,7 +2594,11 @@ void ApiWrap::applyNotifySettings(
void ApiWrap::gotStickerSet(uint64 setId, const MTPmessages_StickerSet &result) { void ApiWrap::gotStickerSet(uint64 setId, const MTPmessages_StickerSet &result) {
_stickerSetRequests.remove(setId); _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) { void ApiWrap::requestWebPageDelayed(WebPageData *page) {
@ -2846,7 +2855,8 @@ void ApiWrap::refreshFileReference(
request(MTPmessages_GetStickerSet( request(MTPmessages_GetStickerSet(
MTP_inputStickerSetID( MTP_inputStickerSetID(
MTP_long(data.setId), MTP_long(data.setId),
MTP_long(data.accessHash))), MTP_long(data.accessHash)),
MTP_int(0)), // hash
[=] { crl::on_main(_session, [=] { [=] { crl::on_main(_session, [=] {
local().writeInstalledStickers(); local().writeInstalledStickers();
local().writeRecentStickers(); local().writeRecentStickers();

View file

@ -210,9 +210,6 @@ public:
void processFullPeer( void processFullPeer(
not_null<PeerData*> peer, not_null<PeerData*> peer,
const MTPmessages_ChatFull &result); const MTPmessages_ChatFull &result);
void processFullPeer(
not_null<UserData*> user,
const MTPUserFull &result);
void migrateChat( void migrateChat(
not_null<ChatData*> chat, not_null<ChatData*> chat,
@ -459,7 +456,7 @@ private:
mtpRequestId req); mtpRequestId req);
void gotUserFull( void gotUserFull(
not_null<UserData*> user, not_null<UserData*> user,
const MTPUserFull &result, const MTPusers_UserFull &result,
mtpRequestId req); mtpRequestId req);
void applyLastParticipantsList( void applyLastParticipantsList(
not_null<ChannelData*> channel, not_null<ChannelData*> channel,

View file

@ -487,7 +487,7 @@ void DeleteMessagesBox::deleteAndClear() {
_moderateInChannel->session().api().request( _moderateInChannel->session().api().request(
MTPchannels_ReportSpam( MTPchannels_ReportSpam(
_moderateInChannel->inputChannel, _moderateInChannel->inputChannel,
_moderateFrom->inputUser, _moderateFrom->input,
MTP_vector<MTPint>(1, MTP_int(_ids[0].msg))) MTP_vector<MTPint>(1, MTP_int(_ids[0].msg)))
).send(); ).send();
} }

View file

@ -367,7 +367,8 @@ StickerSetBox::Inner::Inner(
, _input(set) , _input(set)
, _previewTimer([=] { showPreview(); }) { , _previewTimer([=] { showPreview(); }) {
_api.request(MTPmessages_GetStickerSet( _api.request(MTPmessages_GetStickerSet(
Data::InputStickerSet(_input) Data::InputStickerSet(_input),
MTP_int(0) // hash
)).done([=](const MTPmessages_StickerSet &result) { )).done([=](const MTPmessages_StickerSet &result) {
gotSet(result); gotSet(result);
}).fail([=](const MTP::Error &error) { }).fail([=](const MTP::Error &error) {
@ -463,6 +464,8 @@ void StickerSetBox::Inner::gotSet(const MTPmessages_StickerSet &set) {
set->setThumbnail(_setThumbnail); set->setThumbnail(_setThumbnail);
} }
}); });
}, [&](const MTPDmessages_stickerSetNotModified &data) {
LOG(("API Error: Unexpected messages.stickerSetNotModified."));
}); });
if (_pack.isEmpty()) { if (_pack.isEmpty()) {

View file

@ -1887,11 +1887,16 @@ void StickersBox::Inner::handleMegagroupSetAddressChange() {
} }
} else if (!_megagroupSetRequestId) { } else if (!_megagroupSetRequestId) {
_megagroupSetRequestId = _api.request(MTPmessages_GetStickerSet( _megagroupSetRequestId = _api.request(MTPmessages_GetStickerSet(
MTP_inputStickerSetShortName(MTP_string(text)) MTP_inputStickerSetShortName(MTP_string(text)),
MTP_int(0) // hash
)).done([=](const MTPmessages_StickerSet &result) { )).done([=](const MTPmessages_StickerSet &result) {
_megagroupSetRequestId = 0; _megagroupSetRequestId = 0;
auto set = session().data().stickers().feedSetFull(result); result.match([&](const MTPDmessages_stickerSet &data) {
setMegagroupSelectedSet(set->identifier()); 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) { }).fail([=](const MTP::Error &error) {
_megagroupSetRequestId = 0; _megagroupSetRequestId = 0;
setMegagroupSelectedSet({}); setMegagroupSelectedSet({});

View file

@ -47,10 +47,13 @@ void DicePack::load() {
return; return;
} }
_requestId = _session->api().request(MTPmessages_GetStickerSet( _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) { )).done([=](const MTPmessages_StickerSet &result) {
result.match([&](const MTPDmessages_stickerSet &data) { result.match([&](const MTPDmessages_stickerSet &data) {
applySet(data); applySet(data);
}, [](const MTPDmessages_stickerSetNotModified &) {
LOG(("API Error: Unexpected messages.stickerSetNotModified."));
}); });
}).fail([=](const MTP::Error &error) { }).fail([=](const MTP::Error &error) {
_requestId = 0; _requestId = 0;

View file

@ -231,12 +231,15 @@ void EmojiPack::refresh() {
return; return;
} }
_requestId = _session->api().request(MTPmessages_GetStickerSet( _requestId = _session->api().request(MTPmessages_GetStickerSet(
MTP_inputStickerSetAnimatedEmoji() MTP_inputStickerSetAnimatedEmoji(),
MTP_int(0) // hash
)).done([=](const MTPmessages_StickerSet &result) { )).done([=](const MTPmessages_StickerSet &result) {
_requestId = 0; _requestId = 0;
refreshAnimations(); refreshAnimations();
result.match([&](const MTPDmessages_stickerSet &data) { result.match([&](const MTPDmessages_stickerSet &data) {
applySet(data); applySet(data);
}, [](const MTPDmessages_stickerSetNotModified &) {
LOG(("API Error: Unexpected messages.stickerSetNotModified."));
}); });
}).fail([=](const MTP::Error &error) { }).fail([=](const MTP::Error &error) {
_requestId = 0; _requestId = 0;
@ -249,12 +252,15 @@ void EmojiPack::refreshAnimations() {
return; return;
} }
_animationsRequestId = _session->api().request(MTPmessages_GetStickerSet( _animationsRequestId = _session->api().request(MTPmessages_GetStickerSet(
MTP_inputStickerSetAnimatedEmojiAnimations() MTP_inputStickerSetAnimatedEmojiAnimations(),
MTP_int(0) // hash
)).done([=](const MTPmessages_StickerSet &result) { )).done([=](const MTPmessages_StickerSet &result) {
_animationsRequestId = 0; _animationsRequestId = 0;
refreshDelayed(); refreshDelayed();
result.match([&](const MTPDmessages_stickerSet &data) { result.match([&](const MTPDmessages_stickerSet &data) {
applyAnimationsSet(data); applyAnimationsSet(data);
}, [](const MTPDmessages_stickerSetNotModified &) {
LOG(("API Error: Unexpected messages.stickerSetNotModified."));
}); });
}).fail([=](const MTP::Error &error) { }).fail([=](const MTP::Error &error) {
_animationsRequestId = 0; _animationsRequestId = 0;

View file

@ -2778,16 +2778,21 @@ void StickersListWidget::refreshMegagroupStickers(GroupStickersPlace place) {
} }
_megagroupSetIdRequested = set.id; _megagroupSetIdRequested = set.id;
_api.request(MTPmessages_GetStickerSet( _api.request(MTPmessages_GetStickerSet(
Data::InputStickerSet(set) Data::InputStickerSet(set),
MTP_int(0) // hash
)).done([=](const MTPmessages_StickerSet &result) { )).done([=](const MTPmessages_StickerSet &result) {
if (const auto set = session().data().stickers().feedSetFull(result)) { result.match([&](const MTPDmessages_stickerSet &data) {
refreshStickers(); if (const auto set = session().data().stickers().feedSetFull(data)) {
if (set->id == _megagroupSetIdRequested) { refreshStickers();
_megagroupSetIdRequested = 0; if (set->id == _megagroupSetIdRequested) {
} else { _megagroupSetIdRequested = 0;
LOG(("API Error: Got different set.")); } else {
LOG(("API Error: Got different set."));
}
} }
} }, [](const MTPDmessages_stickerSetNotModified &) {
LOG(("API Error: Unexpected messages.stickerSetNotModified."));
});
}).send(); }).send();
} }
@ -3117,9 +3122,14 @@ void StickersListWidget::installSet(uint64 setId) {
const auto input = set->mtpInput(); const auto input = set->mtpInput();
if ((set->flags & SetFlag::NotLoaded) || set->stickers.empty()) { if ((set->flags & SetFlag::NotLoaded) || set->stickers.empty()) {
_api.request(MTPmessages_GetStickerSet( _api.request(MTPmessages_GetStickerSet(
input input,
MTP_int(0) // hash
)).done([=](const MTPmessages_StickerSet &result) { )).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); sendInstallRequest(setId, input);
}).send(); }).send();
} else { } else {

View file

@ -140,6 +140,7 @@ struct FileReferenceAccumulator {
void push(const MTPmessages_StickerSet &data) { void push(const MTPmessages_StickerSet &data) {
data.match([&](const MTPDmessages_stickerSet &data) { data.match([&](const MTPDmessages_stickerSet &data) {
push(data.vdocuments()); push(data.vdocuments());
}, [](const MTPDmessages_stickerSetNotModified &data) {
}); });
} }
void push(const MTPmessages_SavedGifs &data) { void push(const MTPmessages_SavedGifs &data) {

View file

@ -188,7 +188,6 @@ bool UserData::hasCalls() const {
namespace Data { namespace Data {
void ApplyUserUpdate(not_null<UserData*> user, const MTPDuserFull &update) { void ApplyUserUpdate(not_null<UserData*> user, const MTPDuserFull &update) {
user->owner().processUser(update.vuser());
if (const auto photo = update.vprofile_photo()) { if (const auto photo = update.vprofile_photo()) {
user->owner().processPhoto(*photo); user->owner().processPhoto(*photo);
} }

View file

@ -518,25 +518,27 @@ void Stickers::requestSetToPushFaved(not_null<DocumentData*> document) {
setIsFaved(document, std::move(list)); setIsFaved(document, std::move(list));
}; };
session().api().request(MTPmessages_GetStickerSet( session().api().request(MTPmessages_GetStickerSet(
Data::InputStickerSet(document->sticker()->set) Data::InputStickerSet(document->sticker()->set),
MTP_int(0) // hash
)).done([=](const MTPmessages_StickerSet &result) { )).done([=](const MTPmessages_StickerSet &result) {
Expects(result.type() == mtpc_messages_stickerSet); result.match([&](const MTPDmessages_stickerSet &data) {
auto list = std::vector<not_null<EmojiPtr>>();
auto list = std::vector<not_null<EmojiPtr>>(); list.reserve(data.vpacks().v.size());
auto &d = result.c_messages_stickerSet(); for (const auto &mtpPack : data.vpacks().v) {
list.reserve(d.vpacks().v.size()); auto &pack = mtpPack.c_stickerPack();
for (const auto &mtpPack : d.vpacks().v) { for (const auto &documentId : pack.vdocuments().v) {
auto &pack = mtpPack.c_stickerPack(); if (documentId.v == document->id) {
for (const auto &documentId : pack.vdocuments().v) { if (const auto emoji = Ui::Emoji::Find(qs(mtpPack.c_stickerPack().vemoticon()))) {
if (documentId.v == document->id) { list.emplace_back(emoji);
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) { }).fail([=](const MTP::Error &error) {
// Perhaps this is a deleted sticker pack. Add anyway. // Perhaps this is a deleted sticker pack. Add anyway.
addAnyway({}); addAnyway({});
@ -1230,11 +1232,9 @@ StickersSet *Stickers::feedSet(const MTPDstickerSet &data) {
return it->second.get(); return it->second.get();
} }
StickersSet *Stickers::feedSetFull(const MTPmessages_StickerSet &data) { StickersSet *Stickers::feedSetFull(const MTPDmessages_stickerSet &d) {
Expects(data.type() == mtpc_messages_stickerSet); Expects(d.vset().type() == mtpc_stickerSet);
Expects(data.c_messages_stickerSet().vset().type() == mtpc_stickerSet);
const auto &d = data.c_messages_stickerSet();
const auto &s = d.vset().c_stickerSet(); const auto &s = d.vset().c_stickerSet();
auto &sets = setsRef(); auto &sets = setsRef();
@ -1353,8 +1353,7 @@ StickersSet *Stickers::feedSetFull(const MTPmessages_StickerSet &data) {
return set; return set;
} }
void Stickers::newSetReceived(const MTPmessages_StickerSet &data) { void Stickers::newSetReceived(const MTPDmessages_stickerSet &set) {
const auto &set = data.c_messages_stickerSet();
const auto &s = set.vset().c_stickerSet(); const auto &s = set.vset().c_stickerSet();
if (!s.vinstalled_date()) { if (!s.vinstalled_date()) {
LOG(("API Error: " LOG(("API Error: "
@ -1374,7 +1373,7 @@ void Stickers::newSetReceived(const MTPmessages_StickerSet &data) {
order.insert(insertAtIndex, s.vid().v); order.insert(insertAtIndex, s.vid().v);
} }
feedSetFull(data); feedSetFull(set);
} }
QString Stickers::getSetTitle(const MTPDstickerSet &s) { QString Stickers::getSetTitle(const MTPDstickerSet &s) {

View file

@ -198,8 +198,8 @@ public:
not_null<DocumentData*> document); not_null<DocumentData*> document);
StickersSet *feedSet(const MTPDstickerSet &data); StickersSet *feedSet(const MTPDstickerSet &data);
StickersSet *feedSetFull(const MTPmessages_StickerSet &data); StickersSet *feedSetFull(const MTPDmessages_stickerSet &d);
void newSetReceived(const MTPmessages_StickerSet &data); void newSetReceived(const MTPDmessages_stickerSet &set);
QString getSetTitle(const MTPDstickerSet &s); QString getSetTitle(const MTPDstickerSet &s);

View file

@ -1283,15 +1283,14 @@ std::map<MessageId, Message> ParseMessagesList(
return result; return result;
} }
PersonalInfo ParsePersonalInfo(const MTPUserFull &data) { PersonalInfo ParsePersonalInfo(const MTPDusers_userFull &data) {
Expects(data.type() == mtpc_userFull);
const auto &fields = data.c_userFull();
auto result = PersonalInfo(); auto result = PersonalInfo();
result.user = ParseUser(fields.vuser()); result.user = ParseUser(data.vusers().v[0]);
if (const auto about = fields.vabout()) { data.vfull_user().match([&](const MTPDuserFull &data) {
result.bio = ParseString(*about); if (const auto about = data.vabout()) {
} result.bio = ParseString(*about);
}
});
return result; return result;
} }

View file

@ -255,7 +255,7 @@ struct PersonalInfo {
Utf8String bio; Utf8String bio;
}; };
PersonalInfo ParsePersonalInfo(const MTPUserFull &data); PersonalInfo ParsePersonalInfo(const MTPDusers_userFull &data);
struct TopPeer { struct TopPeer {
Peer peer; Peer peer;

View file

@ -674,15 +674,14 @@ void ApiWrap::startMainSession(FnMut<void()> done) {
void ApiWrap::requestPersonalInfo(FnMut<void(Data::PersonalInfo&&)> done) { void ApiWrap::requestPersonalInfo(FnMut<void(Data::PersonalInfo&&)> done) {
mainRequest(MTPusers_GetFullUser( mainRequest(MTPusers_GetFullUser(
_user _user
)).done([=, done = std::move(done)](const MTPUserFull &result) mutable { )).done([=, done = std::move(done)](const MTPusers_UserFull &result) mutable {
Expects(result.type() == mtpc_userFull); result.match([&](const MTPDusers_userFull &data) {
if (!data.vusers().v.empty()) {
const auto &full = result.c_userFull(); done(Data::ParsePersonalInfo(data));
if (full.vuser().type() == mtpc_user) { } else {
done(Data::ParsePersonalInfo(result)); error("Bad user type.");
} else { }
error("Bad user type."); });
}
}).send(); }).send();
} }

View file

@ -220,11 +220,8 @@ PeerId Session::userPeerId() const {
return _user->id; return _user->id;
} }
bool Session::validateSelf(const MTPUser &user) { bool Session::validateSelf(UserId id) {
if (user.type() != mtpc_user || !user.c_user().is_self()) { if (id != userId()) {
LOG(("API Error: bad self user received."));
return false;
} else if (UserId(user.c_user().vid()) != userId()) {
LOG(("Auth Error: wrong self user received.")); LOG(("Auth Error: wrong self user received."));
crl::on_main(this, [=] { _account->logOut(); }); crl::on_main(this, [=] { _account->logOut(); });
return false; return false;

View file

@ -82,7 +82,7 @@ public:
[[nodiscard]] not_null<UserData*> user() const { [[nodiscard]] not_null<UserData*> user() const {
return _user; return _user;
} }
bool validateSelf(const MTPUser &user); bool validateSelf(UserId id);
[[nodiscard]] Data::Changes &changes() const { [[nodiscard]] Data::Changes &changes() const {
return *_changes; return *_changes;