From afae88f6ccadbb0d424eaa8fda4be3fa3e1183ca Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 4 Feb 2026 17:27:05 +0400 Subject: [PATCH] Support new service messages. --- Telegram/Resources/langs/lang.strings | 2 ++ .../export/data/export_data_types.cpp | 8 ++++-- .../export/data/export_data_types.h | 12 +++++++- .../export/output/export_output_html.cpp | 10 +++++++ .../export/output/export_output_json.cpp | 8 ++++++ Telegram/SourceFiles/history/history_item.cpp | 28 ++++++++++++++++--- 6 files changed, 61 insertions(+), 7 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 6a0c5dc0a9..0f24447e4c 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -2496,6 +2496,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_action_stake_game_won_you" = "You won {amount}"; "lng_action_stake_game_lost" = "{from} lost {amount}"; "lng_action_stake_game_lost_you" = "You lost {amount}"; +"lng_action_change_creator" = "{from} made {user} the new main admin of the group."; +"lng_action_new_creator_pending" = "{user} will become the new main admin in 7 days if {from} does not return."; "lng_stake_game_title" = "Emoji Stake"; "lng_stake_game_beta" = "Beta"; diff --git a/Telegram/SourceFiles/export/data/export_data_types.cpp b/Telegram/SourceFiles/export/data/export_data_types.cpp index 1b9ef7a46c..7af24dd128 100644 --- a/Telegram/SourceFiles/export/data/export_data_types.cpp +++ b/Telegram/SourceFiles/export/data/export_data_types.cpp @@ -1850,9 +1850,13 @@ ServiceAction ParseServiceAction( content.offerPrice = CreditsAmountFromTL(data.vprice()); result.content = content; }, [&](const MTPDmessageActionNewCreatorPending &data) { - AssertIsDebug(); + auto content = ActionNewCreatorPending(); + content.newCreatorId = data.vnew_creator_id().v; + result.content = content; }, [&](const MTPDmessageActionChangeCreator &data) { - AssertIsDebug(); + auto content = ActionChangeCreator(); + content.newCreatorId = data.vnew_creator_id().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 8a4d0060a7..dc6cb4b8bf 100644 --- a/Telegram/SourceFiles/export/data/export_data_types.h +++ b/Telegram/SourceFiles/export/data/export_data_types.h @@ -738,6 +738,14 @@ struct ActionSuggestBirthday { Birthday birthday; }; +struct ActionNewCreatorPending { + UserId newCreatorId = 0; +}; + +struct ActionChangeCreator { + UserId newCreatorId = 0; +}; + struct ServiceAction { std::variant< v::null_t, @@ -791,7 +799,9 @@ struct ServiceAction { ActionSuggestedPostApproval, ActionSuggestedPostSuccess, ActionSuggestedPostRefund, - ActionSuggestBirthday> content; + ActionSuggestBirthday, + ActionNewCreatorPending, + ActionChangeCreator> content; }; ServiceAction ParseServiceAction( diff --git a/Telegram/SourceFiles/export/output/export_output_html.cpp b/Telegram/SourceFiles/export/output/export_output_html.cpp index 4aa35d8e2f..84d8e1d2d8 100644 --- a/Telegram/SourceFiles/export/output/export_output_html.cpp +++ b/Telegram/SourceFiles/export/output/export_output_html.cpp @@ -1553,6 +1553,16 @@ auto HtmlWriter::Wrap::pushMessage( }() + (data.birthday.year() ? (' ' + QByteArray::number(data.birthday.year())) : QByteArray()); + }, [&](const ActionNewCreatorPending &data) { + return peers.wrapUserName(data.newCreatorId) + + " will become the new main admin in 7 days if " + + serviceFrom + + " does not return"; + }, [&](const ActionChangeCreator &data) { + return serviceFrom + + " made " + + peers.wrapUserName(data.newCreatorId) + + " the new main admin of the group"; }, [](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 18cb7e4fbe..434c69ebc9 100644 --- a/Telegram/SourceFiles/export/output/export_output_json.cpp +++ b/Telegram/SourceFiles/export/output/export_output_json.cpp @@ -743,6 +743,14 @@ QByteArray SerializeMessage( if (const auto year = data.birthday.year()) { push("year", year); } + }, [&](const ActionNewCreatorPending &data) { + pushActor(); + pushAction("new_creator_pending"); + pushBare("new_creator", wrapUserName(data.newCreatorId)); + }, [&](const ActionChangeCreator &data) { + pushActor(); + pushAction("change_creator"); + pushBare("new_creator", wrapUserName(data.newCreatorId)); }, [](v::null_t) {}); if (v::is_null(message.action.content)) { diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index d91a2aed5e..00b1a22a5b 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -6601,13 +6601,33 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) { return result; }; - auto prepareNewCreatorPending = [&](const MTPDmessageActionNewCreatorPending &action) { - auto result = PreparedServiceText{ .text = { u"new creator pending"_q } }; + auto prepareNewCreatorPending = [this](const MTPDmessageActionNewCreatorPending &action) { + auto result = PreparedServiceText(); + auto user = _history->owner().user(action.vnew_creator_id().v); + result.links.push_back(fromLink()); + result.links.push_back(user->createOpenLink()); + result.text = tr::lng_action_new_creator_pending( + tr::now, + lt_user, + tr::link(user->name(), 2), + lt_from, + fromLinkText(), + tr::marked); return result; }; - auto prepareChangeCreator = [&](const MTPDmessageActionChangeCreator &action) { - auto result = PreparedServiceText{ .text = { u"new creator"_q } }; + auto prepareChangeCreator = [this](const MTPDmessageActionChangeCreator &action) { + auto result = PreparedServiceText(); + auto user = _history->owner().user(action.vnew_creator_id().v); + result.links.push_back(fromLink()); + result.links.push_back(user->createOpenLink()); + result.text = tr::lng_action_change_creator( + tr::now, + lt_from, + fromLinkText(), + lt_user, + tr::link(user->name(), 2), + tr::marked); return result; };