From c9ac77ccbfb9b117011c81e3391dc54570cd081e Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 26 Feb 2026 13:05:05 +0400 Subject: [PATCH] Use separate phrase for singular Edit Tag. --- Telegram/Resources/langs/lang.strings | 2 ++ .../boxes/moderate_messages_box.cpp | 2 +- .../boxes/peers/edit_participant_box.cpp | 2 +- .../boxes/peers/edit_peer_permissions_box.cpp | 4 +++- .../SourceFiles/core/click_handler_types.cpp | 19 ++++++++++++++----- .../data/data_chat_participant_status.h | 1 + .../admin_log/history_admin_log_item.cpp | 14 ++++++++++---- 7 files changed, 32 insertions(+), 12 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 837448e83f..7a8d81deca 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -6165,6 +6165,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_rights_group_topics" = "Manage topics"; "lng_rights_group_add_topics" = "Create topics"; "lng_rights_group_edit_rank" = "Edit own tags"; +"lng_rights_group_edit_rank_single" = "Edit own tag"; "lng_rights_group_manage_calls" = "Manage video chats"; "lng_rights_group_delete" = "Delete messages"; "lng_rights_group_anonymous" = "Remain anonymous"; @@ -6481,6 +6482,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_admin_log_admin_invite_link" = "Invite users via link"; "lng_admin_log_admin_pin_messages" = "Pin messages"; "lng_admin_log_banned_edit_rank" = "Edit own tags"; +"lng_admin_log_banned_edit_rank_single" = "Edit own tag"; "lng_admin_log_admin_manage_topics" = "Manage topics"; "lng_admin_log_admin_create_topics" = "Create topics"; "lng_admin_log_admin_manage_calls" = "Manage video chats"; diff --git a/Telegram/SourceFiles/boxes/moderate_messages_box.cpp b/Telegram/SourceFiles/boxes/moderate_messages_box.cpp index b0b4fa0bde..2c6d7c510d 100644 --- a/Telegram/SourceFiles/boxes/moderate_messages_box.cpp +++ b/Telegram/SourceFiles/boxes/moderate_messages_box.cpp @@ -835,7 +835,7 @@ void CreateModerateMessagesBox( box, prepareFlags, disabledMessages, - { .isForum = peer->isForum() }); + { .isForum = peer->isForum(), .isUserSpecific = true }); computeRestrictions = getRestrictions; std::move(changes) | rpl::on_next([=] { ban->setChecked(true); diff --git a/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp index e955b6a5c3..72d88cacfe 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp @@ -769,7 +769,7 @@ void EditRestrictedBox::prepare() { this, prepareFlags, disabledMessages, - { .isForum = peer()->isForum() }); + { .isForum = peer()->isForum(), .isUserSpecific = true }); addControl(std::move(checkboxes), QMargins()); if (canSave() && peer()->canManageRanks()) { diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp index 0d48843cd3..9707ab564e 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp @@ -96,7 +96,9 @@ constexpr auto kDefaultChargeStars = 10; { Flag::AddParticipants, tr::lng_rights_chat_add_members(tr::now) }, { Flag::CreateTopics, tr::lng_rights_group_add_topics(tr::now) }, { Flag::PinMessages, tr::lng_rights_group_pin(tr::now) }, - { Flag::EditRank, tr::lng_rights_group_edit_rank(tr::now) }, + { Flag::EditRank, (options.isUserSpecific + ? tr::lng_rights_group_edit_rank_single + : tr::lng_rights_group_edit_rank)(tr::now) }, { Flag::ChangeInfo, tr::lng_rights_group_info(tr::now) }, }; if (!options.isForum) { diff --git a/Telegram/SourceFiles/core/click_handler_types.cpp b/Telegram/SourceFiles/core/click_handler_types.cpp index abf74aee4d..835a484151 100644 --- a/Telegram/SourceFiles/core/click_handler_types.cpp +++ b/Telegram/SourceFiles/core/click_handler_types.cpp @@ -485,9 +485,14 @@ void FormattedDateClickHandler::onClick(ClickContext context) const { }, &st::menuIconCopy); + const auto itemId = my.itemId; + const auto &owner = controller->session().data(); + const auto item = owner.message(itemId); + + const auto messageText = item ? item->originalText().text : QString(); menu->addAction( tr::lng_context_add_to_calendar(tr::now), - [date] { + [date, messageText] { const auto start = QDateTime::fromSecsSinceEpoch( date, Qt::UTC); @@ -505,6 +510,11 @@ void FormattedDateClickHandler::onClick(ClickContext context) const { summary.replace(';', u"\\;"_q); summary.replace(',', u"\\,"_q); summary.replace('\n', u"\\n"_q); + auto description = messageText; + description.replace('\\', u"\\\\"_q); + description.replace(';', u"\\;"_q); + description.replace(',', u"\\,"_q); + description.replace('\n', u"\\n"_q); const auto uid = base::RandomValue(); const auto content = u"BEGIN:VCALENDAR\r\n" "VERSION:2.0\r\n" @@ -513,8 +523,9 @@ void FormattedDateClickHandler::onClick(ClickContext context) const { "DTSTART:%1\r\n" "DTEND:%2\r\n" "DTSTAMP:%3\r\n" - "UID:telegram-%4-%6@telegram.org\r\n" + "UID:telegram-%4-%7@telegram.org\r\n" "SUMMARY:%5\r\n" + "DESCRIPTION:%6\r\n" "END:VEVENT\r\n" "END:VCALENDAR\r\n"_q .arg(start.toString(format)) @@ -522,6 +533,7 @@ void FormattedDateClickHandler::onClick(ClickContext context) const { .arg(now.toString(format)) .arg(date) .arg(summary) + .arg(description) .arg(uid, 0, 16); const auto dir = cWorkingDir() + u"tdata/temp"_q; QDir().mkpath(dir); @@ -537,9 +549,6 @@ void FormattedDateClickHandler::onClick(ClickContext context) const { }, &st::menuIconSchedule); - const auto itemId = my.itemId; - const auto &owner = controller->session().data(); - const auto item = owner.message(itemId); const auto canForward = item && !item->forbidsForward() && item->history()->peer->allowsForwarding(); diff --git a/Telegram/SourceFiles/data/data_chat_participant_status.h b/Telegram/SourceFiles/data/data_chat_participant_status.h index 4838876201..0d14508a1e 100644 --- a/Telegram/SourceFiles/data/data_chat_participant_status.h +++ b/Telegram/SourceFiles/data/data_chat_participant_status.h @@ -107,6 +107,7 @@ struct AdminRightsSetOptions { struct RestrictionsSetOptions { bool isForum = false; + bool isUserSpecific = false; }; [[nodiscard]] std::vector ListOfRestrictions( diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp index 4af8ef3bed..edba011b71 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp @@ -313,11 +313,12 @@ TextWithEntities GenerateAdminChangeText( QString GeneratePermissionsChangeText( ChatRestrictionsInfo newRights, - ChatRestrictionsInfo prevRights) { + ChatRestrictionsInfo prevRights, + bool isUserSpecific = false) { using Flag = ChatRestriction; using Flags = ChatRestrictions; - static auto phraseMap = std::map>{ + auto phraseMap = std::map>{ { Flag::ViewMessages, tr::lng_admin_log_banned_view_messages }, { Flag::SendOther, tr::lng_admin_log_banned_send_messages }, { Flag::SendPhotos, tr::lng_admin_log_banned_send_photos }, @@ -340,7 +341,9 @@ QString GeneratePermissionsChangeText( { Flag::AddParticipants, tr::lng_admin_log_admin_invite_users }, { Flag::CreateTopics, tr::lng_admin_log_admin_create_topics }, { Flag::PinMessages, tr::lng_admin_log_admin_pin_messages }, - { Flag::EditRank, tr::lng_admin_log_banned_edit_rank }, + { Flag::EditRank, isUserSpecific + ? tr::lng_admin_log_banned_edit_rank_single + : tr::lng_admin_log_banned_edit_rank }, }; return CollectChanges(phraseMap, prevRights.flags, newRights.flags); } @@ -397,7 +400,10 @@ TextWithEntities GeneratePermissionsChangeText( lt_until, TextWithEntities { untilText }, tr::marked); - const auto changes = GeneratePermissionsChangeText(newRights, prevRights); + const auto changes = GeneratePermissionsChangeText( + newRights, + prevRights, + true); if (!changes.isEmpty()) { result.text.append('\n' + changes); }