mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-30 14:17:45 +00:00
Allow removing users invited by me.
This commit is contained in:
@@ -354,6 +354,16 @@ bool 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(
|
||||
not_null<UserData*> user) const
|
||||
-> std::optional<MTPChatAdminRights> {
|
||||
@@ -1436,6 +1446,8 @@ base::unique_qptr<Ui::PopupMenu> ParticipantsBoxController::rowContextMenu(
|
||||
tr::lng_context_restrict_user(tr::now),
|
||||
crl::guard(this, [=] { showRestricted(user); }));
|
||||
}
|
||||
}
|
||||
if (_additional.canRemoveUser(user)) {
|
||||
if (!_additional.isKicked(user)) {
|
||||
const auto isGroup = _peer->isChat() || _peer->isMegagroup();
|
||||
result->addAction(
|
||||
@@ -1806,7 +1818,7 @@ auto ParticipantsBoxController::computeType(
|
||||
: _additional.adminRights(user).has_value()
|
||||
? Rights::Admin
|
||||
: Rights::Normal;
|
||||
result.canRemove = _additional.canRestrictUser(user);
|
||||
result.canRemove = _additional.canRemoveUser(user);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@@ -88,6 +88,7 @@ public:
|
||||
[[nodiscard]] bool canEditAdmin(not_null<UserData*> user) const;
|
||||
[[nodiscard]] bool canAddOrEditAdmin(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(
|
||||
not_null<UserData*> user) const;
|
||||
QString adminRank(not_null<UserData*> user) const;
|
||||
|
Reference in New Issue
Block a user