mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Respected privacy setting for voice messages when they are forwarded.
This commit is contained in:
parent
c9aec6a170
commit
505e60545e
7 changed files with 47 additions and 10 deletions
|
@ -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_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_exceptions_list_title" = "Exceptions";
|
||||||
"lng_removed_list_title" = "Removed users";
|
"lng_removed_list_title" = "Removed users";
|
||||||
|
|
|
@ -7,6 +7,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
enum class UserRestriction {
|
||||||
|
SendVoiceMessages,
|
||||||
|
SendVideoMessages,
|
||||||
|
};
|
||||||
|
|
||||||
enum class ChatAdminRight {
|
enum class ChatAdminRight {
|
||||||
ChangeInfo = (1 << 0),
|
ChangeInfo = (1 << 0),
|
||||||
PostMessages = (1 << 1),
|
PostMessages = (1 << 1),
|
||||||
|
|
|
@ -918,6 +918,11 @@ QString MediaFile::errorTextForForward(not_null<PeerData*> peer) const {
|
||||||
ChatRestriction::SendMedia)) {
|
ChatRestriction::SendMedia)) {
|
||||||
return *error;
|
return *error;
|
||||||
}
|
}
|
||||||
|
if (const auto error = Data::RestrictionError(
|
||||||
|
peer,
|
||||||
|
UserRestriction::SendVideoMessages)) {
|
||||||
|
return *error;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (const auto error = Data::RestrictionError(
|
if (const auto error = Data::RestrictionError(
|
||||||
peer,
|
peer,
|
||||||
|
@ -929,6 +934,12 @@ QString MediaFile::errorTextForForward(not_null<PeerData*> peer) const {
|
||||||
peer,
|
peer,
|
||||||
ChatRestriction::SendMedia)) {
|
ChatRestriction::SendMedia)) {
|
||||||
return *error;
|
return *error;
|
||||||
|
} else if (_document->isVoiceMessage()) {
|
||||||
|
if (const auto error = Data::RestrictionError(
|
||||||
|
peer,
|
||||||
|
UserRestriction::SendVoiceMessages)) {
|
||||||
|
return *error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1125,10 +1125,21 @@ std::optional<QString> RestrictionError(
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<QString> RestrictionVoicesError(not_null<PeerData*> peer) {
|
std::optional<QString> RestrictionError(
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
UserRestriction restriction) {
|
||||||
const auto user = peer->asUser();
|
const auto user = peer->asUser();
|
||||||
if (user && !user->canReceiveVoices()) {
|
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;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ class ChatData;
|
||||||
class ChannelData;
|
class ChannelData;
|
||||||
|
|
||||||
enum class ChatRestriction;
|
enum class ChatRestriction;
|
||||||
|
enum class UserRestriction;
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class EmptyUserpic;
|
class EmptyUserpic;
|
||||||
|
@ -469,7 +470,9 @@ std::optional<QString> RestrictionError(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
ChatRestriction restriction);
|
ChatRestriction restriction);
|
||||||
|
|
||||||
std::optional<QString> RestrictionVoicesError(not_null<PeerData*> peer);
|
std::optional<QString> RestrictionError(
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
UserRestriction restriction);
|
||||||
|
|
||||||
void SetTopPinnedMessageId(not_null<PeerData*> peer, MsgId messageId);
|
void SetTopPinnedMessageId(not_null<PeerData*> peer, MsgId messageId);
|
||||||
[[nodiscard]] FullMsgId ResolveTopPinnedId(
|
[[nodiscard]] FullMsgId ResolveTopPinnedId(
|
||||||
|
|
|
@ -943,11 +943,14 @@ void HistoryWidget::initVoiceRecordBar() {
|
||||||
_voiceRecordBar->setStartRecordingFilter([=] {
|
_voiceRecordBar->setStartRecordingFilter([=] {
|
||||||
const auto error = [&]() -> std::optional<QString> {
|
const auto error = [&]() -> std::optional<QString> {
|
||||||
if (_peer) {
|
if (_peer) {
|
||||||
const auto type = ChatRestriction::SendMedia;
|
if (const auto error = Data::RestrictionError(
|
||||||
if (const auto error = Data::RestrictionError(_peer, type)) {
|
_peer,
|
||||||
|
ChatRestriction::SendMedia)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
if (const auto error = Data::RestrictionVoicesError(_peer)) {
|
if (const auto error = Data::RestrictionError(
|
||||||
|
_peer,
|
||||||
|
UserRestriction::SendVoiceMessages)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1967,11 +1967,14 @@ void ComposeControls::initVoiceRecordBar() {
|
||||||
const auto error = [&]() -> std::optional<QString> {
|
const auto error = [&]() -> std::optional<QString> {
|
||||||
const auto peer = _history ? _history->peer.get() : nullptr;
|
const auto peer = _history ? _history->peer.get() : nullptr;
|
||||||
if (!peer) {
|
if (!peer) {
|
||||||
const auto type = ChatRestriction::SendMedia;
|
if (const auto error = Data::RestrictionError(
|
||||||
if (const auto error = Data::RestrictionError(peer, type)) {
|
peer,
|
||||||
|
ChatRestriction::SendMedia)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
if (const auto error = Data::RestrictionVoicesError(peer)) {
|
if (const auto error = Data::RestrictionError(
|
||||||
|
peer,
|
||||||
|
UserRestriction::SendVoiceMessages)) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue