From ba34d92cd3fdb70ccef677dd2c7b39c43294bbb9 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 7 Jan 2025 09:41:41 +0400 Subject: [PATCH] Update API scheme to layer 197. --- Telegram/SourceFiles/api/api_premium.cpp | 5 ++++- Telegram/SourceFiles/data/data_file_origin.cpp | 18 ++++++++++++++++++ Telegram/SourceFiles/data/data_session.cpp | 2 ++ Telegram/SourceFiles/data/data_star_gift.h | 2 ++ Telegram/SourceFiles/data/data_story.cpp | 5 +++++ .../history_view_webpage_processor.cpp | 8 ++++++-- Telegram/SourceFiles/mtproto/scheme/api.tl | 15 +++++++++++---- 7 files changed, 48 insertions(+), 7 deletions(-) diff --git a/Telegram/SourceFiles/api/api_premium.cpp b/Telegram/SourceFiles/api/api_premium.cpp index 682f34cde..c18beafa5 100644 --- a/Telegram/SourceFiles/api/api_premium.cpp +++ b/Telegram/SourceFiles/api/api_premium.cpp @@ -805,8 +805,11 @@ std::optional FromTL( auto result = Data::StarGift{ .id = uint64(data.vid().v), .unique = std::make_shared(Data::UniqueGift{ + .slug = qs(data.vslug()), .title = qs(data.vtitle()), - .ownerId = peerFromUser(UserId(data.vowner_id().v)), + .ownerName = qs(data.vowner_name().value_or_empty()), + .ownerId = peerFromUser( + UserId(data.vowner_id().value_or_empty())), .number = data.vnum().v, .model = *model, .pattern = *pattern, diff --git a/Telegram/SourceFiles/data/data_file_origin.cpp b/Telegram/SourceFiles/data/data_file_origin.cpp index 48f2be854..06c39cb91 100644 --- a/Telegram/SourceFiles/data/data_file_origin.cpp +++ b/Telegram/SourceFiles/data/data_file_origin.cpp @@ -59,6 +59,24 @@ struct FileReferenceAccumulator { push(data.vdocuments()); }, [&](const MTPDwebPageAttributeStickerSet &data) { push(data.vstickers()); + }, [&](const MTPDwebPageAttributeUniqueStarGift &data) { + push(data.vgift()); + }); + } + void push(const MTPStarGift &data) { + data.match([&](const MTPDstarGift &data) { + push(data.vsticker()); + }, [&](const MTPDstarGiftUnique &data) { + push(data.vattributes()); + }); + } + void push(const MTPStarGiftAttribute &data) { + data.match([&](const MTPDstarGiftAttributeModel &data) { + push(data.vdocument()); + }, [&](const MTPDstarGiftAttributePattern &data) { + push(data.vdocument()); + }, [&](const MTPDstarGiftAttributeBackdrop &data) { + }, [&](const MTPDstarGiftAttributeOriginalDetails &data) { }); } void push(const MTPWebPage &data) { diff --git a/Telegram/SourceFiles/data/data_session.cpp b/Telegram/SourceFiles/data/data_session.cpp index 4927e271d..4493926c3 100644 --- a/Telegram/SourceFiles/data/data_session.cpp +++ b/Telegram/SourceFiles/data/data_session.cpp @@ -3572,6 +3572,8 @@ void Session::webpageApplyFields( return (DocumentData*)nullptr; }, [](const MTPDwebPageAttributeStickerSet &) { return (DocumentData*)nullptr; + }, [](const MTPDwebPageAttributeUniqueStarGift &) { + return (DocumentData*)nullptr; }); if (result) { return result; diff --git a/Telegram/SourceFiles/data/data_star_gift.h b/Telegram/SourceFiles/data/data_star_gift.h index 3f7578de1..1dea80468 100644 --- a/Telegram/SourceFiles/data/data_star_gift.h +++ b/Telegram/SourceFiles/data/data_star_gift.h @@ -37,7 +37,9 @@ struct UniqueGiftOriginalDetails { }; struct UniqueGift { + QString slug; QString title; + QString ownerName; PeerId ownerId = 0; int number = 0; int starsForTransfer = -1; diff --git a/Telegram/SourceFiles/data/data_story.cpp b/Telegram/SourceFiles/data/data_story.cpp index 70a37ac21..8aec4e166 100644 --- a/Telegram/SourceFiles/data/data_story.cpp +++ b/Telegram/SourceFiles/data/data_story.cpp @@ -87,6 +87,7 @@ using UpdateFlag = StoryUpdate::Flag; }, [&](const MTPDmediaAreaChannelPost &data) { }, [&](const MTPDmediaAreaUrl &data) { }, [&](const MTPDmediaAreaWeather &data) { + }, [&](const MTPDmediaAreaStarGift &data) { }, [&](const MTPDinputMediaAreaChannelPost &data) { LOG(("API Error: Unexpected inputMediaAreaChannelPost from API.")); }, [&](const MTPDinputMediaAreaVenue &data) { @@ -110,6 +111,7 @@ using UpdateFlag = StoryUpdate::Flag; }, [&](const MTPDmediaAreaChannelPost &data) { }, [&](const MTPDmediaAreaUrl &data) { }, [&](const MTPDmediaAreaWeather &data) { + }, [&](const MTPDmediaAreaStarGift &data) { }, [&](const MTPDinputMediaAreaChannelPost &data) { LOG(("API Error: Unexpected inputMediaAreaChannelPost from API.")); }, [&](const MTPDinputMediaAreaVenue &data) { @@ -133,6 +135,7 @@ using UpdateFlag = StoryUpdate::Flag; }); }, [&](const MTPDmediaAreaUrl &data) { }, [&](const MTPDmediaAreaWeather &data) { + }, [&](const MTPDmediaAreaStarGift &data) { }, [&](const MTPDinputMediaAreaChannelPost &data) { LOG(("API Error: Unexpected inputMediaAreaChannelPost from API.")); }, [&](const MTPDinputMediaAreaVenue &data) { @@ -154,6 +157,7 @@ using UpdateFlag = StoryUpdate::Flag; .url = qs(data.vurl()), }); }, [&](const MTPDmediaAreaWeather &data) { + }, [&](const MTPDmediaAreaStarGift &data) { }, [&](const MTPDinputMediaAreaChannelPost &data) { LOG(("API Error: Unexpected inputMediaAreaChannelPost from API.")); }, [&](const MTPDinputMediaAreaVenue &data) { @@ -180,6 +184,7 @@ using UpdateFlag = StoryUpdate::Flag; -274., 1'000'000.)), }); + }, [&](const MTPDmediaAreaStarGift &data) { }, [&](const MTPDinputMediaAreaChannelPost &data) { LOG(("API Error: Unexpected inputMediaAreaChannelPost from API.")); }, [&](const MTPDinputMediaAreaVenue &data) { diff --git a/Telegram/SourceFiles/history/view/controls/history_view_webpage_processor.cpp b/Telegram/SourceFiles/history/view/controls/history_view_webpage_processor.cpp index 214de059c..379ffb92e 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_webpage_processor.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_webpage_processor.cpp @@ -158,11 +158,15 @@ void WebpageResolver::request(const QString &link, bool force) { MTP_flags(0), MTP_string(link), MTPVector() - )).done([=](const MTPMessageMedia &result, mtpRequestId requestId) { + )).done([=]( + const MTPmessages_WebPagePreview &result, + mtpRequestId requestId) { if (_requestId == requestId) { _requestId = 0; } - result.match([=](const MTPDmessageMediaWebPage &data) { + const auto &data = result.data(); + _session->data().processUsers(data.vusers()); + data.vmedia().match([=](const MTPDmessageMediaWebPage &data) { done(data); }, [&](const auto &d) { fail(); diff --git a/Telegram/SourceFiles/mtproto/scheme/api.tl b/Telegram/SourceFiles/mtproto/scheme/api.tl index 96d3fce82..1812e8004 100644 --- a/Telegram/SourceFiles/mtproto/scheme/api.tl +++ b/Telegram/SourceFiles/mtproto/scheme/api.tl @@ -1268,6 +1268,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; webPageAttributeStory#2e94c3e7 flags:# peer:Peer id:int story:flags.0?StoryItem = WebPageAttribute; webPageAttributeStickerSet#50cc03d3 flags:# emojis:flags.0?true text_color:flags.1?true stickers:Vector = WebPageAttribute; +webPageAttributeUniqueStarGift#cf6f6db8 gift:StarGift = WebPageAttribute; messages.votesList#4899484e flags:# count:int votes:Vector chats:Vector users:Vector next_offset:flags.0?string = messages.VotesList; @@ -1640,6 +1641,7 @@ mediaAreaChannelPost#770416af coordinates:MediaAreaCoordinates channel_id:long m inputMediaAreaChannelPost#2271f2bf coordinates:MediaAreaCoordinates channel:InputChannel msg_id:int = MediaArea; mediaAreaUrl#37381085 coordinates:MediaAreaCoordinates url:string = MediaArea; mediaAreaWeather#49a6549c coordinates:MediaAreaCoordinates emoji:string temperature_c:double color:int = MediaArea; +mediaAreaStarGift#5787686d coordinates:MediaAreaCoordinates slug:string = MediaArea; peerStories#9a35e999 flags:# peer:Peer max_read_id:flags.0?int stories:Vector = PeerStories; @@ -1874,7 +1876,7 @@ starsGiveawayOption#94ce852a flags:# extended:flags.0?true default:flags.1?true starsGiveawayWinnersOption#54236209 flags:# default:flags.0?true users:int per_user_stars:long = StarsGiveawayWinnersOption; starGift#2cc73c8 flags:# limited:flags.0?true sold_out:flags.1?true birthday:flags.2?true id:long sticker:Document stars:long availability_remains:flags.0?int availability_total:flags.0?int convert_stars:long first_sale_date:flags.1?int last_sale_date:flags.1?int upgrade_stars:flags.3?long = StarGift; -starGiftUnique#6a1407cd id:long title:string num:int owner_id:long attributes:Vector availability_issued:int availability_total:int = StarGift; +starGiftUnique#3482f322 flags:# id:long title:string slug:string num:int owner_id:flags.0?long owner_name:flags.1?string attributes:Vector availability_issued:int availability_total:int = StarGift; payments.starGiftsNotModified#a388a368 = payments.StarGifts; payments.starGifts#901689ea hash:int gifts:Vector = payments.StarGifts; @@ -1922,6 +1924,10 @@ payments.starGiftUpgradePreview#167bd90b sample_attributes:Vector = users.Users; users.usersSlice#315a4974 count:int users:Vector = users.Users; +payments.uniqueStarGift#caa2f60b gift:StarGift users:Vector = payments.UniqueStarGift; + +messages.webPagePreview#b53e8b21 media:MessageMedia users:Vector = messages.WebPagePreview; + ---functions--- invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X; @@ -2140,7 +2146,7 @@ messages.reportEncryptedSpam#4b0c8c0f peer:InputEncryptedChat = Bool; messages.readMessageContents#36a73f77 id:Vector = messages.AffectedMessages; messages.getStickers#d5a5d3a1 emoticon:string hash:long = messages.Stickers; messages.getAllStickers#b8a0a1a8 hash:long = messages.AllStickers; -messages.getWebPagePreview#8b68b0cc flags:# message:string entities:flags.3?Vector = MessageMedia; +messages.getWebPagePreview#570d6f6f flags:# message:string entities:flags.3?Vector = messages.WebPagePreview; messages.exportChatInvite#a455de90 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 subscription_pricing:flags.5?StarsSubscriptionPricing = ExportedChatInvite; messages.checkChatInvite#3eadb1bb hash:string = ChatInvite; messages.importChatInvite#6c50051c hash:string = Updates; @@ -2466,7 +2472,7 @@ bots.checkDownloadFileParams#50077589 bot:InputUser file_name:string url:string bots.getAdminedBots#b0711d83 = Vector; bots.updateStarRefProgram#778b5ab3 flags:# bot:InputUser commission_permille:int duration_months:flags.0?int = StarRefProgram; bots.setCustomVerification#8b89dfbd flags:# enabled:flags.1?true bot:flags.0?InputUser peer:InputPeer custom_description:flags.2?string = Bool; -bots.getBotRecommendations#2855be61 flags:# bot:InputUser = users.Users; +bots.getBotRecommendations#a1b70815 bot:InputUser = users.Users; payments.getPaymentForm#37148dbb flags:# invoice:InputInvoice theme_params:flags.0?DataJSON = payments.PaymentForm; payments.getPaymentReceipt#2478d1cc peer:InputPeer msg_id:int = payments.PaymentReceipt; @@ -2512,6 +2518,7 @@ payments.getStarGiftUpgradePreview#9c9abcb1 gift_id:long = payments.StarGiftUpgr payments.upgradeStarGift#cf4f0781 flags:# keep_original_details:flags.0?true msg_id:int = Updates; payments.transferStarGift#333fb526 msg_id:int to_id:InputUser = Updates; payments.getUserStarGift#b502e4a5 msg_id:Vector = payments.UserStarGifts; +payments.getUniqueStarGift#a1974d72 slug:string = payments.UniqueStarGift; stickers.createStickerSet#9021ab67 flags:# masks:flags.0?true emojis:flags.5?true text_color:flags.6?true user_id:InputUser title:string short_name:string thumb:flags.2?InputDocument stickers:Vector software:flags.3?string = messages.StickerSet; stickers.removeStickerFromSet#f7760f51 sticker:InputDocument = messages.StickerSet; @@ -2632,4 +2639,4 @@ smsjobs.finishJob#4f1ebf24 flags:# job_id:string error:flags.0?string = Bool; fragment.getCollectibleInfo#be1e85ba collectible:InputCollectible = fragment.CollectibleInfo; -// LAYER 196 +// LAYER 197