From c3737499c42d02e0ba610775a5928e0125bb9f0d Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Mon, 27 Jan 2020 09:24:57 +0100 Subject: [PATCH] [User] Kick and ban only available with correct membership --- lib/src/user.dart | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/src/user.dart b/lib/src/user.dart index 7bcb215..7489f19 100644 --- a/lib/src/user.dart +++ b/lib/src/user.dart @@ -149,11 +149,17 @@ class User extends Event { /// The newest presence of this user if there is any and null if not. Presence get presence => room.client.presences[id]; - /// Whether the client is allowed to ban/unban this user. - bool get canBan => room.canBan && powerLevel < room.ownPowerLevel; + /// Whether the client is able to ban/unban this user. + bool get canBan => + membership != Membership.ban && + room.canBan && + powerLevel < room.ownPowerLevel; - /// Whether the client is allowed to kick this user. - bool get canKick => room.canKick && powerLevel < room.ownPowerLevel; + /// Whether the client is able to kick this user. + bool get canKick => + [Membership.join, Membership.invite].contains(membership) && + room.canKick && + powerLevel < room.ownPowerLevel; /// Whether the client is allowed to change the power level of this user. /// Please be aware that you can only set the power level to at least your own!