Update API scheme to layer 211.

This commit is contained in:
John Preston
2025-07-25 11:40:25 +04:00
parent 472d9dd467
commit 043bc754ae
8 changed files with 80 additions and 26 deletions
+2
View File
@@ -2182,6 +2182,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_action_gift_channel_about_unique" = "You can display this gift in channel's Gifts or turn it into unique collectible.";
"lng_action_gift_for_stars#one" = "{count} Star";
"lng_action_gift_for_stars#other" = "{count} Stars";
"lng_action_gift_for_ton#one" = "{count} TON";
"lng_action_gift_for_ton#other" = "{count} TON";
"lng_action_gift_got_subtitle" = "Gift from {user}";
"lng_action_gift_got_stars_text#one" = "Display this gift on your page or convert it to **{count}** Star.";
"lng_action_gift_got_stars_text#other" = "Display this gift on your page or convert it to **{count}** Stars.";
+27 -1
View File
@@ -58,6 +58,30 @@ namespace {
return options;
}
[[nodiscard]] int FindStarsForResale(const MTPVector<MTPStarsAmount> *list) {
if (!list) {
return 0;
}
for (const auto &amount : list->v) {
if (amount.type() == mtpc_starsAmount) {
return int(amount.c_starsAmount().vamount().v);
}
}
return 0;
}
[[nodiscard]] int64 FindTonForResale(const MTPVector<MTPStarsAmount> *list) {
if (!list) {
return 0;
}
for (const auto &amount : list->v) {
if (amount.type() == mtpc_starsTonAmount) {
return int64(amount.c_starsTonAmount().vamount().v);
}
}
return 0;
}
} // namespace
Premium::Premium(not_null<ApiWrap*> api)
@@ -872,7 +896,8 @@ std::optional<Data::StarGift> FromTL(
: PeerId()),
.releasedBy = releasedBy,
.number = data.vnum().v,
.starsForResale = int(data.vresell_stars().value_or_empty()),
.starsForResale = FindStarsForResale(data.vresell_amount()),
.tonForResale = FindTonForResale(data.vresell_amount()),
.model = *model,
.pattern = *pattern,
}),
@@ -880,6 +905,7 @@ std::optional<Data::StarGift> FromTL(
.releasedBy = releasedBy,
.limitedLeft = (total - data.vavailability_issued().v),
.limitedCount = total,
.resellTonOnly = data.is_resale_ton_only(),
.requirePremium = data.is_require_premium(),
};
const auto unique = result.unique.get();
+1 -1
View File
@@ -4478,7 +4478,7 @@ void UpdateGiftSellPrice(
const auto session = &show->session();
session->api().request(MTPpayments_UpdateStarGiftPrice(
Api::InputSavedStarGiftId(savedId, unique),
MTP_long(price)
MTP_starsAmount(MTP_long(price), MTP_int(0))
)).done([=](const MTPUpdates &result) {
session->api().applyUpdates(result);
show->showToast((!price
@@ -501,7 +501,9 @@ void BuyResaleGift(
}
};
using Flag = MTPDinputInvoiceStarGiftResale::Flag;
const auto invoice = MTP_inputInvoiceStarGiftResale(
MTP_flags(Flag()),
MTP_string(gift->slug),
to->input);
+6 -4
View File
@@ -48,6 +48,7 @@ struct UniqueGift {
int number = 0;
int starsForTransfer = -1;
int starsForResale = -1;
int64 tonForResale = -1;
TimeId exportAt = 0;
TimeId canTransferAt = 0;
TimeId canResellAt = 0;
@@ -78,10 +79,11 @@ struct StarGift {
int perUserRemains = 0;
TimeId firstSaleDate = 0;
TimeId lastSaleDate = 0;
bool requirePremium = false;
bool upgradable = false;
bool birthday = false;
bool soldOut = false;
bool resellTonOnly : 1 = false;
bool requirePremium : 1 = false;
bool upgradable : 1 = false;
bool birthday : 1 = false;
bool soldOut : 1 = false;
friend inline bool operator==(
const StarGift &,
@@ -2917,15 +2917,19 @@ void Widget::requestPublicPosts(bool fromStart) {
.posts = true,
.start = fromStart,
};
using Flag = MTPchannels_SearchPosts::Flag;
_postsProcess.requestId = session().api().request(
MTPchannels_SearchPosts(
MTP_flags(Flag::f_hashtag),
MTP_string(_searchState.query.trimmed().mid(1)),
MTP_string(), // query
MTP_int(fromStart ? 0 : _postsProcess.nextRate),
(fromStart
? MTP_inputPeerEmpty()
: _postsProcess.lastPeer->input),
MTP_int(fromStart ? 0 : _postsProcess.lastId),
MTP_int(kSearchPerPage))
MTP_int(kSearchPerPage),
MTP_long(0)) // allow_paid_stars
).done([=](const MTPmessages_Messages &result) {
searchReceived(type, result, &_postsProcess);
}).fail([=](const MTP::Error &error) {
+18 -11
View File
@@ -5931,11 +5931,18 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) {
const MTPDmessageActionStarGiftUnique &action) {
auto result = PreparedServiceText();
const auto isSelf = _from->isSelf();
const auto resaleStars = action.vresale_stars().value_or_empty();
const auto resaleCost = TextWithEntities{ resaleStars
? tr::lng_action_gift_for_stars(tr::now, lt_count, resaleStars)
: QString()
};
const auto resale = CreditsAmountFromTL(action.vresale_amount());
const auto resaleCost = !resale
? TextWithEntities()
: resale.stars()
? TextWithEntities{ tr::lng_action_gift_for_stars(
tr::now,
lt_count,
resale.value()) }
: TextWithEntities{ tr::lng_action_gift_for_ton(
tr::now,
lt_count,
resale.value()) };
const auto giftPeer = action.vpeer()
? peerFromMTP(*action.vpeer())
: PeerId();
@@ -5951,10 +5958,10 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) {
peerToChannel(giftPeer));
if (!from->isServiceUser() && !from->isSelf()) {
result.links.push_back(from->createOpenLink());
if (resaleStars) {
if (resale) {
result.links.push_back(channel->createOpenLink());
}
result.text = resaleStars
result.text = resale
? tr::lng_action_gift_sent_channel(
tr::now,
lt_user,
@@ -5974,7 +5981,7 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) {
Ui::Text::Link(channel->name(), 2),
Ui::Text::WithEntities);
} else {
result.text = resaleStars
result.text = resale
? tr::lng_action_gift_sent_self_channel(
tr::now,
lt_name,
@@ -5995,10 +6002,10 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) {
result.links.push_back(channel->createOpenLink());
} else {
if (!from->isServiceUser() && !_history->peer->isSelf()) {
if (!resaleStars || !isSelf) {
if (!resale || !isSelf) {
result.links.push_back(from->createOpenLink());
}
result.text = resaleStars
result.text = resale
? (isSelf
? tr::lng_action_gift_sent(
tr::now,
@@ -6024,7 +6031,7 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) {
Ui::Text::Link(from->shortName(), 1),
Ui::Text::WithEntities);
} else {
result.text = resaleStars
result.text = resale
? tr::lng_action_gift_self_bought(
tr::now,
lt_cost,
+19 -8
View File
@@ -186,7 +186,7 @@ messageActionPaymentRefunded#41b3e202 flags:# peer:Peer currency:string total_am
messageActionGiftStars#45d5b021 flags:# currency:string amount:long stars:long crypto_currency:flags.0?string crypto_amount:flags.0?long transaction_id:flags.1?string = MessageAction;
messageActionPrizeStars#b00c47a2 flags:# unclaimed:flags.0?true stars:long transaction_id:string boost_peer:Peer giveaway_msg_id:int = MessageAction;
messageActionStarGift#4717e8a4 flags:# name_hidden:flags.0?true saved:flags.2?true converted:flags.3?true upgraded:flags.5?true refunded:flags.9?true can_upgrade:flags.10?true gift:StarGift message:flags.1?TextWithEntities convert_stars:flags.4?long upgrade_msg_id:flags.5?int upgrade_stars:flags.8?long from_id:flags.11?Peer peer:flags.12?Peer saved_id:flags.12?long = MessageAction;
messageActionStarGiftUnique#2e3ae60e flags:# upgrade:flags.0?true transferred:flags.1?true saved:flags.2?true refunded:flags.5?true gift:StarGift can_export_at:flags.3?int transfer_stars:flags.4?long from_id:flags.6?Peer peer:flags.7?Peer saved_id:flags.7?long resale_stars:flags.8?long can_transfer_at:flags.9?int can_resell_at:flags.10?int = MessageAction;
messageActionStarGiftUnique#34f762f3 flags:# upgrade:flags.0?true transferred:flags.1?true saved:flags.2?true refunded:flags.5?true gift:StarGift can_export_at:flags.3?int transfer_stars:flags.4?long from_id:flags.6?Peer peer:flags.7?Peer saved_id:flags.7?long resale_amount:flags.8?StarsAmount can_transfer_at:flags.9?int can_resell_at:flags.10?int = MessageAction;
messageActionPaidMessagesRefunded#ac1f1fcd count:int stars:long = MessageAction;
messageActionPaidMessagesPrice#84b88578 flags:# broadcast_messages_allowed:flags.0?true stars:long = MessageAction;
messageActionConferenceCall#2ffe2f7a flags:# missed:flags.0?true active:flags.1?true video:flags.4?true call_id:long duration:flags.2?int other_participants:flags.3?Vector<Peer> = MessageAction;
@@ -1502,7 +1502,7 @@ inputInvoiceStarGiftUpgrade#4d818d5d flags:# keep_original_details:flags.0?true
inputInvoiceStarGiftTransfer#4a5f5bd9 stargift:InputSavedStarGift to_id:InputPeer = InputInvoice;
inputInvoicePremiumGiftStars#dabab2ef flags:# user_id:InputUser months:int message:flags.0?TextWithEntities = InputInvoice;
inputInvoiceBusinessBotTransferStars#f4997e42 bot:InputUser stars:long = InputInvoice;
inputInvoiceStarGiftResale#63cbc38c slug:string to_id:InputPeer = InputInvoice;
inputInvoiceStarGiftResale#c39f5324 flags:# ton:flags.0?true slug:string to_id:InputPeer = InputInvoice;
payments.exportedInvoice#aed0cbd9 url:string = payments.ExportedInvoice;
@@ -1634,7 +1634,7 @@ storyViews#8d595cd6 flags:# has_viewers:flags.1?true views_count:int forwards_co
storyItemDeleted#51e6ee4f id:int = StoryItem;
storyItemSkipped#ffadc913 flags:# close_friends:flags.8?true id:int date:int expire_date:int = StoryItem;
storyItem#79b26a24 flags:# pinned:flags.5?true public:flags.7?true close_friends:flags.8?true min:flags.9?true noforwards:flags.10?true edited:flags.11?true contacts:flags.12?true selected_contacts:flags.13?true out:flags.16?true id:int date:int from_id:flags.18?Peer fwd_from:flags.17?StoryFwdHeader expire_date:int caption:flags.0?string entities:flags.1?Vector<MessageEntity> media:MessageMedia media_areas:flags.14?Vector<MediaArea> privacy:flags.2?Vector<PrivacyRule> views:flags.3?StoryViews sent_reaction:flags.15?Reaction = StoryItem;
storyItem#edf164f1 flags:# pinned:flags.5?true public:flags.7?true close_friends:flags.8?true min:flags.9?true noforwards:flags.10?true edited:flags.11?true contacts:flags.12?true selected_contacts:flags.13?true out:flags.16?true id:int date:int from_id:flags.18?Peer fwd_from:flags.17?StoryFwdHeader expire_date:int caption:flags.0?string entities:flags.1?Vector<MessageEntity> media:MessageMedia media_areas:flags.14?Vector<MediaArea> privacy:flags.2?Vector<PrivacyRule> views:flags.3?StoryViews sent_reaction:flags.15?Reaction albums:flags.19?Vector<int> = StoryItem;
stories.allStoriesNotModified#1158fe3e flags:# state:string stealth_mode:StoriesStealthMode = stories.AllStories;
stories.allStories#6efc5e81 flags:# has_more:flags.0?true count:int state:string peer_stories:Vector<PeerStories> chats:Vector<Chat> users:Vector<User> stealth_mode:StoriesStealthMode = stories.AllStories;
@@ -1891,7 +1891,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#bcff5b 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 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 = StarGift;
starGiftUnique#f63778ae flags:# require_premium:flags.6?true 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<StarGiftAttribute> availability_issued:int availability_total:int gift_address:flags.3?string resell_stars:flags.4?long released_by:flags.5?Peer = StarGift;
starGiftUnique#3a274d50 flags:# require_premium:flags.6?true resale_ton_only:flags.7?true 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<StarGiftAttribute> availability_issued:int availability_total:int gift_address:flags.3?string resell_amount:flags.4?Vector<StarsAmount> released_by:flags.5?Peer = StarGift;
payments.starGiftsNotModified#a388a368 = payments.StarGifts;
payments.starGifts#2ed82995 hash:int gifts:Vector<StarGift> chats:Vector<Chat> users:Vector<User> = payments.StarGifts;
@@ -1996,6 +1996,11 @@ starGiftCollection#9d6b13b0 flags:# collection_id:int title:string icon:flags.0?
payments.starGiftCollectionsNotModified#a0ba4f17 = payments.StarGiftCollections;
payments.starGiftCollections#8a2932f3 collections:Vector<StarGiftCollection> = payments.StarGiftCollections;
storyAlbum#9325705a flags:# album_id:int title:string icon_photo:flags.0?Photo icon_video:flags.1?Document = StoryAlbum;
stories.albumsNotModified#564edaeb = stories.Albums;
stories.albums#c3987a3a hash:long albums:Vector<StoryAlbum> = stories.Albums;
---functions---
invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X;
@@ -2519,7 +2524,7 @@ channels.updateEmojiStatus#f0d3e6a8 channel:InputChannel emoji_status:EmojiStatu
channels.setBoostsToUnblockRestrictions#ad399cee channel:InputChannel boosts:int = Updates;
channels.setEmojiStickers#3cd930b7 channel:InputChannel stickerset:InputStickerSet = Bool;
channels.restrictSponsoredMessages#9ae91519 channel:InputChannel restricted:Bool = Updates;
channels.searchPosts#d19f987b hashtag:string offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages;
channels.searchPosts#f2c4f24d flags:# hashtag:flags.0?string query:flags.1?string offset_rate:int offset_peer:InputPeer offset_id:int limit:int allow_paid_stars:flags.2?long = messages.Messages;
channels.updatePaidMessagesPrice#4b12327b flags:# broadcast_messages_allowed:flags.0?true channel:InputChannel send_paid_messages_stars:long = Updates;
channels.toggleAutotranslation#167fc0a1 channel:InputChannel enabled:Bool = Updates;
channels.getMessageAuthor#ece2a0e6 channel:InputChannel id:int = User;
@@ -2604,7 +2609,7 @@ payments.toggleChatStarGiftNotifications#60eaefa1 flags:# enabled:flags.0?true p
payments.toggleStarGiftsPinnedToTop#1513e7b0 peer:InputPeer stargift:Vector<InputSavedStarGift> = Bool;
payments.canPurchaseStore#4fdc5ea7 purpose:InputStorePaymentPurpose = Bool;
payments.getResaleStarGifts#7a5fa236 flags:# sort_by_price:flags.1?true sort_by_num:flags.2?true attributes_hash:flags.0?long gift_id:long attributes:flags.3?Vector<StarGiftAttributeId> offset:string limit:int = payments.ResaleStarGifts;
payments.updateStarGiftPrice#3baea4e1 stargift:InputSavedStarGift resell_stars:long = Updates;
payments.updateStarGiftPrice#edbe6ccb stargift:InputSavedStarGift resell_amount:StarsAmount = Updates;
payments.createStarGiftCollection#1f4a0e87 peer:InputPeer title:string stargift:Vector<InputSavedStarGift> = StarGiftCollection;
payments.updateStarGiftCollection#4fddbee7 flags:# peer:InputPeer collection_id:int title:flags.0?string delete_stargift:flags.1?Vector<InputSavedStarGift> add_stargift:flags.2?Vector<InputSavedStarGift> order:flags.3?Vector<InputSavedStarGift> = StarGiftCollection;
payments.reorderStarGiftCollections#c32af4cc peer:InputPeer order:Vector<int> = Bool;
@@ -2690,7 +2695,7 @@ chatlists.getLeaveChatlistSuggestions#fdbcd714 chatlist:InputChatlist = Vector<P
chatlists.leaveChatlist#74fae13a chatlist:InputChatlist peers:Vector<InputPeer> = Updates;
stories.canSendStory#30eb63f0 peer:InputPeer = stories.CanSendStoryCount;
stories.sendStory#e4e6694b flags:# pinned:flags.2?true noforwards:flags.4?true fwd_modified:flags.7?true peer:InputPeer media:InputMedia media_areas:flags.5?Vector<MediaArea> caption:flags.0?string entities:flags.1?Vector<MessageEntity> privacy_rules:Vector<InputPrivacyRule> random_id:long period:flags.3?int fwd_from_id:flags.6?InputPeer fwd_from_story:flags.6?int = Updates;
stories.sendStory#737fc2ec flags:# pinned:flags.2?true noforwards:flags.4?true fwd_modified:flags.7?true peer:InputPeer media:InputMedia media_areas:flags.5?Vector<MediaArea> caption:flags.0?string entities:flags.1?Vector<MessageEntity> privacy_rules:Vector<InputPrivacyRule> random_id:long period:flags.3?int fwd_from_id:flags.6?InputPeer fwd_from_story:flags.6?int albums:flags.8?Vector<int> = Updates;
stories.editStory#b583ba46 flags:# peer:InputPeer id:int media:flags.0?InputMedia media_areas:flags.3?Vector<MediaArea> caption:flags.1?string entities:flags.1?Vector<MessageEntity> privacy_rules:flags.2?Vector<InputPrivacyRule> = Updates;
stories.deleteStories#ae59db5f peer:InputPeer id:Vector<int> = Vector<int>;
stories.togglePinned#9a75a1ef peer:InputPeer id:Vector<int> pinned:Bool = Vector<int>;
@@ -2715,6 +2720,12 @@ stories.togglePeerStoriesHidden#bd0415c4 peer:InputPeer hidden:Bool = Bool;
stories.getStoryReactionsList#b9b2881f flags:# forwards_first:flags.2?true peer:InputPeer id:int reaction:flags.0?Reaction offset:flags.1?string limit:int = stories.StoryReactionsList;
stories.togglePinnedToTop#b297e9b peer:InputPeer id:Vector<int> = Bool;
stories.searchPosts#d1810907 flags:# hashtag:flags.0?string area:flags.1?MediaArea peer:flags.2?InputPeer offset:string limit:int = stories.FoundStories;
stories.createAlbum#a36396e5 peer:InputPeer title:string stories:Vector<int> = StoryAlbum;
stories.updateAlbum#5e5259b6 flags:# peer:InputPeer album_id:int title:flags.0?string delete_stories:flags.1?Vector<int> add_stories:flags.2?Vector<int> order:flags.3?Vector<int> = StoryAlbum;
stories.reorderAlbums#8535fbd9 peer:InputPeer order:Vector<int> = Bool;
stories.deleteAlbum#8d3456d0 peer:InputPeer album_id:int = Bool;
stories.getAlbums#25b3eac7 peer:InputPeer hash:long = stories.Albums;
stories.getAlbumStories#ac806d61 peer:InputPeer album_id:int offset:int limit:int = stories.Stories;
premium.getBoostsList#60f67660 flags:# gifts:flags.0?true peer:InputPeer offset:string limit:int = premium.BoostsList;
premium.getMyBoosts#be77b4a = premium.MyBoosts;
@@ -2732,4 +2743,4 @@ smsjobs.finishJob#4f1ebf24 flags:# job_id:string error:flags.0?string = Bool;
fragment.getCollectibleInfo#be1e85ba collectible:InputCollectible = fragment.CollectibleInfo;
// LAYER 210
// LAYER 211