Show anti-spam checkbox only to admins.

This commit is contained in:
John Preston 2022-12-06 22:50:54 +04:00
parent 273a2809cf
commit 74ecd44294

View file

@ -1187,12 +1187,15 @@ void ParticipantsBoxController::prepare() {
} }
Unexpected("Role in ParticipantsBoxController::prepare()"); Unexpected("Role in ParticipantsBoxController::prepare()");
}(); }();
if ((_role == Role::Admins) && _peer->isMegagroup()) { if (const auto megagroup = _peer->asMegagroup()) {
if ((_role == Role::Admins)
&& (megagroup->amCreator() || megagroup->hasAdminRights())) {
const auto validator = AntiSpamMenu::AntiSpamValidator( const auto validator = AntiSpamMenu::AntiSpamValidator(
_navigation->parentController(), _navigation->parentController(),
_peer->asChannel()); _peer->asChannel());
delegate()->peerListSetAboveWidget(validator.createButton()); delegate()->peerListSetAboveWidget(validator.createButton());
} }
}
delegate()->peerListSetSearchMode(PeerListSearchMode::Enabled); delegate()->peerListSetSearchMode(PeerListSearchMode::Enabled);
delegate()->peerListSetTitle(std::move(title)); delegate()->peerListSetTitle(std::move(title));
setDescriptionText(tr::lng_contacts_loading(tr::now)); setDescriptionText(tr::lng_contacts_loading(tr::now));