data_credits.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #pragma once
  8. #include "data/data_subscriptions.h"
  9. namespace Data {
  10. struct UniqueGift;
  11. struct CreditTopupOption final {
  12. uint64 credits = 0;
  13. QString product;
  14. QString currency;
  15. uint64 amount = 0;
  16. bool extended = false;
  17. uint64 giftBarePeerId = 0;
  18. };
  19. using CreditTopupOptions = std::vector<CreditTopupOption>;
  20. enum class CreditsHistoryMediaType {
  21. Photo,
  22. Video,
  23. };
  24. struct CreditsHistoryMedia {
  25. CreditsHistoryMediaType type = CreditsHistoryMediaType::Photo;
  26. uint64 id = 0;
  27. };
  28. struct CreditsHistoryEntry final {
  29. explicit operator bool() const {
  30. return !id.isEmpty();
  31. }
  32. using PhotoId = uint64;
  33. enum class PeerType {
  34. Peer,
  35. AppStore,
  36. PlayMarket,
  37. Fragment,
  38. Unsupported,
  39. PremiumBot,
  40. Ads,
  41. API,
  42. };
  43. QString id;
  44. QString title;
  45. TextWithEntities description;
  46. QDateTime date;
  47. QDateTime firstSaleDate;
  48. QDateTime lastSaleDate;
  49. PhotoId photoId = 0;
  50. std::vector<CreditsHistoryMedia> extended;
  51. StarsAmount credits;
  52. uint64 bareMsgId = 0;
  53. uint64 barePeerId = 0;
  54. uint64 bareGiveawayMsgId = 0;
  55. uint64 bareGiftStickerId = 0;
  56. uint64 bareGiftOwnerId = 0;
  57. uint64 bareActorId = 0;
  58. uint64 bareEntryOwnerId = 0;
  59. uint64 giftChannelSavedId = 0;
  60. uint64 stargiftId = 0;
  61. std::shared_ptr<UniqueGift> uniqueGift;
  62. Fn<std::vector<CreditsHistoryEntry>()> pinnedSavedGifts;
  63. StarsAmount starrefAmount;
  64. int starrefCommission = 0;
  65. uint64 starrefRecipientId = 0;
  66. PeerType peerType;
  67. QDateTime subscriptionUntil;
  68. QDateTime successDate;
  69. QString successLink;
  70. int paidMessagesCount = 0;
  71. StarsAmount paidMessagesAmount;
  72. int paidMessagesCommission = 0;
  73. int limitedCount = 0;
  74. int limitedLeft = 0;
  75. int starsConverted = 0;
  76. int starsToUpgrade = 0;
  77. int starsUpgradedBySender = 0;
  78. int premiumMonthsForStars = 0;
  79. int floodSkip = 0;
  80. bool converted : 1 = false;
  81. bool anonymous : 1 = false;
  82. bool stargift : 1 = false;
  83. bool giftTransferred : 1 = false;
  84. bool giftRefunded : 1 = false;
  85. bool giftUpgraded : 1 = false;
  86. bool giftPinned : 1 = false;
  87. bool savedToProfile : 1 = false;
  88. bool fromGiftsList : 1 = false;
  89. bool fromGiftSlug : 1 = false;
  90. bool soldOutInfo : 1 = false;
  91. bool canUpgradeGift : 1 = false;
  92. bool hasGiftComment : 1 = false;
  93. bool reaction : 1 = false;
  94. bool refunded : 1 = false;
  95. bool pending : 1 = false;
  96. bool failed : 1 = false;
  97. bool in : 1 = false;
  98. bool gift : 1 = false;
  99. };
  100. struct CreditsStatusSlice final {
  101. using OffsetToken = QString;
  102. std::vector<CreditsHistoryEntry> list;
  103. std::vector<SubscriptionEntry> subscriptions;
  104. StarsAmount balance;
  105. uint64 subscriptionsMissingBalance = 0;
  106. bool allLoaded = false;
  107. OffsetToken token;
  108. OffsetToken tokenSubscriptions;
  109. };
  110. struct CreditsGiveawayOption final {
  111. struct Winner final {
  112. int users = 0;
  113. uint64 perUserStars = 0;
  114. bool isDefault = false;
  115. };
  116. std::vector<Winner> winners;
  117. QString storeProduct;
  118. QString currency;
  119. uint64 amount = 0;
  120. uint64 credits = 0;
  121. int yearlyBoosts = 0;
  122. bool isExtended = false;
  123. bool isDefault = false;
  124. };
  125. using CreditsGiveawayOptions = std::vector<CreditsGiveawayOption>;
  126. } // namespace Data