diff options
author | Joas Schilling <coding@schilljs.com> | 2019-11-27 18:31:44 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2019-12-04 10:36:59 +0300 |
commit | 0e1d2b39b92c77d2c58ef60c525677957713e546 (patch) | |
tree | 745d723c175ff8ab2967b0e939f55a4d0d1da221 /lib/PublicShareAuth/Listener.php | |
parent | ff7efea822e95e8927929140995ed5031bec5d80 (diff) |
Typed events for Talk
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/PublicShareAuth/Listener.php')
-rw-r--r-- | lib/PublicShareAuth/Listener.php | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/lib/PublicShareAuth/Listener.php b/lib/PublicShareAuth/Listener.php index 1c4db6587..433dc41c8 100644 --- a/lib/PublicShareAuth/Listener.php +++ b/lib/PublicShareAuth/Listener.php @@ -23,11 +23,13 @@ declare(strict_types=1); namespace OCA\Talk\PublicShareAuth; +use OCA\Talk\Events\JoinRoomGuestEvent; +use OCA\Talk\Events\JoinRoomUserEvent; +use OCA\Talk\Events\RoomEvent; use OCA\Talk\Exceptions\ParticipantNotFoundException; use OCA\Talk\Participant; use OCA\Talk\Room; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\EventDispatcher\GenericEvent; +use OCP\EventDispatcher\IEventDispatcher; /** * Custom behaviour for rooms to request the password for a share. @@ -44,25 +46,19 @@ use Symfony\Component\EventDispatcher\GenericEvent; */ class Listener { - public static function register(EventDispatcherInterface $dispatcher): void { - $listener = function(GenericEvent $event) { - /** @var Room $room */ - $room = $event->getSubject(); - self::preventExtraUsersFromJoining($room, $event->getArgument('userId')); + public static function register(IEventDispatcher $dispatcher): void { + $listener = static function(JoinRoomUserEvent $event) { + self::preventExtraUsersFromJoining($event->getRoom(), $event->getUser()->getUID()); }; $dispatcher->addListener(Room::class . '::preJoinRoom', $listener); - $listener = function(GenericEvent $event) { - /** @var Room $room */ - $room = $event->getSubject(); - self::preventExtraGuestsFromJoining($room); + $listener = static function(JoinRoomGuestEvent $event) { + self::preventExtraGuestsFromJoining($event->getRoom()); }; $dispatcher->addListener(Room::class . '::preJoinRoomGuest', $listener); - $listener = function(GenericEvent $event) { - /** @var Room $room */ - $room = $event->getSubject(); - self::destroyRoomOnParticipantLeave($room); + $listener = static function(RoomEvent $event) { + self::destroyRoomOnParticipantLeave($event->getRoom()); }; $dispatcher->addListener(Room::class . '::postRemoveUser', $listener); $dispatcher->addListener(Room::class . '::postRemoveBySession', $listener); |