summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorVitor Mattos <vitor@php.rio>2023-01-12 10:57:36 -0300
committerVitor Mattos <vitor@php.rio>2023-01-14 10:02:23 -0300
commit2a12d6037a3a9a37bb216f1ae95ac0f08f3622c2 (patch)
treea44b4e42f43371cd02e90bad35c1356a9076677d /lib
parent2382c9a33e7b096af633e055b7823915ab58dada (diff)
Parse stored recording notification
Signed-off-by: Vitor Mattos <vitor@php.rio>
Diffstat (limited to 'lib')
-rw-r--r--lib/Notification/Notifier.php36
-rw-r--r--lib/Service/RecordingService.php33
2 files changed, 38 insertions, 31 deletions
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);
}