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( content.cost = Ui::FillAmountAndCurrency(
data.vamount().v, data.vamount().v,
qs(data.vcurrency())).toUtf8(); qs(data.vcurrency())).toUtf8();
content.stars = data.vstars().v; content.credits = data.vstars().v;
result.content = content; result.content = content;
}, [&](const MTPDmessageActionPrizeStars &data) { }, [&](const MTPDmessageActionPrizeStars &data) {
auto content = ActionPrizeStars(); auto content = ActionPrizeStars();
content.peerId = ParsePeerId(data.vboost_peer());
content.amount = data.vstars().v; content.amount = data.vstars().v;
result.content = content; result.content = content;
}, [](const MTPDmessageActionEmpty &data) {}); }, [](const MTPDmessageActionEmpty &data) {});

View file

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

View file

@ -1330,17 +1330,21 @@ auto HtmlWriter::Wrap::pushMessage(
+ amount; + amount;
return result; return result;
}, [&](const ActionGiftStars &data) { }, [&](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.";
} }
return serviceFrom return serviceFrom
+ " sent you a gift for " + " sent you a gift for "
+ data.cost + data.cost
+ ": " + ": "
+ QString::number(data.stars).toUtf8() + QString::number(data.credits).toUtf8()
+ " Telegram Stars."; + " Telegram Stars.";
}, [&](const ActionPrizeStars &data) { }, [&](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(); }); }, [](v::null_t) { return QByteArray(); });
if (!serviceText.isEmpty()) { if (!serviceText.isEmpty()) {

View file

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