From b295a9eeb1057f527ceb2d6e5891089a0ca4912f Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Thu, 14 Jul 2022 21:53:49 +0300 Subject: [PATCH] Added support of service actions for premium gifts to export. --- Telegram/SourceFiles/export/data/export_data_types.cpp | 7 ++++++- Telegram/SourceFiles/export/data/export_data_types.h | 8 +++++++- .../SourceFiles/export/output/export_output_html.cpp | 9 +++++++++ .../SourceFiles/export/output/export_output_json.cpp | 9 +++++++++ 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/export/data/export_data_types.cpp b/Telegram/SourceFiles/export/data/export_data_types.cpp index 29a9daed04..59072f2be7 100644 --- a/Telegram/SourceFiles/export/data/export_data_types.cpp +++ b/Telegram/SourceFiles/export/data/export_data_types.cpp @@ -1146,7 +1146,12 @@ ServiceAction ParseServiceAction( content.text = ParseString(data.vtext()); result.content = content; }, [&](const MTPDmessageActionGiftPremium &data) { - // #TODO gifts + auto content = ActionGiftPremium(); + content.cost = Ui::FillAmountAndCurrency( + data.vamount().v, + qs(data.vcurrency())).toUtf8(); + content.months = data.vmonths().v; + result.content = content; }, [](const MTPDmessageActionEmpty &data) {}); return result; } diff --git a/Telegram/SourceFiles/export/data/export_data_types.h b/Telegram/SourceFiles/export/data/export_data_types.h index 1bbdba19ae..07b03aece4 100644 --- a/Telegram/SourceFiles/export/data/export_data_types.h +++ b/Telegram/SourceFiles/export/data/export_data_types.h @@ -488,6 +488,11 @@ struct ActionWebViewDataSent { Utf8String text; }; +struct ActionGiftPremium { + Utf8String cost; + int months; +}; + struct ServiceAction { std::variant< v::null_t, @@ -519,7 +524,8 @@ struct ServiceAction { ActionGroupCallScheduled, ActionSetChatTheme, ActionChatJoinedByRequest, - ActionWebViewDataSent> content; + ActionWebViewDataSent, + ActionGiftPremium> content; }; ServiceAction ParseServiceAction( diff --git a/Telegram/SourceFiles/export/output/export_output_html.cpp b/Telegram/SourceFiles/export/output/export_output_html.cpp index 49cdedc46d..0d79af922e 100644 --- a/Telegram/SourceFiles/export/output/export_output_html.cpp +++ b/Telegram/SourceFiles/export/output/export_output_html.cpp @@ -1128,6 +1128,15 @@ auto HtmlWriter::Wrap::pushMessage( return "You have just successfully transferred data from the «" + SerializeString(data.text) + "» button to the bot"; + }, [&](const ActionGiftPremium &data) { + if (!data.months || data.cost.isEmpty()) { + return (serviceFrom + " sent you a gift."); + } + return (serviceFrom + + " sent you a gift for " + + data.cost + + ": Telegram Premium for " + + QString::number(data.months).toUtf8() + " months."); }, [](v::null_t) { return QByteArray(); }); if (!serviceText.isEmpty()) { diff --git a/Telegram/SourceFiles/export/output/export_output_json.cpp b/Telegram/SourceFiles/export/output/export_output_json.cpp index a529a018f3..6d1ade00f0 100644 --- a/Telegram/SourceFiles/export/output/export_output_json.cpp +++ b/Telegram/SourceFiles/export/output/export_output_json.cpp @@ -546,6 +546,15 @@ QByteArray SerializeMessage( }, [&](const ActionWebViewDataSent &data) { pushAction("send_webview_data"); push("text", data.text); + }, [&](const ActionGiftPremium &data) { + pushActor(); + pushAction("send_premium_gift"); + if (!data.cost.isEmpty()) { + push("cost", data.cost); + } + if (data.months) { + push("months", data.months); + } }, [](v::null_t) {}); if (v::is_null(message.action.content)) {