diff options
author | Vitor Mattos <vitor@php.rio> | 2023-01-18 16:55:00 -0300 |
---|---|---|
committer | Vitor Mattos <vitor@php.rio> | 2023-01-18 16:55:00 -0300 |
commit | cb967754abd840dd353127a087d7c85c6dba7c80 (patch) | |
tree | 9d8351ed0e4fc37bae67f20c6b025f5e25a4f756 /lib/Notification/Notifier.php | |
parent | aed32de2c7423d701dda28e49478483481bd28e9 (diff) |
Fixes to share stored recording
Signed-off-by: Vitor Mattos <vitor@php.rio>
Diffstat (limited to 'lib/Notification/Notifier.php')
-rw-r--r-- | lib/Notification/Notifier.php | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/lib/Notification/Notifier.php b/lib/Notification/Notifier.php index f79abbd88..b9e65147e 100644 --- a/lib/Notification/Notifier.php +++ b/lib/Notification/Notifier.php @@ -41,6 +41,7 @@ use OCA\Talk\Webinary; use OCP\AppFramework\Utility\ITimeFactory; use OCP\Comments\ICommentsManager; use OCP\Comments\NotFoundException; +use OCP\Files\IRootFolder; use OCP\HintException; use OCP\IL10N; use OCP\IURLGenerator; @@ -69,7 +70,8 @@ class Notifier implements INotifier { protected INotificationManager $notificationManager; protected ICommentsManager $commentManager; protected MessageParser $messageParser; - private IURLGenerator $urlGenerator; + protected IURLGenerator $urlGenerator; + protected IRootFolder $rootFolder; protected ITimeFactory $timeFactory; protected Definitions $definitions; protected AddressHandler $addressHandler; @@ -91,6 +93,7 @@ class Notifier implements INotifier { CommentsManager $commentManager, MessageParser $messageParser, IURLGenerator $urlGenerator, + IRootFolder $rootFolder, ITimeFactory $timeFactory, Definitions $definitions, AddressHandler $addressHandler) { @@ -106,6 +109,7 @@ class Notifier implements INotifier { $this->commentManager = $commentManager; $this->messageParser = $messageParser; $this->urlGenerator = $urlGenerator; + $this->rootFolder = $rootFolder; $this->timeFactory = $timeFactory; $this->definitions = $definitions; $this->addressHandler = $addressHandler; @@ -300,20 +304,24 @@ class Notifier implements INotifier { IL10N $l ): INotification { $parameters = $notification->getSubjectParameters(); + try { + $userFolder = $this->rootFolder->getUserFolder($notification->getUser()); + /** @var \OCP\Files\File[] */ + $files = $userFolder->getById($parameters['objectId']); + $file = array_shift($files); + } catch (\Throwable $th) { + throw new AlreadyProcessedException(); + } $shareAction = $notification->createAction() ->setParsedLabel($l->t('Share to chat')) ->setPrimary(true) ->setLink( - $this->urlGenerator->linkToRouteAbsolute( - 'ocs.spreed.Chat.shareObjectToChat', + $this->urlGenerator->linkToOCSRouteAbsolute( + 'spreed.Recording.shareToChat', [ 'apiVersion' => 'v1', - 'objectType' => 'file', - 'objectId' => $notification->getObjectId(), - 'metaData' => json_encode([ - 'name' => $parameters['name'], - 'path' => $parameters['name'], - ]), + 'fileId' => $file->getId(), + 'timestamp' => $notification->getDateTime()->getTimestamp(), 'token' => $room->getToken() ] ), @@ -322,12 +330,12 @@ class Notifier implements INotifier { $dismissAction = $notification->createAction() ->setParsedLabel($l->t('Dismiss notification')) ->setLink( - $this->urlGenerator->linkToRouteAbsolute( - 'ocs.spreed.Recording.notificationDismiss', + $this->urlGenerator->linkToOCSRouteAbsolute( + 'spreed.Recording.notificationDismiss', [ 'apiVersion' => 'v1', 'token' => $room->getToken(), - 'dateTime' => $notification->getDateTime()->format('U'), + 'timestamp' => $notification->getDateTime()->getTimestamp(), ] ), IAction::TYPE_DELETE |