From 0cc21e5ca2dcbc7ad312bb7184300406df61497d Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 2 Dec 2025 12:23:29 +0400 Subject: [PATCH] Update API scheme on layer 220. --- Telegram/SourceFiles/api/api_premium.cpp | 16 +++++++++++- Telegram/SourceFiles/data/data_session.cpp | 6 ----- Telegram/SourceFiles/data/data_star_gift.h | 16 ++++++++++++ Telegram/SourceFiles/data/data_web_page.h | 3 --- .../view/media/history_view_unique_gift.cpp | 7 +++-- .../view/media/history_view_unique_gift.h | 3 +-- .../view/media/history_view_web_page.cpp | 12 +++------ Telegram/SourceFiles/mtproto/scheme/api.tl | 26 ++++++++++++------- 8 files changed, 56 insertions(+), 33 deletions(-) diff --git a/Telegram/SourceFiles/api/api_premium.cpp b/Telegram/SourceFiles/api/api_premium.cpp index 1f061cc49b..029280537c 100644 --- a/Telegram/SourceFiles/api/api_premium.cpp +++ b/Telegram/SourceFiles/api/api_premium.cpp @@ -848,8 +848,22 @@ std::optional FromTL( const auto releasedBy = releasedById ? session->data().peer(releasedById).get() : nullptr; + const auto background = [&] { + if (!data.vbackground()) { + return std::shared_ptr(); + } + const auto &fields = data.vbackground()->data(); + using namespace Ui; + return std::make_shared( + Data::StarGiftBackground{ + .center = ColorFromSerialized(fields.vcenter_color()), + .edge = ColorFromSerialized(fields.vedge_color()), + .text = ColorFromSerialized(fields.vtext_color()), + }); + }; return std::optional(Data::StarGift{ .id = uint64(data.vid().v), + .background = background(), .stars = int64(data.vstars().v), .starsConverted = int64(data.vconvert_stars().v), .starsToUpgrade = int64(data.vupgrade_stars().value_or_empty()), @@ -964,7 +978,7 @@ std::optional FromTL( unique->originalDetails = FromTL(session, data); }); } - return std::make_optional(result); + return std::make_optional(std::move(result)); }); } diff --git a/Telegram/SourceFiles/data/data_session.cpp b/Telegram/SourceFiles/data/data_session.cpp index 05bf903cdc..34e81745ea 100644 --- a/Telegram/SourceFiles/data/data_session.cpp +++ b/Telegram/SourceFiles/data/data_session.cpp @@ -3986,12 +3986,6 @@ void Session::webpageApplyFields( auto auction = std::make_unique(); auction->auctionGift = std::make_shared(*gift); auction->endDate = data.vend_date().v; - auction->centerColor = Ui::ColorFromSerialized( - toUint(data.vcenter_color())); - auction->edgeColor = Ui::ColorFromSerialized( - toUint(data.vedge_color())); - auction->textColor = Ui::ColorFromSerialized( - toUint(data.vtext_color())); return auction; }, [](const auto &) -> WebPageAuctionPtr { return nullptr; }); } diff --git a/Telegram/SourceFiles/data/data_star_gift.h b/Telegram/SourceFiles/data/data_star_gift.h index a23208637c..c9d78bb16a 100644 --- a/Telegram/SourceFiles/data/data_star_gift.h +++ b/Telegram/SourceFiles/data/data_star_gift.h @@ -101,9 +101,25 @@ struct UniqueGift { [[nodiscard]] TextWithEntities FormatGiftResaleTon(const UniqueGift &gift); [[nodiscard]] TextWithEntities FormatGiftResaleAsked(const UniqueGift &gift); +struct StarGiftBackground { + QColor center; + QColor edge; + QColor text; + + [[nodiscard]] UniqueGiftBackdrop backdrop() const { + return { + .centerColor = center, + .edgeColor = edge, + .patternColor = edge, + .textColor = text, + }; + } +}; + struct StarGift { uint64 id = 0; std::shared_ptr unique; + std::shared_ptr background; int64 stars = 0; int64 starsConverted = 0; int64 starsToUpgrade = 0; diff --git a/Telegram/SourceFiles/data/data_web_page.h b/Telegram/SourceFiles/data/data_web_page.h index 2aaabeee98..4680a1065a 100644 --- a/Telegram/SourceFiles/data/data_web_page.h +++ b/Telegram/SourceFiles/data/data_web_page.h @@ -90,9 +90,6 @@ struct WebPageStickerSet { struct WebPageAuction { std::shared_ptr auctionGift; TimeId endDate = 0; - QColor centerColor; - QColor edgeColor; - QColor textColor; }; struct WebPageData { diff --git a/Telegram/SourceFiles/history/view/media/history_view_unique_gift.cpp b/Telegram/SourceFiles/history/view/media/history_view_unique_gift.cpp index 2004eef4bf..dc88910f8c 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_unique_gift.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_unique_gift.cpp @@ -543,8 +543,7 @@ auto GenerateAuctionPreview( not_null parent, Element *replacing, std::shared_ptr gift, - Data::UniqueGiftBackdrop backdrop, - TimeId endDate) + Data::UniqueGiftBackdrop backdrop) -> Fn, Fn)>)> { @@ -578,9 +577,9 @@ auto GenerateAuctionPreview( push(std::make_unique( tr::lng_boosts_list_tab_gifts( tr::now, - lt_count, + lt_count_decimal, all, - Ui::Text::WithEntities), + tr::marked), QMargins(0, 0, 0, st::webPageAuctionPreviewPadding.top()), [c = backdrop.textColor](const auto&) { return c; }, st::chatUniqueTextStyle)); diff --git a/Telegram/SourceFiles/history/view/media/history_view_unique_gift.h b/Telegram/SourceFiles/history/view/media/history_view_unique_gift.h index 32f207ae11..a6ecfeafa8 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_unique_gift.h +++ b/Telegram/SourceFiles/history/view/media/history_view_unique_gift.h @@ -57,8 +57,7 @@ class MediaGenericPart; not_null parent, Element *replacing, std::shared_ptr gift, - Data::UniqueGiftBackdrop backdrop, - TimeId endDate) + Data::UniqueGiftBackdrop backdrop) -> Fn, Fn)>)>; diff --git a/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp b/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp index ee87788e55..27c7753284 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp @@ -530,20 +530,16 @@ QSize WebPage::countOptimalSize() { }); } else if (!_attach && _data->auction) { const auto &gift = _data->auction->auctionGift; - const auto backdrop = Data::UniqueGiftBackdrop{ - .centerColor = _data->auction->centerColor, - .edgeColor = _data->auction->edgeColor, - .patternColor = _data->auction->edgeColor, - .textColor = _data->auction->textColor, - }; + const auto backdrop = gift->background + ? gift->background->backdrop() + : Data::UniqueGiftBackdrop(); _attach = std::make_unique( _parent, GenerateAuctionPreview( _parent, nullptr, gift, - backdrop, - _data->auction->endDate), + backdrop), MediaGenericDescriptor{ .maxWidth = st::msgServiceGiftPreview, .paintBgFactory = [=] { diff --git a/Telegram/SourceFiles/mtproto/scheme/api.tl b/Telegram/SourceFiles/mtproto/scheme/api.tl index 176cdcadf7..bcaba61fc8 100644 --- a/Telegram/SourceFiles/mtproto/scheme/api.tl +++ b/Telegram/SourceFiles/mtproto/scheme/api.tl @@ -186,7 +186,7 @@ messageActionRequestedPeerSentMe#93b31848 button_id:int peers:Vector = WebPageAttribute; webPageAttributeUniqueStarGift#cf6f6db8 gift:StarGift = WebPageAttribute; webPageAttributeStarGiftCollection#31cad303 icons:Vector = WebPageAttribute; -webPageAttributeStarGiftAuction#34986ab gift:StarGift end_date:int center_color:int edge_color:int text_color:int = WebPageAttribute; +webPageAttributeStarGiftAuction#1c641c2 gift:StarGift end_date:int = WebPageAttribute; messages.votesList#4899484e flags:# count:int votes:Vector chats:Vector users:Vector next_offset:flags.0?string = messages.VotesList; @@ -1916,8 +1916,8 @@ 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#1b9a4d7f flags:# limited:flags.0?true sold_out:flags.1?true birthday:flags.2?true require_premium:flags.7?true limited_per_user:flags.8?true peer_color_available:flags.10?true auction:flags.11?true id:long sticker:Document stars:long availability_remains:flags.0?int availability_total:flags.0?int availability_resale:flags.4?long convert_stars:long first_sale_date:flags.1?int last_sale_date:flags.1?int upgrade_stars:flags.3?long resell_min_stars:flags.4?long title:flags.5?string released_by:flags.6?Peer per_user_total:flags.8?int per_user_remains:flags.8?int locked_until_date:flags.9?int auction_slug:flags.11?string gifts_per_round:flags.11?int = StarGift; -starGiftUnique#9f2fb096 flags:# require_premium:flags.6?true resale_ton_only:flags.7?true theme_available:flags.9?true id:long gift_id:long title:string slug:string num:int owner_id:flags.0?Peer owner_name:flags.1?string owner_address:flags.2?string attributes:Vector availability_issued:int availability_total:int gift_address:flags.3?string resell_amount:flags.4?Vector released_by:flags.5?Peer value_amount:flags.8?long value_currency:flags.8?string theme_peer:flags.10?Peer peer_color:flags.11?PeerColor host_id:flags.12?Peer offer_min_stars:flags.13?int = StarGift; +starGift#313a9547 flags:# limited:flags.0?true sold_out:flags.1?true birthday:flags.2?true require_premium:flags.7?true limited_per_user:flags.8?true peer_color_available:flags.10?true auction:flags.11?true id:long sticker:Document stars:long availability_remains:flags.0?int availability_total:flags.0?int availability_resale:flags.4?long convert_stars:long first_sale_date:flags.1?int last_sale_date:flags.1?int upgrade_stars:flags.3?long resell_min_stars:flags.4?long title:flags.5?string released_by:flags.6?Peer per_user_total:flags.8?int per_user_remains:flags.8?int locked_until_date:flags.9?int auction_slug:flags.11?string gifts_per_round:flags.11?int auction_start_date:flags.11?int upgrade_variants:flags.12?int background:flags.13?StarGiftBackground = StarGift; +starGiftUnique#569d64c9 flags:# require_premium:flags.6?true resale_ton_only:flags.7?true theme_available:flags.9?true id:long gift_id:long title:string slug:string num:int owner_id:flags.0?Peer owner_name:flags.1?string owner_address:flags.2?string attributes:Vector availability_issued:int availability_total:int gift_address:flags.3?string resell_amount:flags.4?Vector released_by:flags.5?Peer value_amount:flags.8?long value_currency:flags.8?string value_usd_amount:flags.8?long theme_peer:flags.10?Peer peer_color:flags.11?PeerColor host_id:flags.12?Peer offer_min_stars:flags.13?int = StarGift; payments.starGiftsNotModified#a388a368 = payments.StarGifts; payments.starGifts#2ed82995 hash:int gifts:Vector chats:Vector users:Vector = payments.StarGifts; @@ -1966,7 +1966,7 @@ payments.uniqueStarGift#416c56e8 gift:StarGift chats:Vector users:Vector users:Vector = messages.WebPagePreview; -savedStarGift#8983a452 flags:# name_hidden:flags.0?true unsaved:flags.5?true refunded:flags.9?true can_upgrade:flags.10?true pinned_to_top:flags.12?true upgrade_separate:flags.17?true from_id:flags.1?Peer date:int gift:StarGift message:flags.2?TextWithEntities msg_id:flags.3?int saved_id:flags.11?long convert_stars:flags.4?long upgrade_stars:flags.6?long can_export_at:flags.7?int transfer_stars:flags.8?long can_transfer_at:flags.13?int can_resell_at:flags.14?int collection_id:flags.15?Vector prepaid_upgrade_hash:flags.16?string drop_original_details_stars:flags.18?long = SavedStarGift; +savedStarGift#ead6805e flags:# name_hidden:flags.0?true unsaved:flags.5?true refunded:flags.9?true can_upgrade:flags.10?true pinned_to_top:flags.12?true upgrade_separate:flags.17?true from_id:flags.1?Peer date:int gift:StarGift message:flags.2?TextWithEntities msg_id:flags.3?int saved_id:flags.11?long convert_stars:flags.4?long upgrade_stars:flags.6?long can_export_at:flags.7?int transfer_stars:flags.8?long can_transfer_at:flags.13?int can_resell_at:flags.14?int collection_id:flags.15?Vector prepaid_upgrade_hash:flags.16?string drop_original_details_stars:flags.18?long gift_num:flags.19?int = SavedStarGift; payments.savedStarGifts#95f389b1 flags:# count:int chat_notifications_enabled:flags.1?Bool gifts:Vector next_offset:flags.0?string chats:Vector users:Vector = payments.SavedStarGifts; @@ -2066,21 +2066,21 @@ recentStory#711d692d flags:# live:flags.0?true max_id:flags.1?int = RecentStory; auctionBidLevel#310240cc pos:int amount:long date:int = AuctionBidLevel; starGiftAuctionStateNotModified#fe333952 = StarGiftAuctionState; -starGiftAuctionState#5db04f4b version:int start_date:int end_date:int min_bid_amount:long bid_levels:Vector top_bidders:Vector next_round_at:int gifts_left:int current_round:int total_rounds:int = StarGiftAuctionState; +starGiftAuctionState#771a4e66 version:int start_date:int end_date:int min_bid_amount:long bid_levels:Vector top_bidders:Vector next_round_at:int last_gift_num:int gifts_left:int current_round:int total_rounds:int rounds:Vector = StarGiftAuctionState; starGiftAuctionStateFinished#7d967c3a start_date:int end_date:int average_price:long = StarGiftAuctionState; starGiftAuctionUserState#2eeed1c4 flags:# returned:flags.1?true bid_amount:flags.0?long bid_date:flags.0?int min_bid_amount:flags.0?long bid_peer:flags.0?Peer acquired_count:int = StarGiftAuctionUserState; -payments.starGiftAuctionState#e98e474 gift:StarGift state:StarGiftAuctionState user_state:StarGiftAuctionUserState timeout:int users:Vector = payments.StarGiftAuctionState; +payments.starGiftAuctionState#6b39f4ec gift:StarGift state:StarGiftAuctionState user_state:StarGiftAuctionUserState timeout:int users:Vector chats:Vector = payments.StarGiftAuctionState; -starGiftAuctionAcquiredGift#ab60e20b flags:# name_hidden:flags.0?true peer:Peer date:int bid_amount:long round:int pos:int message:flags.1?TextWithEntities = StarGiftAuctionAcquiredGift; +starGiftAuctionAcquiredGift#42b00348 flags:# name_hidden:flags.0?true peer:Peer date:int bid_amount:long round:int pos:int message:flags.1?TextWithEntities gift_num:flags.2?int = StarGiftAuctionAcquiredGift; payments.starGiftAuctionAcquiredGifts#7d5bd1f0 gifts:Vector users:Vector chats:Vector = payments.StarGiftAuctionAcquiredGifts; starGiftActiveAuctionState#d31bc45d gift:StarGift state:StarGiftAuctionState user_state:StarGiftAuctionUserState = StarGiftActiveAuctionState; payments.starGiftActiveAuctionsNotModified#db33dad0 = payments.StarGiftActiveAuctions; -payments.starGiftActiveAuctions#97f187d8 auctions:Vector users:Vector = payments.StarGiftActiveAuctions; +payments.starGiftActiveAuctions#aef6abbc auctions:Vector users:Vector chats:Vector = payments.StarGiftActiveAuctions; inputStarGiftAuction#2e16c98 gift_id:long = InputStarGiftAuction; inputStarGiftAuctionSlug#7ab58308 slug:string = InputStarGiftAuction; @@ -2098,6 +2098,13 @@ inputPasskeyResponseLogin#c31fc14a client_data:DataJSON authenticator_data:bytes inputPasskeyCredentialPublicKey#3c27b78f id:string raw_id:string response:InputPasskeyResponse = InputPasskeyCredential; +starGiftBackground#aff56398 center_color:int edge_color:int text_color:int = StarGiftBackground; + +starGiftAuctionRound#3aae0528 num:int duration:int = StarGiftAuctionRound; +starGiftAuctionRoundExtendable#aa021e5 num:int duration:int extend_top:int extend_window:int = StarGiftAuctionRound; + +payments.starGiftUpgradeAttributes#46c6e36f attributes:Vector = payments.StarGiftUpgradeAttributes; + ---functions--- invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X; @@ -2736,6 +2743,7 @@ payments.getStarGiftAuctionAcquiredGifts#6ba2cbec gift_id:long = payments.StarGi payments.getStarGiftActiveAuctions#a5d0514d hash:long = payments.StarGiftActiveAuctions; payments.resolveStarGiftOffer#e9ce781c flags:# decline:flags.0?true offer_msg_id:int = Updates; payments.sendStarGiftOffer#8fb86b41 flags:# peer:InputPeer slug:string price:StarsAmount duration:int random_id:long allow_paid_stars:flags.0?long = Updates; +payments.getStarGiftUpgradeAttributes#6d038b58 gift_id:long = payments.StarGiftUpgradeAttributes; 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;