Added support of giveaway prize action messages to export to HTML.

This commit is contained in:
23rd 2024-08-29 12:27:32 +03:00 committed by John Preston
parent 36141a9df9
commit bc4b427ed1
4 changed files with 13 additions and 7 deletions

View file

@ -1562,10 +1562,11 @@ ServiceAction ParseServiceAction(
content.cost = Ui::FillAmountAndCurrency(
data.vamount().v,
qs(data.vcurrency())).toUtf8();
content.stars = data.vstars().v;
content.credits = data.vstars().v;
result.content = content;
}, [&](const MTPDmessageActionPrizeStars &data) {
auto content = ActionPrizeStars();
content.peerId = ParsePeerId(data.vboost_peer());
content.amount = data.vstars().v;
result.content = content;
}, [](const MTPDmessageActionEmpty &data) {});

View file

@ -605,10 +605,11 @@ struct ActionPaymentRefunded {
struct ActionGiftStars {
Utf8String cost;
int stars = 0;
int credits = 0;
};
struct ActionPrizeStars {
PeerId peerId = 0;
uint64 amount = 0;
};

View file

@ -1330,17 +1330,21 @@ auto HtmlWriter::Wrap::pushMessage(
+ amount;
return result;
}, [&](const ActionGiftStars &data) {
if (!data.stars || data.cost.isEmpty()) {
if (!data.credits || data.cost.isEmpty()) {
return serviceFrom + " sent you a gift.";
}
return serviceFrom
+ " sent you a gift for "
+ data.cost
+ ": "
+ QString::number(data.stars).toUtf8()
+ QString::number(data.credits).toUtf8()
+ " Telegram Stars.";
}, [&](const ActionPrizeStars &data) {
return serviceFrom + " prize stars."; AssertIsDebug();
return "You won a prize in a giveaway organized by "
+ peers.wrapPeerName(data.peerId)
+ ".\n Your prize is "
+ QString::number(data.amount).toUtf8()
+ " Telegram Stars.";
}, [](v::null_t) { return QByteArray(); });
if (!serviceText.isEmpty()) {

View file

@ -638,8 +638,8 @@ QByteArray SerializeMessage(
if (!data.cost.isEmpty()) {
push("cost", data.cost);
}
if (data.stars) {
push("stars", data.stars);
if (data.credits) {
push("stars", data.credits);
}
}, [&](const ActionPrizeStars &data) {
pushActor();