From 2a12d6037a3a9a37bb216f1ae95ac0f08f3622c2 Mon Sep 17 00:00:00 2001 From: Vitor Mattos Date: Thu, 12 Jan 2023 10:57:36 -0300 Subject: Parse stored recording notification Signed-off-by: Vitor Mattos --- lib/Notification/Notifier.php | 36 ++++++++++++++++++++++++++++++++++++ lib/Service/RecordingService.php | 33 ++------------------------------- 2 files changed, 38 insertions(+), 31 deletions(-) (limited to 'lib') diff --git a/lib/Notification/Notifier.php b/lib/Notification/Notifier.php index 46c6b7b77..52d08a89b 100644 --- a/lib/Notification/Notifier.php +++ b/lib/Notification/Notifier.php @@ -64,6 +64,7 @@ class Notifier implements INotifier { protected IUserManager $userManager; protected GuestManager $guestManager; private IShareManager $shareManager; + private IURLGenerator $urlGenerator; protected Manager $manager; protected ParticipantService $participantService; protected INotificationManager $notificationManager; @@ -84,6 +85,7 @@ class Notifier implements INotifier { IUserManager $userManager, GuestManager $guestManager, IShareManager $shareManager, + IURLGenerator $urlGenerator, Manager $manager, ParticipantService $participantService, INotificationManager $notificationManager, @@ -98,6 +100,7 @@ class Notifier implements INotifier { $this->userManager = $userManager; $this->guestManager = $guestManager; $this->shareManager = $shareManager; + $this->urlGenerator = $urlGenerator; $this->manager = $manager; $this->participantService = $participantService; $this->notificationManager = $notificationManager; @@ -248,6 +251,9 @@ class Notifier implements INotifier { ->setLink($this->url->linkToRouteAbsolute('spreed.Page.showCall', ['token' => $room->getToken()])); $subject = $notification->getSubject(); + if ($subject === 'record_file_stored') { + return $this->parseStoredRecording($notification, $room, $participant, $l); + } if ($subject === 'invitation') { return $this->parseInvitation($notification, $room, $l); } @@ -287,6 +293,36 @@ class Notifier implements INotifier { return $temp; } + private function parseStoredRecording(INotification $notification, Room $room, Participant $participant, IL10N $l): INOtification { + $shareAction = $notification->createAction() + ->setParsedLabel($l->t('Share to chat')) + ->setPrimary(true) + ->setLink( + $this->urlGenerator->linkToRouteAbsolute( + 'ocs.spreed.Chat.shareObjectToChat', + [ + 'apiVersion' => 'v1', + 'token' => $room->getToken() + ] + ), + IAction::TYPE_POST + ); + + $notification + ->setRichSubject( + $l->t('Record file of {call}'), + [ + 'call' => [ + 'type' => 'call', + 'id' => $room->getId(), + 'name' => $room->getDisplayName((string) $participant->getAttendee()->getId()), + 'call-type' => $this->getRoomType($room), + ], + ]) + ->addParsedAction($shareAction); + return $notification; + } + /** * @throws HintException */ diff --git a/lib/Service/RecordingService.php b/lib/Service/RecordingService.php index 38fbf5319..944e3c916 100644 --- a/lib/Service/RecordingService.php +++ b/lib/Service/RecordingService.php @@ -37,9 +37,6 @@ use OCP\Files\IMimeTypeDetector; use OCP\Files\IRootFolder; use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; -use OCP\IL10N; -use OCP\IURLGenerator; -use OCP\Notification\IAction; use OCP\Notification\IManager; class RecordingService { @@ -54,8 +51,6 @@ class RecordingService { private ParticipantService $participantService, private IRootFolder $rootFolder, private IManager $notificationManager, - private IL10N $l, - private IURLGenerator $urlGenerator, private Config $config, private RoomService $roomService ) { @@ -162,40 +157,16 @@ class RecordingService { $notification = $this->notificationManager->createNotification(); - $shareAction = $notification->createAction() - ->setParsedLabel($this->l->t('Share to chat')) - ->setPrimary(true) - ->setLink( - $this->urlGenerator->linkToRouteAbsolute( - 'spreed.Chat.shareObjectToChat', - [ - 'token' => $room->getToken() - ] - ), - IAction::TYPE_POST - ); - $notification ->setApp('spreed') ->setDateTime(new \DateTime()) ->setObject('chat', $room->getToken()) ->setUser($attendee->getActorId()) - ->setSubject('file', [ + ->setSubject('record_file_stored', [ 'objectType' => 'file', 'objectId' => $file->getId(), 'actorDisplayName' => $attendee->getDisplayName(), - ]) - ->setRichSubject( - $this->l->t('Record file of {call}'), - [ - 'call' => [ - 'type' => 'call', - 'id' => $room->getId(), - 'name' => $room->getDisplayName((string) $attendee->getId()), - 'call-type' => $this->getRoomType($room), - ], - ]) - ->addParsedAction($shareAction); + ]); $this->notificationManager->notify($notification); } -- cgit v1.2.3