mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Support new service messages.
This commit is contained in:
@@ -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";
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user