mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Update API scheme to layer 220.
Allow offering to buy gifts.
This commit is contained in:
@@ -905,6 +905,20 @@ UserpicsSlice ParseUserpicsSlice(
|
||||
return result;
|
||||
}
|
||||
|
||||
[[nodiscard]] ActionStarGift ParseStarGift(const MTPStarGift &gift) {
|
||||
return gift.match([&](const MTPDstarGift &gift) {
|
||||
return ActionStarGift{
|
||||
.giftId = uint64(gift.vid().v),
|
||||
.stars = int64(gift.vstars().v),
|
||||
.limited = gift.is_limited(),
|
||||
};
|
||||
}, [&](const MTPDstarGiftUnique &gift) {
|
||||
return ActionStarGift{
|
||||
.giftId = uint64(gift.vid().v),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
File &Story::file() {
|
||||
return media.file();
|
||||
}
|
||||
@@ -1744,41 +1758,16 @@ ServiceAction ParseServiceAction(
|
||||
.isUnclaimed = data.is_unclaimed(),
|
||||
};
|
||||
}, [&](const MTPDmessageActionStarGift &data) {
|
||||
data.vgift().match([&](const MTPDstarGift &gift) {
|
||||
result.content = ActionStarGift{
|
||||
.giftId = uint64(gift.vid().v),
|
||||
.stars = int64(gift.vstars().v),
|
||||
.text = (data.vmessage()
|
||||
? ParseText(
|
||||
data.vmessage()->data().vtext(),
|
||||
data.vmessage()->data().ventities().v)
|
||||
: std::vector<TextPart>()),
|
||||
.anonymous = data.is_name_hidden(),
|
||||
.limited = gift.is_limited(),
|
||||
};
|
||||
}, [&](const MTPDstarGiftUnique &gift) {
|
||||
result.content = ActionStarGift{
|
||||
.giftId = uint64(gift.vid().v),
|
||||
.text = (data.vmessage()
|
||||
? ParseText(
|
||||
data.vmessage()->data().vtext(),
|
||||
data.vmessage()->data().ventities().v)
|
||||
: std::vector<TextPart>()),
|
||||
.anonymous = data.is_name_hidden(),
|
||||
};
|
||||
});
|
||||
auto content = ParseStarGift(data.vgift());
|
||||
content.text = (data.vmessage()
|
||||
? ParseText(
|
||||
data.vmessage()->data().vtext(),
|
||||
data.vmessage()->data().ventities().v)
|
||||
: std::vector<TextPart>());
|
||||
content.anonymous = data.is_name_hidden();
|
||||
result.content = content;
|
||||
}, [&](const MTPDmessageActionStarGiftUnique &data) {
|
||||
data.vgift().match([&](const MTPDstarGift &gift) {
|
||||
result.content = ActionStarGift{
|
||||
.giftId = uint64(gift.vid().v),
|
||||
.stars = int64(gift.vstars().v),
|
||||
.limited = gift.is_limited(),
|
||||
};
|
||||
}, [&](const MTPDstarGiftUnique &gift) {
|
||||
result.content = ActionStarGift{
|
||||
.giftId = uint64(gift.vid().v),
|
||||
};
|
||||
});
|
||||
result.content = ParseStarGift(data.vgift());
|
||||
}, [&](const MTPDmessageActionPaidMessagesRefunded &data) {
|
||||
result.content = ActionPaidMessagesRefunded{
|
||||
.messages = data.vcount().v,
|
||||
@@ -1844,6 +1833,21 @@ ServiceAction ParseServiceAction(
|
||||
fields.vmonth().v,
|
||||
fields.vyear().value_or_empty());
|
||||
result.content = content;
|
||||
}, [&](const MTPDmessageActionStarGiftPurchaseOffer &data) {
|
||||
auto content = ParseStarGift(data.vgift());
|
||||
content.offer = true;
|
||||
content.offerPrice = CreditsAmountFromTL(data.vprice());
|
||||
content.offerExpireAt = data.vexpires_at().v;
|
||||
content.offerAccepted = data.is_accepted();
|
||||
content.offerDeclined = data.is_declined();
|
||||
result.content = content;
|
||||
}, [&](const MTPDmessageActionStarGiftPurchaseOfferDeclined &data) {
|
||||
auto content = ParseStarGift(data.vgift());
|
||||
content.offer = true;
|
||||
content.offerDeclined = true;
|
||||
content.offerExpired = data.is_expired();
|
||||
content.offerPrice = CreditsAmountFromTL(data.vprice());
|
||||
result.content = content;
|
||||
}, [](const MTPDmessageActionEmpty &data) {});
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -690,6 +690,13 @@ struct ActionStarGift {
|
||||
std::vector<TextPart> text;
|
||||
bool anonymous = false;
|
||||
bool limited = false;
|
||||
|
||||
CreditsAmount offerPrice;
|
||||
TimeId offerExpireAt = 0;
|
||||
bool offer = false;
|
||||
bool offerAccepted = false;
|
||||
bool offerDeclined = false;
|
||||
bool offerExpired = false;
|
||||
};
|
||||
|
||||
struct ActionPaidMessagesRefunded {
|
||||
|
||||
Reference in New Issue
Block a user