diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 2a950f23c..380316b62 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -2857,7 +2857,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_restricted_send_public_polls" = "Sorry, public polls can't be forwarded to channels."; -"lng_restricted_send_voices" = "{user} restricted sending of voice messages to them."; +"lng_restricted_send_voice_messages" = "{user} restricted sending of voice messages to them."; +"lng_restricted_send_video_messages" = "{user} restricted sending of video messages to them."; "lng_exceptions_list_title" = "Exceptions"; "lng_removed_list_title" = "Removed users"; diff --git a/Telegram/SourceFiles/data/data_chat_participant_status.h b/Telegram/SourceFiles/data/data_chat_participant_status.h index 7dff3e685..8c3e6d642 100644 --- a/Telegram/SourceFiles/data/data_chat_participant_status.h +++ b/Telegram/SourceFiles/data/data_chat_participant_status.h @@ -7,6 +7,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once +enum class UserRestriction { + SendVoiceMessages, + SendVideoMessages, +}; + enum class ChatAdminRight { ChangeInfo = (1 << 0), PostMessages = (1 << 1), diff --git a/Telegram/SourceFiles/data/data_media_types.cpp b/Telegram/SourceFiles/data/data_media_types.cpp index 1d45fdc90..dcce02a3f 100644 --- a/Telegram/SourceFiles/data/data_media_types.cpp +++ b/Telegram/SourceFiles/data/data_media_types.cpp @@ -918,6 +918,11 @@ QString MediaFile::errorTextForForward(not_null peer) const { ChatRestriction::SendMedia)) { return *error; } + if (const auto error = Data::RestrictionError( + peer, + UserRestriction::SendVideoMessages)) { + return *error; + } } else { if (const auto error = Data::RestrictionError( peer, @@ -929,6 +934,12 @@ QString MediaFile::errorTextForForward(not_null peer) const { peer, ChatRestriction::SendMedia)) { return *error; + } else if (_document->isVoiceMessage()) { + if (const auto error = Data::RestrictionError( + peer, + UserRestriction::SendVoiceMessages)) { + return *error; + } } return QString(); } diff --git a/Telegram/SourceFiles/data/data_peer.cpp b/Telegram/SourceFiles/data/data_peer.cpp index bc7c82cfb..e88826cfb 100644 --- a/Telegram/SourceFiles/data/data_peer.cpp +++ b/Telegram/SourceFiles/data/data_peer.cpp @@ -1125,10 +1125,21 @@ std::optional RestrictionError( return std::nullopt; } -std::optional RestrictionVoicesError(not_null peer) { +std::optional RestrictionError( + not_null peer, + UserRestriction restriction) { const auto user = peer->asUser(); if (user && !user->canReceiveVoices()) { - return tr::lng_restricted_send_voices(tr::now, lt_user, user->name); + const auto voice = restriction == UserRestriction::SendVoiceMessages; + if (voice + || (restriction == UserRestriction::SendVideoMessages)) { + return (voice + ? tr::lng_restricted_send_voice_messages + : tr::lng_restricted_send_video_messages)( + tr::now, + lt_user, + user->name); + } } return std::nullopt; } diff --git a/Telegram/SourceFiles/data/data_peer.h b/Telegram/SourceFiles/data/data_peer.h index cdc8fb324..89341ad5d 100644 --- a/Telegram/SourceFiles/data/data_peer.h +++ b/Telegram/SourceFiles/data/data_peer.h @@ -19,6 +19,7 @@ class ChatData; class ChannelData; enum class ChatRestriction; +enum class UserRestriction; namespace Ui { class EmptyUserpic; @@ -469,7 +470,9 @@ std::optional RestrictionError( not_null peer, ChatRestriction restriction); -std::optional RestrictionVoicesError(not_null peer); +std::optional RestrictionError( + not_null peer, + UserRestriction restriction); void SetTopPinnedMessageId(not_null peer, MsgId messageId); [[nodiscard]] FullMsgId ResolveTopPinnedId( diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 6bba223c3..fd4a23c29 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -943,11 +943,14 @@ void HistoryWidget::initVoiceRecordBar() { _voiceRecordBar->setStartRecordingFilter([=] { const auto error = [&]() -> std::optional { if (_peer) { - const auto type = ChatRestriction::SendMedia; - if (const auto error = Data::RestrictionError(_peer, type)) { + if (const auto error = Data::RestrictionError( + _peer, + ChatRestriction::SendMedia)) { return error; } - if (const auto error = Data::RestrictionVoicesError(_peer)) { + if (const auto error = Data::RestrictionError( + _peer, + UserRestriction::SendVoiceMessages)) { return error; } } diff --git a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp index 5da0009d0..cd4f94a06 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp @@ -1967,11 +1967,14 @@ void ComposeControls::initVoiceRecordBar() { const auto error = [&]() -> std::optional { const auto peer = _history ? _history->peer.get() : nullptr; if (!peer) { - const auto type = ChatRestriction::SendMedia; - if (const auto error = Data::RestrictionError(peer, type)) { + if (const auto error = Data::RestrictionError( + peer, + ChatRestriction::SendMedia)) { return error; } - if (const auto error = Data::RestrictionVoicesError(peer)) { + if (const auto error = Data::RestrictionError( + peer, + UserRestriction::SendVoiceMessages)) { return error; } }