diff options
author | Joas Schilling <coding@schilljs.com> | 2020-10-26 17:49:00 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2020-10-30 12:38:51 +0300 |
commit | a11b907435fdc844a207589d8f8a4cb1583453a5 (patch) | |
tree | 2a465ec8b07fef6b4d1b26ef351277fe46fbfdf9 /lib/Notification | |
parent | 3c61bd47491980e8bd11bb66cf36b354a5212f34 (diff) |
Remove last participant modifying functions from Room object
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Notification')
-rw-r--r-- | lib/Notification/Listener.php | 7 | ||||
-rw-r--r-- | lib/Notification/Notifier.php | 15 |
2 files changed, 16 insertions, 6 deletions
diff --git a/lib/Notification/Listener.php b/lib/Notification/Listener.php index a0e056427..a56d47980 100644 --- a/lib/Notification/Listener.php +++ b/lib/Notification/Listener.php @@ -27,6 +27,7 @@ use OCA\Talk\Events\AddParticipantsEvent; use OCA\Talk\Events\JoinRoomUserEvent; use OCA\Talk\Events\RoomEvent; use OCA\Talk\Room; +use OCA\Talk\Service\ParticipantService; use OCP\AppFramework\Utility\ITimeFactory; use OCP\EventDispatcher\IEventDispatcher; use OCP\Notification\IManager; @@ -38,6 +39,8 @@ class Listener { /** @var IManager */ protected $notificationManager; + /** @var ParticipantService */ + protected $participantsService; /** @var IEventDispatcher */ protected $dispatcher; /** @var IUserSession */ @@ -51,11 +54,13 @@ class Listener { protected $shouldSendCallNotification = false; public function __construct(IManager $notificationManager, + ParticipantService $participantsService, IEventDispatcher $dispatcher, IUserSession $userSession, ITimeFactory $timeFactory, LoggerInterface $logger) { $this->notificationManager = $notificationManager; + $this->participantsService = $participantsService; $this->dispatcher = $dispatcher; $this->userSession = $userSession; $this->timeFactory = $timeFactory; @@ -241,7 +246,7 @@ class Listener { return; } - $userIds = $room->getNotInCallUserIds(); + $userIds = $this->participantsService->getParticipantUserIdsNotInCall($room); foreach ($userIds as $userId) { if ($actorId === $userId) { continue; diff --git a/lib/Notification/Notifier.php b/lib/Notification/Notifier.php index a6a6e5be5..fa1da6ec0 100644 --- a/lib/Notification/Notifier.php +++ b/lib/Notification/Notifier.php @@ -32,6 +32,7 @@ use OCA\Talk\GuestManager; use OCA\Talk\Manager; use OCA\Talk\Participant; use OCA\Talk\Room; +use OCA\Talk\Service\ParticipantService; use OCP\Comments\ICommentsManager; use OCP\Comments\NotFoundException; use OCP\IL10N; @@ -65,6 +66,8 @@ class Notifier implements INotifier { private $shareManager; /** @var Manager */ protected $manager; + /** @var ParticipantService */ + protected $participantService; /** @var INotificationManager */ protected $notificationManager; /** @var ICommentsManager */ @@ -86,6 +89,7 @@ class Notifier implements INotifier { GuestManager $guestManager, IShareManager $shareManager, Manager $manager, + ParticipantService $participantService, INotificationManager $notificationManager, CommentsManager $commentManager, MessageParser $messageParser, @@ -97,6 +101,7 @@ class Notifier implements INotifier { $this->guestManager = $guestManager; $this->shareManager = $shareManager; $this->manager = $manager; + $this->participantService = $participantService; $this->notificationManager = $notificationManager; $this->commentManager = $commentManager; $this->messageParser = $messageParser; @@ -488,7 +493,7 @@ class Notifier implements INotifier { $roomName = $room->getDisplayName($notification->getUser()); if ($room->getType() === Room::ONE_TO_ONE_CALL) { $subject = $l->t('{user} invited you to a private conversation'); - if ($room->hasSessionsInCall()) { + if ($this->participantService->hasActiveSessionsInCall($room)) { $notification = $this->addActionButton($notification, $l->t('Join call')); } else { $notification = $this->addActionButton($notification, $l->t('View chat'), false); @@ -513,7 +518,7 @@ class Notifier implements INotifier { ); } elseif (\in_array($room->getType(), [Room::GROUP_CALL, Room::PUBLIC_CALL], true)) { $subject = $l->t('{user} invited you to a group conversation: {call}'); - if ($room->hasSessionsInCall()) { + if ($this->participantService->hasActiveSessionsInCall($room)) { $notification = $this->addActionButton($notification, $l->t('Join call')); } else { $notification = $this->addActionButton($notification, $l->t('View chat'), false); @@ -562,7 +567,7 @@ class Notifier implements INotifier { $calleeId = $parameters['callee']; $user = $this->userManager->get($calleeId); if ($user instanceof IUser) { - if ($this->notificationManager->isPreparingPushNotification() || $room->hasSessionsInCall()) { + if ($this->notificationManager->isPreparingPushNotification() || $this->participantService->hasActiveSessionsInCall($room)) { $notification = $this->addActionButton($notification, $l->t('Answer call')); $subject = $l->t('{user} wants to talk with you'); } else { @@ -591,7 +596,7 @@ class Notifier implements INotifier { throw new AlreadyProcessedException(); } } elseif (\in_array($room->getType(), [Room::GROUP_CALL, Room::PUBLIC_CALL], true)) { - if ($this->notificationManager->isPreparingPushNotification() || $room->hasSessionsInCall()) { + if ($this->notificationManager->isPreparingPushNotification() || $this->participantService->hasActiveSessionsInCall($room)) { $notification = $this->addActionButton($notification, $l->t('Join call')); $subject = $l->t('A group call has started in {call}'); } else { @@ -647,7 +652,7 @@ class Notifier implements INotifier { throw new AlreadyProcessedException(); } - $callIsActive = $this->notificationManager->isPreparingPushNotification() || $room->hasSessionsInCall(); + $callIsActive = $this->notificationManager->isPreparingPushNotification() || $this->participantService->hasActiveSessionsInCall($room); if ($callIsActive) { $notification = $this->addActionButton($notification, $l->t('Answer call')); } else { |