diff options
author | Joas Schilling <coding@schilljs.com> | 2020-10-22 15:36:21 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2020-10-30 12:38:45 +0300 |
commit | cc93851b17002a2855ddee2ac4c08a23701368b7 (patch) | |
tree | 2fd41e13a25d22826ebd96c79418e63477819fbb /lib/Listener | |
parent | b7c7838a8bde3622dca677da105a63890879df49 (diff) |
Move counting functions to participant service
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Listener')
-rw-r--r-- | lib/Listener/UserDeletedListener.php | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/Listener/UserDeletedListener.php b/lib/Listener/UserDeletedListener.php index 05ed7cfae..df94e835d 100644 --- a/lib/Listener/UserDeletedListener.php +++ b/lib/Listener/UserDeletedListener.php @@ -25,6 +25,7 @@ namespace OCA\Talk\Listener; use OCA\Talk\Manager; use OCA\Talk\Room; +use OCA\Talk\Service\ParticipantService; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; use OCP\User\Events\UserDeletedEvent; @@ -33,9 +34,13 @@ class UserDeletedListener implements IEventListener { /** @var Manager */ private $manager; + /** @var ParticipantService */ + private $participantService; - public function __construct(Manager $manager) { + public function __construct(Manager $manager, + ParticipantService $participantService) { $this->manager = $manager; + $this->participantService = $participantService; } public function handle(Event $event): void { @@ -49,7 +54,7 @@ class UserDeletedListener implements IEventListener { $rooms = $this->manager->getRoomsForUser($user->getUID()); foreach ($rooms as $room) { - if ($room->getNumberOfParticipants() === 1) { + if ($this->participantService->getNumberOfUsers($room) === 1) { $room->deleteRoom(); } else { $room->removeUser($user, Room::PARTICIPANT_REMOVED); |