diff options
author | Joas Schilling <coding@schilljs.com> | 2019-11-27 16:31:44 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2019-12-04 08:36:59 +0100 |
commit | 0e1d2b39b92c77d2c58ef60c525677957713e546 (patch) | |
tree | 745d723c175ff8ab2967b0e939f55a4d0d1da221 /lib/Notification/Listener.php | |
parent | ff7efea822e95e8927929140995ed5031bec5d80 (diff) |
Typed events for Talk
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Notification/Listener.php')
-rw-r--r-- | lib/Notification/Listener.php | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/lib/Notification/Listener.php b/lib/Notification/Listener.php index bb55d5ccf..f272335ac 100644 --- a/lib/Notification/Listener.php +++ b/lib/Notification/Listener.php @@ -22,14 +22,16 @@ declare(strict_types=1); namespace OCA\Talk\Notification; +use OCA\Talk\Events\AddParticipantsEvent; +use OCA\Talk\Events\JoinRoomUserEvent; +use OCA\Talk\Events\RoomEvent; use OCA\Talk\Room; use OCP\AppFramework\Utility\ITimeFactory; +use OCP\EventDispatcher\IEventDispatcher; use OCP\Notification\IManager; use OCP\ILogger; use OCP\IUser; use OCP\IUserSession; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\EventDispatcher\GenericEvent; class Listener { @@ -52,10 +54,9 @@ class Listener { $this->logger = $logger; } - public static function register(EventDispatcherInterface $dispatcher): void { - $listener = function(GenericEvent $event) { - /** @var Room $room */ - $room = $event->getSubject(); + public static function register(IEventDispatcher $dispatcher): void { + $listener = static function(AddParticipantsEvent $event) { + $room = $event->getRoom(); if ($room->getObjectType() === 'file') { return; @@ -63,37 +64,28 @@ class Listener { /** @var self $listener */ $listener = \OC::$server->query(self::class); - $listener->generateInvitation($room, $event->getArgument('users')); + $listener->generateInvitation($room, $event->getParticipants()); }; $dispatcher->addListener(Room::class . '::postAddUsers', $listener); - $listener = function(GenericEvent $event) { - /** @var Room $room */ - $room = $event->getSubject(); - + $listener = static function(JoinRoomUserEvent $event) { /** @var self $listener */ $listener = \OC::$server->query(self::class); - $listener->markInvitationRead($room); + $listener->markInvitationRead($event->getRoom()); }; $dispatcher->addListener(Room::class . '::postJoinRoom', $listener); - $listener = function(GenericEvent $event) { - /** @var Room $room */ - $room = $event->getSubject(); - + $listener = static function(RoomEvent $event) { /** @var self $listener */ $listener = \OC::$server->query(self::class); - $listener->generateCallNotifications($room); + $listener->generateCallNotifications($event->getRoom()); }; $dispatcher->addListener(Room::class . '::preSessionJoinCall', $listener); - $listener = function(GenericEvent $event) { - /** @var Room $room */ - $room = $event->getSubject(); - + $listener = static function(RoomEvent $event) { /** @var self $listener */ $listener = \OC::$server->query(self::class); - $listener->markCallNotificationsRead($room); + $listener->markCallNotificationsRead($event->getRoom()); }; $dispatcher->addListener(Room::class . '::postSessionJoinCall', $listener); } |