@@ -44,105 +44,105 @@ |
||
| 44 | 44 | * @package OCA\Comments\Controller |
| 45 | 45 | */ |
| 46 | 46 | class Notifications extends Controller { |
| 47 | - /** @var IRootFolder */ |
|
| 48 | - protected $rootFolder; |
|
| 47 | + /** @var IRootFolder */ |
|
| 48 | + protected $rootFolder; |
|
| 49 | 49 | |
| 50 | - /** @var ICommentsManager */ |
|
| 51 | - protected $commentsManager; |
|
| 50 | + /** @var ICommentsManager */ |
|
| 51 | + protected $commentsManager; |
|
| 52 | 52 | |
| 53 | - /** @var IURLGenerator */ |
|
| 54 | - protected $urlGenerator; |
|
| 53 | + /** @var IURLGenerator */ |
|
| 54 | + protected $urlGenerator; |
|
| 55 | 55 | |
| 56 | - /** @var IManager */ |
|
| 57 | - protected $notificationManager; |
|
| 56 | + /** @var IManager */ |
|
| 57 | + protected $notificationManager; |
|
| 58 | 58 | |
| 59 | - /** @var IUserSession */ |
|
| 60 | - protected $userSession; |
|
| 59 | + /** @var IUserSession */ |
|
| 60 | + protected $userSession; |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * Notifications constructor. |
|
| 64 | - * |
|
| 65 | - * @param string $appName |
|
| 66 | - * @param IRequest $request |
|
| 67 | - * @param ICommentsManager $commentsManager |
|
| 68 | - * @param IRootFolder $rootFolder |
|
| 69 | - * @param IURLGenerator $urlGenerator |
|
| 70 | - * @param IManager $notificationManager |
|
| 71 | - * @param IUserSession $userSession |
|
| 72 | - */ |
|
| 73 | - public function __construct( |
|
| 74 | - $appName, |
|
| 75 | - IRequest $request, |
|
| 76 | - ICommentsManager $commentsManager, |
|
| 77 | - IRootFolder $rootFolder, |
|
| 78 | - IURLGenerator $urlGenerator, |
|
| 79 | - IManager $notificationManager, |
|
| 80 | - IUserSession $userSession |
|
| 81 | - ) { |
|
| 82 | - parent::__construct($appName, $request); |
|
| 83 | - $this->commentsManager = $commentsManager; |
|
| 84 | - $this->rootFolder = $rootFolder; |
|
| 85 | - $this->urlGenerator = $urlGenerator; |
|
| 86 | - $this->notificationManager = $notificationManager; |
|
| 87 | - $this->userSession = $userSession; |
|
| 88 | - } |
|
| 62 | + /** |
|
| 63 | + * Notifications constructor. |
|
| 64 | + * |
|
| 65 | + * @param string $appName |
|
| 66 | + * @param IRequest $request |
|
| 67 | + * @param ICommentsManager $commentsManager |
|
| 68 | + * @param IRootFolder $rootFolder |
|
| 69 | + * @param IURLGenerator $urlGenerator |
|
| 70 | + * @param IManager $notificationManager |
|
| 71 | + * @param IUserSession $userSession |
|
| 72 | + */ |
|
| 73 | + public function __construct( |
|
| 74 | + $appName, |
|
| 75 | + IRequest $request, |
|
| 76 | + ICommentsManager $commentsManager, |
|
| 77 | + IRootFolder $rootFolder, |
|
| 78 | + IURLGenerator $urlGenerator, |
|
| 79 | + IManager $notificationManager, |
|
| 80 | + IUserSession $userSession |
|
| 81 | + ) { |
|
| 82 | + parent::__construct($appName, $request); |
|
| 83 | + $this->commentsManager = $commentsManager; |
|
| 84 | + $this->rootFolder = $rootFolder; |
|
| 85 | + $this->urlGenerator = $urlGenerator; |
|
| 86 | + $this->notificationManager = $notificationManager; |
|
| 87 | + $this->userSession = $userSession; |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - /** |
|
| 91 | - * @PublicPage |
|
| 92 | - * @NoCSRFRequired |
|
| 93 | - * |
|
| 94 | - * @param string $id the comment ID |
|
| 95 | - * @return Response |
|
| 96 | - */ |
|
| 97 | - public function view($id) { |
|
| 98 | - $currentUser = $this->userSession->getUser(); |
|
| 99 | - if (!$currentUser instanceof IUser) { |
|
| 100 | - return new RedirectResponse( |
|
| 101 | - $this->urlGenerator->linkToRoute('core.login.showLoginForm', [ |
|
| 102 | - 'redirect_url' => $this->urlGenerator->linkToRoute( |
|
| 103 | - 'comments.Notifications.view', |
|
| 104 | - ['id' => $id] |
|
| 105 | - ), |
|
| 106 | - ]) |
|
| 107 | - ); |
|
| 108 | - } |
|
| 90 | + /** |
|
| 91 | + * @PublicPage |
|
| 92 | + * @NoCSRFRequired |
|
| 93 | + * |
|
| 94 | + * @param string $id the comment ID |
|
| 95 | + * @return Response |
|
| 96 | + */ |
|
| 97 | + public function view($id) { |
|
| 98 | + $currentUser = $this->userSession->getUser(); |
|
| 99 | + if (!$currentUser instanceof IUser) { |
|
| 100 | + return new RedirectResponse( |
|
| 101 | + $this->urlGenerator->linkToRoute('core.login.showLoginForm', [ |
|
| 102 | + 'redirect_url' => $this->urlGenerator->linkToRoute( |
|
| 103 | + 'comments.Notifications.view', |
|
| 104 | + ['id' => $id] |
|
| 105 | + ), |
|
| 106 | + ]) |
|
| 107 | + ); |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - try { |
|
| 111 | - $comment = $this->commentsManager->get($id); |
|
| 112 | - if($comment->getObjectType() !== 'files') { |
|
| 113 | - return new NotFoundResponse(); |
|
| 114 | - } |
|
| 115 | - $userFolder = $this->rootFolder->getUserFolder($currentUser->getUID()); |
|
| 116 | - $files = $userFolder->getById((int)$comment->getObjectId()); |
|
| 110 | + try { |
|
| 111 | + $comment = $this->commentsManager->get($id); |
|
| 112 | + if($comment->getObjectType() !== 'files') { |
|
| 113 | + return new NotFoundResponse(); |
|
| 114 | + } |
|
| 115 | + $userFolder = $this->rootFolder->getUserFolder($currentUser->getUID()); |
|
| 116 | + $files = $userFolder->getById((int)$comment->getObjectId()); |
|
| 117 | 117 | |
| 118 | - $this->markProcessed($comment, $currentUser); |
|
| 118 | + $this->markProcessed($comment, $currentUser); |
|
| 119 | 119 | |
| 120 | - if (empty($files)) { |
|
| 121 | - return new NotFoundResponse(); |
|
| 122 | - } |
|
| 120 | + if (empty($files)) { |
|
| 121 | + return new NotFoundResponse(); |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - $url = $this->urlGenerator->linkToRouteAbsolute( |
|
| 125 | - 'files.viewcontroller.showFile', |
|
| 126 | - [ 'fileid' => $comment->getObjectId() ] |
|
| 127 | - ); |
|
| 124 | + $url = $this->urlGenerator->linkToRouteAbsolute( |
|
| 125 | + 'files.viewcontroller.showFile', |
|
| 126 | + [ 'fileid' => $comment->getObjectId() ] |
|
| 127 | + ); |
|
| 128 | 128 | |
| 129 | - return new RedirectResponse($url); |
|
| 130 | - } catch (\Exception $e) { |
|
| 131 | - return new NotFoundResponse(); |
|
| 132 | - } |
|
| 133 | - } |
|
| 129 | + return new RedirectResponse($url); |
|
| 130 | + } catch (\Exception $e) { |
|
| 131 | + return new NotFoundResponse(); |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - /** |
|
| 136 | - * Marks the notification about a comment as processed |
|
| 137 | - * @param IComment $comment |
|
| 138 | - * @param IUser $currentUser |
|
| 139 | - */ |
|
| 140 | - protected function markProcessed(IComment $comment, IUser $currentUser) { |
|
| 141 | - $notification = $this->notificationManager->createNotification(); |
|
| 142 | - $notification->setApp('comments') |
|
| 143 | - ->setObject('comment', $comment->getId()) |
|
| 144 | - ->setSubject('mention') |
|
| 145 | - ->setUser($currentUser->getUID()); |
|
| 146 | - $this->notificationManager->markProcessed($notification); |
|
| 147 | - } |
|
| 135 | + /** |
|
| 136 | + * Marks the notification about a comment as processed |
|
| 137 | + * @param IComment $comment |
|
| 138 | + * @param IUser $currentUser |
|
| 139 | + */ |
|
| 140 | + protected function markProcessed(IComment $comment, IUser $currentUser) { |
|
| 141 | + $notification = $this->notificationManager->createNotification(); |
|
| 142 | + $notification->setApp('comments') |
|
| 143 | + ->setObject('comment', $comment->getId()) |
|
| 144 | + ->setSubject('mention') |
|
| 145 | + ->setUser($currentUser->getUID()); |
|
| 146 | + $this->notificationManager->markProcessed($notification); |
|
| 147 | + } |
|
| 148 | 148 | } |
@@ -109,11 +109,11 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | try { |
| 111 | 111 | $comment = $this->commentsManager->get($id); |
| 112 | - if($comment->getObjectType() !== 'files') { |
|
| 112 | + if ($comment->getObjectType() !== 'files') { |
|
| 113 | 113 | return new NotFoundResponse(); |
| 114 | 114 | } |
| 115 | 115 | $userFolder = $this->rootFolder->getUserFolder($currentUser->getUID()); |
| 116 | - $files = $userFolder->getById((int)$comment->getObjectId()); |
|
| 116 | + $files = $userFolder->getById((int) $comment->getObjectId()); |
|
| 117 | 117 | |
| 118 | 118 | $this->markProcessed($comment, $currentUser); |
| 119 | 119 | |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | $url = $this->urlGenerator->linkToRouteAbsolute( |
| 125 | 125 | 'files.viewcontroller.showFile', |
| 126 | - [ 'fileid' => $comment->getObjectId() ] |
|
| 126 | + ['fileid' => $comment->getObjectId()] |
|
| 127 | 127 | ); |
| 128 | 128 | |
| 129 | 129 | return new RedirectResponse($url); |