summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorskalidindi53 <s.teja2004@gmail.com>2024-07-10 12:49:08 -0500
committerskalidindi53 <s.teja2004@gmail.com>2024-07-12 11:05:59 -0500
commitda33a4436cf423472008b85445d282ee559f56f4 (patch)
tree169f0e815228758e482a5feea980b560a87134b1 /lib
parent193b70eff9bb867e4611fe38ea06ff7407c4f03c (diff)
fix: Moderators no longer able to ban themselves or other moderatorsskalidindi53/12670/Moderators-banning-others/themselves
Signed-off-by: skalidindi53 <s.teja2004@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Service/BanService.php9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/Service/BanService.php b/lib/Service/BanService.php
index f36f9013e..5d8495db3 100644
--- a/lib/Service/BanService.php
+++ b/lib/Service/BanService.php
@@ -9,6 +9,7 @@ declare(strict_types=1);
namespace OCA\Talk\Service;
use DateTime;
+use OCA\Talk\Manager;
use OCA\Talk\Model\Ban;
use OCA\Talk\Model\BanMapper;
use OCP\AppFramework\Db\DoesNotExistException;
@@ -17,6 +18,8 @@ class BanService {
public function __construct(
protected BanMapper $banMapper,
+ protected Manager $manager,
+ protected ParticipantService $participantService,
) {
}
@@ -34,6 +37,12 @@ class BanService {
throw new \InvalidArgumentException('internalNote');
}
+ $bannedParticipant = $this->participantService->getParticipantByActor($this->manager->getRoomById($roomId), $bannedType, $bannedId);
+
+ if ($bannedParticipant->hasModeratorPermissions()) {
+ throw new \InvalidArgumentException('moderator');
+ }
+
$ban = new Ban();
$ban->setActorId($actorId);
$ban->setActorType($actorType);