3030#include " td/telegram/PhotoFormat.h"
3131#include " td/telegram/QuickReplyManager.h"
3232#include " td/telegram/StarGift.h"
33+ #include " td/telegram/StarGiftBackground.h"
34+ #include " td/telegram/StarGiftBackground.hpp"
3335#include " td/telegram/StickerFormat.h"
3436#include " td/telegram/StickersManager.h"
3537#include " td/telegram/StickersManager.hpp"
@@ -262,9 +264,7 @@ class WebPagesManager::WebPage {
262264 vector<StarGift> star_gifts_;
263265 WebPageInstantView instant_view_;
264266 int32 auction_end_date_ = 0 ;
265- int32 auction_center_color_ = 0 ;
266- int32 auction_edge_color_ = 0 ;
267- int32 auction_text_color_ = 0 ;
267+ unique_ptr<StarGiftBackground> gift_background_;
268268
269269 FileSourceId file_source_id_;
270270
@@ -291,8 +291,8 @@ class WebPagesManager::WebPage {
291291 bool has_sticker_ids = !sticker_ids_.empty ();
292292 bool has_theme_settings = !theme_settings_.is_empty ();
293293 bool has_star_gifts = !star_gifts_.empty ();
294- bool has_auction =
295- auction_end_date_ != 0 || auction_center_color_ != 0 || auction_edge_color_ != 0 || auction_text_color_ != 0 ;
294+ bool has_auction_end_date = auction_end_date_ != 0 ;
295+ bool has_gift_background = gift_background_ != nullptr ;
296296 BEGIN_STORE_FLAGS ();
297297 STORE_FLAG (has_type);
298298 STORE_FLAG (has_site_name);
@@ -314,7 +314,8 @@ class WebPagesManager::WebPage {
314314 STORE_FLAG (has_theme_settings);
315315 STORE_FLAG (has_star_gifts);
316316 STORE_FLAG (video_cover_photo_);
317- STORE_FLAG (has_auction);
317+ STORE_FLAG (has_auction_end_date);
318+ STORE_FLAG (has_gift_background);
318319 END_STORE_FLAGS ();
319320
320321 store (url_, storer);
@@ -369,11 +370,11 @@ class WebPagesManager::WebPage {
369370 if (has_star_gifts) {
370371 store (star_gifts_, storer);
371372 }
372- if (has_auction ) {
373+ if (has_auction_end_date ) {
373374 store (auction_end_date_, storer);
374- store (auction_center_color_, storer);
375- store (auction_edge_color_, storer);
376- store (auction_text_color_ , storer);
375+ }
376+ if (has_gift_background) {
377+ store (gift_background_ , storer);
377378 }
378379 }
379380
@@ -398,7 +399,8 @@ class WebPagesManager::WebPage {
398399 bool has_sticker_ids;
399400 bool has_theme_settings;
400401 bool has_star_gifts;
401- bool has_auction;
402+ bool has_auction_end_date;
403+ bool has_gift_background;
402404 BEGIN_PARSE_FLAGS ();
403405 PARSE_FLAG (has_type);
404406 PARSE_FLAG (has_site_name);
@@ -420,7 +422,8 @@ class WebPagesManager::WebPage {
420422 PARSE_FLAG (has_theme_settings);
421423 PARSE_FLAG (has_star_gifts);
422424 PARSE_FLAG (video_cover_photo_);
423- PARSE_FLAG (has_auction);
425+ PARSE_FLAG (has_auction_end_date);
426+ PARSE_FLAG (has_gift_background);
424427 END_PARSE_FLAGS ();
425428
426429 parse (url_, parser);
@@ -484,11 +487,11 @@ class WebPagesManager::WebPage {
484487 if (has_star_gifts) {
485488 parse (star_gifts_, parser);
486489 }
487- if (has_auction ) {
490+ if (has_auction_end_date ) {
488491 parse (auction_end_date_, parser);
489- parse (auction_center_color_, parser);
490- parse (auction_edge_color_, parser);
491- parse (auction_text_color_ , parser);
492+ }
493+ if (has_gift_background) {
494+ parse (gift_background_ , parser);
492495 }
493496
494497 if (has_instant_view) {
@@ -509,8 +512,7 @@ class WebPagesManager::WebPage {
509512 lhs.document_ == rhs.document_ && lhs.documents_ == rhs.documents_ &&
510513 lhs.theme_settings_ == rhs.theme_settings_ && lhs.story_full_ids_ == rhs.story_full_ids_ &&
511514 lhs.sticker_ids_ == rhs.sticker_ids_ && lhs.star_gifts_ == rhs.star_gifts_ &&
512- lhs.auction_end_date_ == rhs.auction_end_date_ && lhs.auction_center_color_ == rhs.auction_center_color_ &&
513- lhs.auction_edge_color_ == rhs.auction_edge_color_ && lhs.auction_text_color_ == rhs.auction_text_color_ &&
515+ lhs.auction_end_date_ == rhs.auction_end_date_ && lhs.gift_background_ == rhs.gift_background_ &&
514516 lhs.instant_view_ .is_empty_ == rhs.instant_view_ .is_empty_ &&
515517 lhs.instant_view_ .is_v2_ == rhs.instant_view_ .is_v2_ ;
516518 }
@@ -748,9 +750,8 @@ WebPageId WebPagesManager::on_get_web_page(tl_object_ptr<telegram_api::WebPage>
748750 }
749751 page->star_gifts_ .push_back (std::move (star_gift));
750752 page->auction_end_date_ = attribute->end_date_ ;
751- page->auction_center_color_ = attribute->center_color_ ;
752- page->auction_edge_color_ = attribute->edge_color_ ;
753- page->auction_text_color_ = attribute->text_color_ ;
753+ page->gift_background_ = make_unique<StarGiftBackground>(attribute->center_color_ , attribute->edge_color_ ,
754+ attribute->text_color_ );
754755 if (page->type_ != " telegram_auction" ) {
755756 LOG (ERROR) << " Receive webPageAttributeStarGiftAuction for " << page->type_ ;
756757 }
@@ -1541,9 +1542,12 @@ td_api::object_ptr<td_api::LinkPreviewType> WebPagesManager::get_link_preview_ty
15411542 Slice type = Slice (web_page->type_ ).substr (9 );
15421543 if (type == " auction" ) {
15431544 if (web_page->star_gifts_ .size () == 1 ) {
1545+ td_api::object_ptr<td_api::giftBackground> background;
1546+ if (web_page->gift_background_ != nullptr ) {
1547+ background = web_page->gift_background_ ->get_gift_background_object ();
1548+ }
15441549 return td_api::make_object<td_api::linkPreviewTypeGiftAuction>(
1545- web_page->star_gifts_ [0 ].get_gift_object (td_), web_page->auction_end_date_ , web_page->auction_center_color_ ,
1546- web_page->auction_edge_color_ , web_page->auction_text_color_ );
1550+ web_page->star_gifts_ [0 ].get_gift_object (td_), std::move (background), web_page->auction_end_date_ );
15471551 } else {
15481552 LOG (ERROR) << " Receive gift auction " << web_page->url_ << " without the gift" ;
15491553 need_reload = true ;
0 commit comments