diff --git a/Telegram/Resources/langs/rewrites/en.json b/Telegram/Resources/langs/rewrites/en.json index c7049018a..01d0e3698 100644 --- a/Telegram/Resources/langs/rewrites/en.json +++ b/Telegram/Resources/langs/rewrites/en.json @@ -144,6 +144,14 @@ "ktg_group_status_admin": "is admin", "ktg_too_many_accounts_warning": "Warning! Using too many accounts at the same time is not recommended due to higher memory comsumption and possible crashes because of it.\n\nYou sure you want to add a new account?", "ktg_account_add_anyway": "Add anyway", + "ktg_rights_chat_send_stickers": "Send stickers", + "ktg_rights_chat_send_gif": "Send GIFs", + "ktg_rights_chat_send_games": "Send games", + "ktg_rights_chat_use_inline": "Use inline bots", + "ktg_admin_log_banned_send_stickers": "Send stickers", + "ktg_admin_log_banned_send_gif": "Send GIFs", + "ktg_admin_log_banned_send_games": "Send games", + "ktg_admin_log_banned_use_inline": "Use inline bots", "ktg_forward_go_to_chat": "Go to chat", "ktg_settings_forward": "Forward", "ktg_settings_forward_retain_selection": "Retain selection after forward", diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp index eccf38c8b..1f7682347 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "boxes/peers/edit_peer_permissions_box.h" +#include "kotato/kotato_lang.h" #include "lang/lang_keys.h" #include "data/data_channel.h" #include "data/data_chat.h" @@ -108,21 +109,24 @@ void ApplyDependencies( std::vector> RestrictionLabels() { const auto langKeys = { - tr::lng_rights_chat_send_text, - tr::lng_rights_chat_send_media, - tr::lng_rights_chat_send_stickers, - tr::lng_rights_chat_send_links, - tr::lng_rights_chat_send_polls, - tr::lng_rights_chat_add_members, - tr::lng_rights_group_pin, - tr::lng_rights_group_info, + tr::lng_rights_chat_send_text(tr::now), + tr::lng_rights_chat_send_media(tr::now), + ktr("ktg_rights_chat_send_stickers"), + ktr("ktg_rights_chat_send_gif"), + ktr("ktg_rights_chat_send_games"), + ktr("ktg_rights_chat_use_inline"), + tr::lng_rights_chat_send_links(tr::now), + tr::lng_rights_chat_send_polls(tr::now), + tr::lng_rights_chat_add_members(tr::now), + tr::lng_rights_group_pin(tr::now), + tr::lng_rights_group_info(tr::now), }; std::vector> vector; const auto restrictions = Data::ListOfRestrictions(); auto i = 0; for (const auto &key : langKeys) { - vector.emplace_back(restrictions[i++], key(tr::now)); + vector.emplace_back(restrictions[i++], key); } return vector; } @@ -163,6 +167,7 @@ auto Dependencies(ChatRestrictions) using Flag = ChatRestriction; return { + /* // stickers <-> gifs { Flag::SendGifs, Flag::SendStickers }, { Flag::SendStickers, Flag::SendGifs }, @@ -177,10 +182,23 @@ auto Dependencies(ChatRestrictions) // stickers -> send_messages { Flag::SendStickers, Flag::SendMessages }, + */ // embed_links -> send_messages { Flag::EmbedLinks, Flag::SendMessages }, + // send_games -> send_messages + { Flag::SendGames, Flag::SendMessages }, + + // send_gifs -> send_messages + { Flag::SendGifs, Flag::SendMessages }, + + // send_inline -> send_messages + { Flag::SendInline, Flag::SendMessages }, + + // send_stickers -> send_messages + { Flag::SendStickers, Flag::SendMessages }, + // send_media -> send_messages { Flag::SendMedia, Flag::SendMessages }, @@ -285,11 +303,13 @@ ChatRestrictions FixDependentRestrictions(ChatRestrictions restrictions) { // Fix iOS bug of saving send_inline like embed_links. // We copy send_stickers to send_inline. + /* if (restrictions & ChatRestriction::SendStickers) { restrictions |= ChatRestriction::SendInline; } else { restrictions &= ~ChatRestriction::SendInline; } + */ // Apply the strictest. const auto fixOne = [&] { diff --git a/Telegram/SourceFiles/data/data_chat_participant_status.cpp b/Telegram/SourceFiles/data/data_chat_participant_status.cpp index e878775b5..554ed00cf 100644 --- a/Telegram/SourceFiles/data/data_chat_participant_status.cpp +++ b/Telegram/SourceFiles/data/data_chat_participant_status.cpp @@ -49,10 +49,10 @@ std::vector ListOfRestrictions() { return { Flag::SendMessages, Flag::SendMedia, - Flag::SendStickers - | Flag::SendGifs - | Flag::SendGames - | Flag::SendInline, + Flag::SendStickers, + Flag::SendGifs, + Flag::SendGames, + Flag::SendInline, Flag::EmbedLinks, Flag::SendPolls, Flag::InviteUsers, 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 87a501d30..375a0ebf1 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "history/admin_log/history_admin_log_item.h" +#include "kotato/kotato_lang.h" #include "history/admin_log/history_admin_log_inner.h" #include "history/view/history_view_element.h" #include "history/history_location_manager.h" @@ -180,6 +181,26 @@ const auto CollectChanges = []( + withPrefix(minusFlags & ~plusFlags, kMinus); }; +const auto CollectChangesKtg = [](auto &phraseMap, auto &ktgPhraseMap, auto plusFlags, auto minusFlags) { + auto withPrefix = [&ktgPhraseMap, &phraseMap](auto flags, QChar prefix) { + auto result = QString(); + for (auto &phrase : ktgPhraseMap) { + if (flags & phrase.first) { + result.append('\n' + (prefix + ktr(phrase.second))); + } + } + + for (auto &phrase : phraseMap) { + if (flags & phrase.first) { + result.append('\n' + (prefix + phrase.second(tr::now))); + } + } + return result; + }; + const auto kMinus = QChar(0x2212); + return withPrefix(plusFlags & ~minusFlags, '+') + withPrefix(minusFlags & ~plusFlags, kMinus); +}; + TextWithEntities GenerateAdminChangeText( not_null channel, const TextWithEntities &user, @@ -243,17 +264,19 @@ QString GeneratePermissionsChangeText( { Flag::ViewMessages, tr::lng_admin_log_banned_view_messages }, { Flag::SendMessages, tr::lng_admin_log_banned_send_messages }, { Flag::SendMedia, tr::lng_admin_log_banned_send_media }, - { Flag::SendStickers - | Flag::SendGifs - | Flag::SendInline - | Flag::SendGames, tr::lng_admin_log_banned_send_stickers }, { Flag::EmbedLinks, tr::lng_admin_log_banned_embed_links }, { Flag::SendPolls, tr::lng_admin_log_banned_send_polls }, { Flag::ChangeInfo, tr::lng_admin_log_admin_change_info }, { Flag::InviteUsers, tr::lng_admin_log_admin_invite_users }, { Flag::PinMessages, tr::lng_admin_log_admin_pin_messages }, }; - return CollectChanges(phraseMap, prevRights.flags, newRights.flags); + static auto ktgPhraseMap = std::map{ + { Flag::SendStickers, "ktg_admin_log_banned_send_stickers" }, + { Flag::SendGifs, "ktg_admin_log_banned_send_gif" }, + { Flag::SendInline, "ktg_admin_log_banned_use_inline" }, + { Flag::SendGames, "ktg_admin_log_banned_send_games" }, + }; + return CollectChangesKtg(phraseMap, ktgPhraseMap, prevRights.flags, newRights.flags); } TextWithEntities GeneratePermissionsChangeText( diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index f26d52691..d54a1df53 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -6836,9 +6836,11 @@ bool HistoryWidget::sendExistingDocument( not_null document, Api::SendOptions options, std::optional localId) { - const auto error = _peer - ? Data::RestrictionError(_peer, ChatRestriction::SendStickers) - : std::nullopt; + const auto error = !_peer + ? std::nullopt + : document->sticker() + ? Data::RestrictionError(_peer, ChatRestriction::SendStickers) + : Data::RestrictionError(_peer, ChatRestriction::SendGifs); if (error) { controller()->show( Ui::MakeInformBox(*error),