From 71aa1692c51ea845e70e74f498e201748fd10702 Mon Sep 17 00:00:00 2001 From: Vitor Mattos Date: Fri, 13 Jan 2023 13:44:58 -0300 Subject: Refactors after code review Signed-off-by: Vitor Mattos --- lib/Notification/Notifier.php | 4 ++-- lib/Service/RecordingService.php | 22 +++------------------- 2 files changed, 5 insertions(+), 21 deletions(-) (limited to 'lib') diff --git a/lib/Notification/Notifier.php b/lib/Notification/Notifier.php index 52d08a89b..936006a4b 100644 --- a/lib/Notification/Notifier.php +++ b/lib/Notification/Notifier.php @@ -293,7 +293,7 @@ class Notifier implements INotifier { return $temp; } - private function parseStoredRecording(INotification $notification, Room $room, Participant $participant, IL10N $l): INOtification { + private function parseStoredRecording(INotification $notification, Room $room, Participant $participant, IL10N $l): INotification { $shareAction = $notification->createAction() ->setParsedLabel($l->t('Share to chat')) ->setPrimary(true) @@ -310,7 +310,7 @@ class Notifier implements INotifier { $notification ->setRichSubject( - $l->t('Record file of {call}'), + $l->t('Recording for the call in {call} was uploaded.'), [ 'call' => [ 'type' => 'call', diff --git a/lib/Service/RecordingService.php b/lib/Service/RecordingService.php index 944e3c916..a20143d9d 100644 --- a/lib/Service/RecordingService.php +++ b/lib/Service/RecordingService.php @@ -31,6 +31,7 @@ use OCA\Talk\Config; use OCA\Talk\Exceptions\ParticipantNotFoundException; use OCA\Talk\Participant; use OCA\Talk\Room; +use OCP\AppFramework\Utility\ITimeFactory; use OCP\Files\File; use OCP\Files\Folder; use OCP\Files\IMimeTypeDetector; @@ -51,6 +52,7 @@ class RecordingService { private ParticipantService $participantService, private IRootFolder $rootFolder, private IManager $notificationManager, + private ITimeFactory $timeFactory, private Config $config, private RoomService $roomService ) { @@ -159,7 +161,7 @@ class RecordingService { $notification ->setApp('spreed') - ->setDateTime(new \DateTime()) + ->setDateTime($this->timeFactory->getDateTime()) ->setObject('chat', $room->getToken()) ->setUser($attendee->getActorId()) ->setSubject('record_file_stored', [ @@ -169,22 +171,4 @@ class RecordingService { ]); $this->notificationManager->notify($notification); } - - /** - * @param Room $room - * @return string - * @throws \InvalidArgumentException - */ - protected function getRoomType(Room $room): string { - switch ($room->getType()) { - case Room::TYPE_ONE_TO_ONE: - return 'one2one'; - case Room::TYPE_GROUP: - return 'group'; - case Room::TYPE_PUBLIC: - return 'public'; - default: - throw new \InvalidArgumentException('Unknown room type'); - } - } } -- cgit v1.2.3