MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / FromTL

Function FromTL

Telegram/SourceFiles/api/api_premium.cpp:836–994  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

834}
835
836std::optional<Data::StarGift> FromTL(
837 not_null<Main::Session*> session,
838 const MTPstarGift &gift) {
839 return gift.match([&](const MTPDstarGift &data) {
840 const auto document = session->data().processDocument(
841 data.vsticker());
842 const auto resellPrice = data.vresell_min_stars().value_or_empty();
843 const auto remaining = data.vavailability_remains();
844 const auto total = data.vavailability_total();
845 if (!document->sticker()) {
846 return std::optional<Data::StarGift>();
847 }
848 const auto releasedById = data.vreleased_by()
849 ? peerFromMTP(*data.vreleased_by())
850 : PeerId();
851 const auto releasedBy = releasedById
852 ? session->data().peer(releasedById).get()
853 : nullptr;
854 const auto background = [&] {
855 if (!data.vbackground()) {
856 return std::shared_ptr<Data::StarGiftBackground>();
857 }
858 const auto &fields = data.vbackground()->data();
859 using namespace Ui;
860 return std::make_shared<Data::StarGiftBackground>(
861 Data::StarGiftBackground{
862 .center = ColorFromSerialized(fields.vcenter_color()),
863 .edge = ColorFromSerialized(fields.vedge_color()),
864 .text = ColorFromSerialized(fields.vtext_color()),
865 });
866 };
867 return std::optional<Data::StarGift>(Data::StarGift{
868 .id = uint64(data.vid().v),
869 .background = background(),
870 .stars = int64(data.vstars().v),
871 .starsConverted = int64(data.vconvert_stars().v),
872 .starsToUpgrade = int64(data.vupgrade_stars().value_or_empty()),
873 .starsResellMin = int64(resellPrice),
874 .document = document,
875 .releasedBy = releasedBy,
876 .resellTitle = qs(data.vtitle().value_or_empty()),
877 .resellCount = int(data.vavailability_resale().value_or_empty()),
878 .auctionSlug = qs(data.vauction_slug().value_or_empty()),
879 .auctionGiftsPerRound = data.vgifts_per_round().value_or_empty(),
880 .auctionStartDate = data.vauction_start_date().value_or_empty(),
881 .limitedLeft = remaining.value_or_empty(),
882 .limitedCount = total.value_or_empty(),
883 .perUserTotal = data.vper_user_total().value_or_empty(),
884 .perUserRemains = data.vper_user_remains().value_or_empty(),
885 .upgradeVariants = data.vupgrade_variants().value_or_empty(),
886 .firstSaleDate = data.vfirst_sale_date().value_or_empty(),
887 .lastSaleDate = data.vlast_sale_date().value_or_empty(),
888 .lockedUntilDate = data.vlocked_until_date().value_or_empty(),
889 .requirePremium = data.is_require_premium(),
890 .peerColorAvailable = data.is_peer_color_available(),
891 .upgradable = data.vupgrade_stars().has_value(),
892 .birthday = data.is_birthday(),
893 .soldOut = data.is_sold_out(),

Callers 12

loadUsernamesMethod · 0.70
feedUpdateMethod · 0.70
requestStarGiftsMethod · 0.70
SessionControllerMethod · 0.50
ShowStarGiftUpgradeBoxFunction · 0.50
FindUniqueGiftFunction · 0.50
ResolveAndShowUniqueGiftFunction · 0.50
createServiceFromMtpMethod · 0.50
processActionMethod · 0.50
OpenStarGiftLinkFunction · 0.50

Calls 15

peerFromMTPFunction · 0.85
PeerIdClass · 0.85
qsFunction · 0.85
ParseColorCollectibleFunction · 0.85
FindTonForResaleFunction · 0.85
FindStarsForResaleFunction · 0.85
ParseTextWithEntitiesFunction · 0.85
TextWithEntitiesClass · 0.85
ParseRarityFunction · 0.85
processDocumentMethod · 0.80
has_valueMethod · 0.80

Tested by

no test coverage detected