Admin log events about channel emoji status.

This commit is contained in:
John Preston 2023-12-22 07:34:32 -04:00
parent fd64718502
commit 2a5698cf34
2 changed files with 78 additions and 0 deletions

View File

@ -3682,6 +3682,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_admin_log_change_profile_background_emoji" = "{from} changed channel profile background emoji from {previous} to {emoji}";
"lng_admin_log_removed_profile_background_emoji" = "{from} removed channel profile background emoji {emoji}";
"lng_admin_log_change_wallpaper" = "{from} changed channel wallpaper";
"lng_admin_log_set_status" = "{from} set channel emoji status to {emoji}";
"lng_admin_log_change_status" = "{from} changed channel emoji status from {previous} to {emoji}";
"lng_admin_log_removed_status" = "{from} removed channel emoji status {emoji}";
"lng_admin_log_set_status_until" = "{from} set channel emoji status to {emoji} until {date}";
"lng_admin_log_change_status_until" = "{from} changed channel emoji status from {previous} to {emoji} until {date}";
"lng_admin_log_user_with_username" = "{name} ({mention})";
"lng_admin_log_messages_ttl_set" = "{from} enabled messages auto-delete after {duration}";
"lng_admin_log_messages_ttl_changed" = "{from} changed messages auto-delete period from {previous} to {duration}";

View File

@ -1910,7 +1910,80 @@ void GenerateItems(
};
const auto createChangeEmojiStatus = [&](const LogChangeEmojiStatus &data) {
const auto parse = [](const MTPEmojiStatus &status) {
return status.match([](
const MTPDemojiStatus &data) {
return data.vdocument_id().v;
}, [](const MTPDemojiStatusEmpty &) {
return DocumentId();
}, [](const MTPDemojiStatusUntil &data) {
return data.vdocument_id().v;
});
};
const auto prevEmoji = parse(data.vprev_value());
const auto nextEmoji = parse(data.vnew_value());
const auto nextUntil = data.vnew_value().match([](
const MTPDemojiStatusUntil &data) {
return data.vuntil().v;
}, [](const auto &) { return TimeId(); });
const auto text = !prevEmoji
? (nextUntil
? tr::lng_admin_log_set_status_until(
tr::now,
lt_from,
fromLinkText,
lt_emoji,
Ui::Text::SingleCustomEmoji(
Data::SerializeCustomEmojiId(nextEmoji)),
lt_date,
TextWithEntities{
langDateTime(base::unixtime::parse(nextUntil)) },
Ui::Text::WithEntities)
: tr::lng_admin_log_set_status(
tr::now,
lt_from,
fromLinkText,
lt_emoji,
Ui::Text::SingleCustomEmoji(
Data::SerializeCustomEmojiId(nextEmoji)),
Ui::Text::WithEntities))
: !nextEmoji
? tr::lng_admin_log_removed_status(
tr::now,
lt_from,
fromLinkText,
lt_emoji,
Ui::Text::SingleCustomEmoji(
Data::SerializeCustomEmojiId(prevEmoji)),
Ui::Text::WithEntities)
: (nextUntil
? tr::lng_admin_log_change_status_until(
tr::now,
lt_from,
fromLinkText,
lt_previous,
Ui::Text::SingleCustomEmoji(
Data::SerializeCustomEmojiId(prevEmoji)),
lt_emoji,
Ui::Text::SingleCustomEmoji(
Data::SerializeCustomEmojiId(nextEmoji)),
lt_date,
TextWithEntities{
langDateTime(base::unixtime::parse(nextUntil)) },
Ui::Text::WithEntities)
: tr::lng_admin_log_change_status(
tr::now,
lt_from,
fromLinkText,
lt_previous,
Ui::Text::SingleCustomEmoji(
Data::SerializeCustomEmojiId(prevEmoji)),
lt_emoji,
Ui::Text::SingleCustomEmoji(
Data::SerializeCustomEmojiId(nextEmoji)),
Ui::Text::WithEntities));
addSimpleServiceMessage(text);
};
action.match(