diff options
-rw-r--r-- | lib/Listener/RestrictStartingCalls.php | 12 | ||||
-rw-r--r-- | tests/php/Listener/RestrictStartingCallsTest.php | 2 |
2 files changed, 7 insertions, 7 deletions
diff --git a/lib/Listener/RestrictStartingCalls.php b/lib/Listener/RestrictStartingCalls.php index ed041ef0c..59e95639c 100644 --- a/lib/Listener/RestrictStartingCalls.php +++ b/lib/Listener/RestrictStartingCalls.php @@ -42,18 +42,16 @@ class RestrictStartingCalls { } public static function register(IEventDispatcher $dispatcher): void { - $dispatcher->addListener(Room::EVENT_BEFORE_SESSION_JOIN_CALL, static function (ModifyParticipantEvent $event) { - /** @var self $listener */ - $listener = \OC::$server->get(self::class); - $listener->checkStartCallPermissions($event); - }, 1000); + $dispatcher->addListener(Room::EVENT_BEFORE_SESSION_JOIN_CALL, [self::class, 'checkStartCallPermissions'], 1000); } /** * @param ModifyParticipantEvent $event * @throws ForbiddenException */ - public function checkStartCallPermissions(ModifyParticipantEvent $event): void { + public static function checkStartCallPermissions(ModifyParticipantEvent $event): void { + /** @var self $listener */ + $listener = \OC::$server->get(self::class); $room = $event->getRoom(); $participant = $event->getParticipant(); @@ -63,7 +61,7 @@ class RestrictStartingCalls { return; } - if (!$participant->canStartCall($this->config) && !$this->participantService->hasActiveSessionsInCall($room)) { + if (!$participant->canStartCall($listener->config) && !$listener->participantService->hasActiveSessionsInCall($room)) { throw new ForbiddenException('Can not start a call'); } } diff --git a/tests/php/Listener/RestrictStartingCallsTest.php b/tests/php/Listener/RestrictStartingCallsTest.php index b94da5a55..2ffbe04ab 100644 --- a/tests/php/Listener/RestrictStartingCallsTest.php +++ b/tests/php/Listener/RestrictStartingCallsTest.php @@ -97,7 +97,9 @@ class RestrictStartingCallsTest extends TestCase { $this->expectException(ForbiddenException::class); } + $this->overwriteService(RestrictStartingCalls::class, $this->listener); $this->listener->checkStartCallPermissions($event); + $this->restoreService(RestrictStartingCalls::class); if (!$throws) { self::assertTrue(true); |