mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 14:38:15 +00:00
Prepare legacy group restrictions checking.
This commit is contained in:
@@ -64,10 +64,8 @@ void SendDataCommon::addToHistory(
|
||||
QString SendDataCommon::getErrorOnSend(
|
||||
const Result *owner,
|
||||
not_null<History*> history) const {
|
||||
if (const auto megagroup = history->peer->asMegagroup()) {
|
||||
if (megagroup->restricted(ChatRestriction::f_send_messages)) {
|
||||
return lang(lng_restricted_send_message);
|
||||
}
|
||||
if (history->peer->amRestricted(ChatRestriction::f_send_messages)) {
|
||||
return lang(lng_restricted_send_message);
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
@@ -146,10 +144,8 @@ void SendPhoto::addToHistory(
|
||||
QString SendPhoto::getErrorOnSend(
|
||||
const Result *owner,
|
||||
not_null<History*> history) const {
|
||||
if (const auto megagroup = history->peer->asMegagroup()) {
|
||||
if (megagroup->restricted(ChatRestriction::f_send_media)) {
|
||||
return lang(lng_restricted_send_media);
|
||||
}
|
||||
if (history->peer->amRestricted(ChatRestriction::f_send_media)) {
|
||||
return lang(lng_restricted_send_media);
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
@@ -181,17 +177,15 @@ void SendFile::addToHistory(
|
||||
QString SendFile::getErrorOnSend(
|
||||
const Result *owner,
|
||||
not_null<History*> history) const {
|
||||
if (const auto megagroup = history->peer->asMegagroup()) {
|
||||
if (megagroup->restricted(ChatRestriction::f_send_media)) {
|
||||
return lang(lng_restricted_send_media);
|
||||
} else if (megagroup->restricted(ChatRestriction::f_send_stickers)
|
||||
&& (_document->sticker() != nullptr)) {
|
||||
return lang(lng_restricted_send_stickers);
|
||||
} else if (megagroup->restricted(ChatRestriction::f_send_gifs)
|
||||
&& _document->isAnimation()
|
||||
&& !_document->isVideoMessage()) {
|
||||
return lang(lng_restricted_send_gifs);
|
||||
}
|
||||
if (history->peer->amRestricted(ChatRestriction::f_send_media)) {
|
||||
return lang(lng_restricted_send_media);
|
||||
} else if (history->peer->amRestricted(ChatRestriction::f_send_stickers)
|
||||
&& (_document->sticker() != nullptr)) {
|
||||
return lang(lng_restricted_send_stickers);
|
||||
} else if (history->peer->amRestricted(ChatRestriction::f_send_gifs)
|
||||
&& _document->isAnimation()
|
||||
&& !_document->isVideoMessage()) {
|
||||
return lang(lng_restricted_send_gifs);
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
@@ -222,10 +216,8 @@ void SendGame::addToHistory(
|
||||
QString SendGame::getErrorOnSend(
|
||||
const Result *owner,
|
||||
not_null<History*> history) const {
|
||||
if (auto megagroup = history->peer->asMegagroup()) {
|
||||
if (megagroup->restricted(ChatRestriction::f_send_games)) {
|
||||
return lang(lng_restricted_send_inline);
|
||||
}
|
||||
if (history->peer->amRestricted(ChatRestriction::f_send_games)) {
|
||||
return lang(lng_restricted_send_inline);
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
@@ -58,7 +58,7 @@ Inner::Inner(QWidget *parent, not_null<Window::Controller*> controller) : TWidge
|
||||
update();
|
||||
}
|
||||
});
|
||||
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(Notify::PeerUpdate::Flag::ChannelRightsChanged, [this](const Notify::PeerUpdate &update) {
|
||||
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(Notify::PeerUpdate::Flag::RightsChanged, [this](const Notify::PeerUpdate &update) {
|
||||
if (update.peer == _inlineQueryPeer) {
|
||||
auto isRestricted = (_restrictedLabel != nullptr);
|
||||
if (isRestricted != isRestrictedView()) {
|
||||
@@ -80,8 +80,8 @@ void Inner::visibleTopBottomUpdated(
|
||||
}
|
||||
|
||||
void Inner::checkRestrictedPeer() {
|
||||
if (auto megagroup = _inlineQueryPeer ? _inlineQueryPeer->asMegagroup() : nullptr) {
|
||||
if (megagroup->restricted(ChatRestriction::f_send_inline)) {
|
||||
if (_inlineQueryPeer) {
|
||||
if (_inlineQueryPeer->amRestricted(ChatRestriction::f_send_inline)) {
|
||||
if (!_restrictedLabel) {
|
||||
_restrictedLabel.create(this, lang(lng_restricted_send_inline), Ui::FlatLabel::InitType::Simple, st::stickersRestrictedLabel);
|
||||
_restrictedLabel->show();
|
||||
|
Reference in New Issue
Block a user