mirror of https://github.com/procxx/kepka.git
Allow removing users invited by me.
This commit is contained in:
parent
ca97e3c375
commit
63c6a1db82
|
@ -354,6 +354,16 @@ bool ParticipantsAdditionalData::canRestrictUser(
|
||||||
Unexpected("Peer in ParticipantsAdditionalData::canRestrictUser.");
|
Unexpected("Peer in ParticipantsAdditionalData::canRestrictUser.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ParticipantsAdditionalData::canRemoveUser(
|
||||||
|
not_null<UserData*> user) const {
|
||||||
|
if (canRestrictUser(user)) {
|
||||||
|
return true;
|
||||||
|
} else if (const auto chat = _peer->asChat()) {
|
||||||
|
return chat->invitedByMe.contains(user);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
auto ParticipantsAdditionalData::adminRights(
|
auto ParticipantsAdditionalData::adminRights(
|
||||||
not_null<UserData*> user) const
|
not_null<UserData*> user) const
|
||||||
-> std::optional<MTPChatAdminRights> {
|
-> std::optional<MTPChatAdminRights> {
|
||||||
|
@ -1436,6 +1446,8 @@ base::unique_qptr<Ui::PopupMenu> ParticipantsBoxController::rowContextMenu(
|
||||||
tr::lng_context_restrict_user(tr::now),
|
tr::lng_context_restrict_user(tr::now),
|
||||||
crl::guard(this, [=] { showRestricted(user); }));
|
crl::guard(this, [=] { showRestricted(user); }));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (_additional.canRemoveUser(user)) {
|
||||||
if (!_additional.isKicked(user)) {
|
if (!_additional.isKicked(user)) {
|
||||||
const auto isGroup = _peer->isChat() || _peer->isMegagroup();
|
const auto isGroup = _peer->isChat() || _peer->isMegagroup();
|
||||||
result->addAction(
|
result->addAction(
|
||||||
|
@ -1806,7 +1818,7 @@ auto ParticipantsBoxController::computeType(
|
||||||
: _additional.adminRights(user).has_value()
|
: _additional.adminRights(user).has_value()
|
||||||
? Rights::Admin
|
? Rights::Admin
|
||||||
: Rights::Normal;
|
: Rights::Normal;
|
||||||
result.canRemove = _additional.canRestrictUser(user);
|
result.canRemove = _additional.canRemoveUser(user);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,7 @@ public:
|
||||||
[[nodiscard]] bool canEditAdmin(not_null<UserData*> user) const;
|
[[nodiscard]] bool canEditAdmin(not_null<UserData*> user) const;
|
||||||
[[nodiscard]] bool canAddOrEditAdmin(not_null<UserData*> user) const;
|
[[nodiscard]] bool canAddOrEditAdmin(not_null<UserData*> user) const;
|
||||||
[[nodiscard]] bool canRestrictUser(not_null<UserData*> user) const;
|
[[nodiscard]] bool canRestrictUser(not_null<UserData*> user) const;
|
||||||
|
[[nodiscard]] bool canRemoveUser(not_null<UserData*> user) const;
|
||||||
[[nodiscard]] std::optional<MTPChatAdminRights> adminRights(
|
[[nodiscard]] std::optional<MTPChatAdminRights> adminRights(
|
||||||
not_null<UserData*> user) const;
|
not_null<UserData*> user) const;
|
||||||
QString adminRank(not_null<UserData*> user) const;
|
QString adminRank(not_null<UserData*> user) const;
|
||||||
|
|
Loading…
Reference in New Issue