aboutsummaryrefslogtreecommitdiffstats
path: root/apps/comments
diff options
context:
space:
mode:
Diffstat (limited to 'apps/comments')
-rw-r--r--apps/comments/composer/composer/autoload_classmap.php2
-rw-r--r--apps/comments/composer/composer/autoload_static.php6
-rw-r--r--apps/comments/l10n/ar.js1
-rw-r--r--apps/comments/l10n/ar.json1
-rw-r--r--apps/comments/l10n/et_EE.js15
-rw-r--r--apps/comments/l10n/et_EE.json15
-rw-r--r--apps/comments/l10n/gl.js9
-rw-r--r--apps/comments/l10n/gl.json9
-rw-r--r--apps/comments/lib/Activity/Filter.php38
-rw-r--r--apps/comments/lib/Activity/Listener.php5
-rw-r--r--apps/comments/lib/Activity/Provider.php2
-rw-r--r--apps/comments/lib/Activity/Setting.php51
-rw-r--r--apps/comments/lib/AppInfo/Application.php3
-rw-r--r--apps/comments/lib/Collaboration/CommentersSorter.php10
-rw-r--r--apps/comments/lib/Controller/NotificationsController.php (renamed from apps/comments/lib/Controller/Notifications.php)6
-rw-r--r--apps/comments/lib/EventHandler.php22
-rw-r--r--apps/comments/lib/Listener/CommentsEntityEventListener.php13
-rw-r--r--apps/comments/lib/MaxAutoCompleteResultsInitialState.php4
-rw-r--r--apps/comments/lib/Notification/Listener.php23
-rw-r--r--apps/comments/lib/Search/CommentsSearchProvider.php13
-rw-r--r--apps/comments/lib/Search/Result.php11
-rw-r--r--apps/comments/tests/Unit/AppInfo/ApplicationTest.php5
-rw-r--r--apps/comments/tests/Unit/Controller/NotificationsTest.php6
23 files changed, 100 insertions, 170 deletions
diff --git a/apps/comments/composer/composer/autoload_classmap.php b/apps/comments/composer/composer/autoload_classmap.php
index 6afc14d07a1..61def2ecc46 100644
--- a/apps/comments/composer/composer/autoload_classmap.php
+++ b/apps/comments/composer/composer/autoload_classmap.php
@@ -14,7 +14,7 @@ return array(
'OCA\\Comments\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php',
'OCA\\Comments\\Capabilities' => $baseDir . '/../lib/Capabilities.php',
'OCA\\Comments\\Collaboration\\CommentersSorter' => $baseDir . '/../lib/Collaboration/CommentersSorter.php',
- 'OCA\\Comments\\Controller\\Notifications' => $baseDir . '/../lib/Controller/Notifications.php',
+ 'OCA\\Comments\\Controller\\NotificationsController' => $baseDir . '/../lib/Controller/NotificationsController.php',
'OCA\\Comments\\EventHandler' => $baseDir . '/../lib/EventHandler.php',
'OCA\\Comments\\Listener\\CommentsEntityEventListener' => $baseDir . '/../lib/Listener/CommentsEntityEventListener.php',
'OCA\\Comments\\Listener\\LoadAdditionalScripts' => $baseDir . '/../lib/Listener/LoadAdditionalScripts.php',
diff --git a/apps/comments/composer/composer/autoload_static.php b/apps/comments/composer/composer/autoload_static.php
index 0f832e1849b..9732ee9f4ca 100644
--- a/apps/comments/composer/composer/autoload_static.php
+++ b/apps/comments/composer/composer/autoload_static.php
@@ -7,14 +7,14 @@ namespace Composer\Autoload;
class ComposerStaticInitComments
{
public static $prefixLengthsPsr4 = array (
- 'O' =>
+ 'O' =>
array (
'OCA\\Comments\\' => 13,
),
);
public static $prefixDirsPsr4 = array (
- 'OCA\\Comments\\' =>
+ 'OCA\\Comments\\' =>
array (
0 => __DIR__ . '/..' . '/../lib',
),
@@ -29,7 +29,7 @@ class ComposerStaticInitComments
'OCA\\Comments\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php',
'OCA\\Comments\\Capabilities' => __DIR__ . '/..' . '/../lib/Capabilities.php',
'OCA\\Comments\\Collaboration\\CommentersSorter' => __DIR__ . '/..' . '/../lib/Collaboration/CommentersSorter.php',
- 'OCA\\Comments\\Controller\\Notifications' => __DIR__ . '/..' . '/../lib/Controller/Notifications.php',
+ 'OCA\\Comments\\Controller\\NotificationsController' => __DIR__ . '/..' . '/../lib/Controller/NotificationsController.php',
'OCA\\Comments\\EventHandler' => __DIR__ . '/..' . '/../lib/EventHandler.php',
'OCA\\Comments\\Listener\\CommentsEntityEventListener' => __DIR__ . '/..' . '/../lib/Listener/CommentsEntityEventListener.php',
'OCA\\Comments\\Listener\\LoadAdditionalScripts' => __DIR__ . '/..' . '/../lib/Listener/LoadAdditionalScripts.php',
diff --git a/apps/comments/l10n/ar.js b/apps/comments/l10n/ar.js
index 5a0554515a9..8f2eaf9b8c8 100644
--- a/apps/comments/l10n/ar.js
+++ b/apps/comments/l10n/ar.js
@@ -19,6 +19,7 @@ OC.L10N.register(
"No comments yet, start the conversation!" : "لا يوجد تعليقات, ابدأ النقاش الآن!",
"No more messages" : "لامزيد من الرسائل",
"Retry" : "أعد المحاولة",
+ "Failed to mark comments as read" : "إخفاق في تعيين ملاحظات كمقرؤة",
"Unable to load the comments list" : "تعذر تحميل قائمة التعليقات",
"_%n unread comment_::_%n unread comments_" : ["%n تعليق غير مقروء","%n تعليق غير مقروء","تعليقان غير مقروءة","%n تعليقات غير مقروء","%n تعليق غير مقروء","%n تعليق غير مقروء"],
"_1 new comment_::_{unread} new comments_" : ["1 تعليق جديد","1 تعليق جديد","{unread} تعليقات جديدة","{unread} تعليقات جديدة","{unread} تعليقات جديدة","{unread} تعليقات جديدة"],
diff --git a/apps/comments/l10n/ar.json b/apps/comments/l10n/ar.json
index c4e63b4da6b..7f1da8e4393 100644
--- a/apps/comments/l10n/ar.json
+++ b/apps/comments/l10n/ar.json
@@ -17,6 +17,7 @@
"No comments yet, start the conversation!" : "لا يوجد تعليقات, ابدأ النقاش الآن!",
"No more messages" : "لامزيد من الرسائل",
"Retry" : "أعد المحاولة",
+ "Failed to mark comments as read" : "إخفاق في تعيين ملاحظات كمقرؤة",
"Unable to load the comments list" : "تعذر تحميل قائمة التعليقات",
"_%n unread comment_::_%n unread comments_" : ["%n تعليق غير مقروء","%n تعليق غير مقروء","تعليقان غير مقروءة","%n تعليقات غير مقروء","%n تعليق غير مقروء","%n تعليق غير مقروء"],
"_1 new comment_::_{unread} new comments_" : ["1 تعليق جديد","1 تعليق جديد","{unread} تعليقات جديدة","{unread} تعليقات جديدة","{unread} تعليقات جديدة","{unread} تعليقات جديدة"],
diff --git a/apps/comments/l10n/et_EE.js b/apps/comments/l10n/et_EE.js
index fed1952f83b..269c7cdd9c4 100644
--- a/apps/comments/l10n/et_EE.js
+++ b/apps/comments/l10n/et_EE.js
@@ -9,12 +9,25 @@ OC.L10N.register(
"%1$s commented on %2$s" : "%1$s kommenteeris %2$s",
"{author} commented on {file}" : "{author} kommenteeris faili {file}",
"<strong>Comments</strong> for files" : "<strong>Kommentaarid</strong> failidele",
+ "You were mentioned on \"{file}\", in a comment by a user that has since been deleted" : "Sind mainis faili \"{file}\" kommentaaris kasutaja, kes on praeguseks kustutatud.",
+ "{user} mentioned you in a comment on \"{file}\"" : "{user} mainis sind faili \"{file}\" kommentaaris",
+ "Files app plugin to add comments to files" : "Failid rakenduse laiendus failidele kommentaaride lisamiseks",
"Edit comment" : "Muuda kommentaari",
"Delete comment" : "Kustuta kommentaar",
- "No comments yet, start the conversation!" : "Kommentaare veel pole, alusta vestlust",
+ "Cancel edit" : "Loobu muutmisest",
+ "Post comment" : "Postita kommentaar",
+ "No comments yet, start the conversation!" : "Kommentaare veel pole, alusta vestlust!",
+ "No more messages" : "Rohkem teateid pole",
"Retry" : "Proovi uuesti",
+ "Failed to mark comments as read" : "Kommentaaride loetuks märkimine ebaõnnestus",
+ "Unable to load the comments list" : "Kommentaaride loendi laadimine ebaõnnestus",
"_%n unread comment_::_%n unread comments_" : ["%n lugemata kommentaar","%n lugemata kommentaari"],
+ "_1 new comment_::_{unread} new comments_" : ["1 uus kommentaar","{unread} uus kommentaar"],
"Comment" : "Kommentaar",
+ "An error occurred while trying to edit the comment" : "Kommentaari muutmisel tekkis tõrge",
+ "Comment deleted" : "Kommentaar kustutatud",
+ "An error occurred while trying to delete the comment" : "Kommentaari kustutamisel tekkis tõrge",
+ "An error occurred while trying to create the comment" : "Kommentaari lisamisel tekkis tõrge",
"%1$s commented" : "%1$s kommenteeris"
},
"nplurals=2; plural=(n != 1);");
diff --git a/apps/comments/l10n/et_EE.json b/apps/comments/l10n/et_EE.json
index 88d0906771e..31ac5007e9f 100644
--- a/apps/comments/l10n/et_EE.json
+++ b/apps/comments/l10n/et_EE.json
@@ -7,12 +7,25 @@
"%1$s commented on %2$s" : "%1$s kommenteeris %2$s",
"{author} commented on {file}" : "{author} kommenteeris faili {file}",
"<strong>Comments</strong> for files" : "<strong>Kommentaarid</strong> failidele",
+ "You were mentioned on \"{file}\", in a comment by a user that has since been deleted" : "Sind mainis faili \"{file}\" kommentaaris kasutaja, kes on praeguseks kustutatud.",
+ "{user} mentioned you in a comment on \"{file}\"" : "{user} mainis sind faili \"{file}\" kommentaaris",
+ "Files app plugin to add comments to files" : "Failid rakenduse laiendus failidele kommentaaride lisamiseks",
"Edit comment" : "Muuda kommentaari",
"Delete comment" : "Kustuta kommentaar",
- "No comments yet, start the conversation!" : "Kommentaare veel pole, alusta vestlust",
+ "Cancel edit" : "Loobu muutmisest",
+ "Post comment" : "Postita kommentaar",
+ "No comments yet, start the conversation!" : "Kommentaare veel pole, alusta vestlust!",
+ "No more messages" : "Rohkem teateid pole",
"Retry" : "Proovi uuesti",
+ "Failed to mark comments as read" : "Kommentaaride loetuks märkimine ebaõnnestus",
+ "Unable to load the comments list" : "Kommentaaride loendi laadimine ebaõnnestus",
"_%n unread comment_::_%n unread comments_" : ["%n lugemata kommentaar","%n lugemata kommentaari"],
+ "_1 new comment_::_{unread} new comments_" : ["1 uus kommentaar","{unread} uus kommentaar"],
"Comment" : "Kommentaar",
+ "An error occurred while trying to edit the comment" : "Kommentaari muutmisel tekkis tõrge",
+ "Comment deleted" : "Kommentaar kustutatud",
+ "An error occurred while trying to delete the comment" : "Kommentaari kustutamisel tekkis tõrge",
+ "An error occurred while trying to create the comment" : "Kommentaari lisamisel tekkis tõrge",
"%1$s commented" : "%1$s kommenteeris"
},"pluralForm" :"nplurals=2; plural=(n != 1);"
} \ No newline at end of file
diff --git a/apps/comments/l10n/gl.js b/apps/comments/l10n/gl.js
index d1551536aea..a17aed3fb9f 100644
--- a/apps/comments/l10n/gl.js
+++ b/apps/comments/l10n/gl.js
@@ -9,16 +9,17 @@ OC.L10N.register(
"%1$s commented on %2$s" : "%1$s comentados en %2$s",
"{author} commented on {file}" : "{author} comentou en {file}",
"<strong>Comments</strong> for files" : "<strong>Comentarios</strong> para ficheiros",
- "You were mentioned on \"{file}\", in a comment by a user that has since been deleted" : "Mencionáronte en \"{ficheiro}\", nun comentario dun usuario que xa foi eliminado",
- "{user} mentioned you in a comment on \"{file}\"" : "{user} mencionoute nun comentario en \"{file}\"",
- "Files app plugin to add comments to files" : "Engadido da aplicación de ficheiros para engadir comentarios aos ficheiros",
+ "You were mentioned on \"{file}\", in a comment by a user that has since been deleted" : "Mencionárono en «{file}», nun comentario dun usuario que xa foi eliminado",
+ "{user} mentioned you in a comment on \"{file}\"" : "{user} mencionouno a vostede nun comentario en «{file}»",
+ "Files app plugin to add comments to files" : "Complemento da aplicación de ficheiros para engadir comentarios aos ficheiros",
"Edit comment" : "Editar comentario",
"Delete comment" : "Eliminar comentario",
"Cancel edit" : "Cancelar a edición",
"Post comment" : "Publicar comentario",
"No comments yet, start the conversation!" : "Aínda non hai comentarios, comeza a conversa!",
"No more messages" : "Non hai máis mensaxes",
- "Retry" : "Volver tentar",
+ "Retry" : "Tentar de novo",
+ "Failed to mark comments as read" : "Produciuse un fallo ao marcar os comentarios como lidos",
"Unable to load the comments list" : "Non é posíbel cargar a lista de comentarios",
"_%n unread comment_::_%n unread comments_" : ["%n comentario sen ler","%n comentarios sen ler"],
"_1 new comment_::_{unread} new comments_" : ["1 comentario novo","{unread} comentarios novos"],
diff --git a/apps/comments/l10n/gl.json b/apps/comments/l10n/gl.json
index ceda2ec017c..ca1278dd2d0 100644
--- a/apps/comments/l10n/gl.json
+++ b/apps/comments/l10n/gl.json
@@ -7,16 +7,17 @@
"%1$s commented on %2$s" : "%1$s comentados en %2$s",
"{author} commented on {file}" : "{author} comentou en {file}",
"<strong>Comments</strong> for files" : "<strong>Comentarios</strong> para ficheiros",
- "You were mentioned on \"{file}\", in a comment by a user that has since been deleted" : "Mencionáronte en \"{ficheiro}\", nun comentario dun usuario que xa foi eliminado",
- "{user} mentioned you in a comment on \"{file}\"" : "{user} mencionoute nun comentario en \"{file}\"",
- "Files app plugin to add comments to files" : "Engadido da aplicación de ficheiros para engadir comentarios aos ficheiros",
+ "You were mentioned on \"{file}\", in a comment by a user that has since been deleted" : "Mencionárono en «{file}», nun comentario dun usuario que xa foi eliminado",
+ "{user} mentioned you in a comment on \"{file}\"" : "{user} mencionouno a vostede nun comentario en «{file}»",
+ "Files app plugin to add comments to files" : "Complemento da aplicación de ficheiros para engadir comentarios aos ficheiros",
"Edit comment" : "Editar comentario",
"Delete comment" : "Eliminar comentario",
"Cancel edit" : "Cancelar a edición",
"Post comment" : "Publicar comentario",
"No comments yet, start the conversation!" : "Aínda non hai comentarios, comeza a conversa!",
"No more messages" : "Non hai máis mensaxes",
- "Retry" : "Volver tentar",
+ "Retry" : "Tentar de novo",
+ "Failed to mark comments as read" : "Produciuse un fallo ao marcar os comentarios como lidos",
"Unable to load the comments list" : "Non é posíbel cargar a lista de comentarios",
"_%n unread comment_::_%n unread comments_" : ["%n comentario sen ler","%n comentarios sen ler"],
"_1 new comment_::_{unread} new comments_" : ["1 comentario novo","{unread} comentarios novos"],
diff --git a/apps/comments/lib/Activity/Filter.php b/apps/comments/lib/Activity/Filter.php
index efd8d5140ae..2b6e898f599 100644
--- a/apps/comments/lib/Activity/Filter.php
+++ b/apps/comments/lib/Activity/Filter.php
@@ -27,64 +27,42 @@ use OCP\IL10N;
use OCP\IURLGenerator;
class Filter implements IFilter {
-
- /** @var IL10N */
- protected $l;
-
- /** @var IURLGenerator */
- protected $url;
+ protected IL10N $l;
+ protected IURLGenerator $url;
public function __construct(IL10N $l, IURLGenerator $url) {
$this->l = $l;
$this->url = $url;
}
- /**
- * @return string Lowercase a-z only identifier
- * @since 11.0.0
- */
- public function getIdentifier() {
+ public function getIdentifier(): string {
return 'comments';
}
- /**
- * @return string A translated string
- * @since 11.0.0
- */
- public function getName() {
+ public function getName(): string {
return $this->l->t('Comments');
}
- /**
- * @return int
- * @since 11.0.0
- */
- public function getPriority() {
+ public function getPriority(): int {
return 40;
}
- /**
- * @return string Full URL to an icon, empty string when none is given
- * @since 11.0.0
- */
- public function getIcon() {
+ public function getIcon(): string {
return $this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/comment.svg'));
}
/**
* @param string[] $types
* @return string[] An array of allowed apps from which activities should be displayed
- * @since 11.0.0
*/
- public function filterTypes(array $types) {
+ public function filterTypes(array $types): array {
return $types;
}
/**
* @return string[] An array of allowed apps from which activities should be displayed
- * @since 11.0.0
*/
- public function allowedApps() {
+ public function allowedApps(): array {
return ['comments'];
}
}
diff --git a/apps/comments/lib/Activity/Listener.php b/apps/comments/lib/Activity/Listener.php
index 69315b6ac00..a066ccdefc1 100644
--- a/apps/comments/lib/Activity/Listener.php
+++ b/apps/comments/lib/Activity/Listener.php
@@ -59,10 +59,7 @@ class Listener {
$this->shareHelper = $shareHelper;
}
- /**
- * @param CommentsEvent $event
- */
- public function commentEvent(CommentsEvent $event) {
+ public function commentEvent(CommentsEvent $event): void {
if ($event->getComment()->getObjectType() !== 'files'
|| $event->getEvent() !== CommentsEvent::EVENT_ADD
|| !$this->appManager->isInstalled('activity')) {
diff --git a/apps/comments/lib/Activity/Provider.php b/apps/comments/lib/Activity/Provider.php
index 8e65732f4a7..7ec22c68c16 100644
--- a/apps/comments/lib/Activity/Provider.php
+++ b/apps/comments/lib/Activity/Provider.php
@@ -58,7 +58,7 @@ class Provider implements IProvider {
* @throws \InvalidArgumentException
* @since 11.0.0
*/
- public function parse($language, IEvent $event, IEvent $previousEvent = null) {
+ public function parse($language, IEvent $event, IEvent $previousEvent = null): IEvent {
if ($event->getApp() !== 'comments') {
throw new \InvalidArgumentException();
}
diff --git a/apps/comments/lib/Activity/Setting.php b/apps/comments/lib/Activity/Setting.php
index c0d91c244a6..3352bf2a59b 100644
--- a/apps/comments/lib/Activity/Setting.php
+++ b/apps/comments/lib/Activity/Setting.php
@@ -26,72 +26,37 @@ use OCP\Activity\ISetting;
use OCP\IL10N;
class Setting implements ISetting {
+ protected IL10N $l;
- /** @var IL10N */
- protected $l;
-
- /**
- * @param IL10N $l
- */
public function __construct(IL10N $l) {
$this->l = $l;
}
- /**
- * @return string Lowercase a-z and underscore only identifier
- * @since 11.0.0
- */
- public function getIdentifier() {
+ public function getIdentifier(): string {
return 'comments';
}
- /**
- * @return string A translated string
- * @since 11.0.0
- */
- public function getName() {
+ public function getName(): string {
return $this->l->t('<strong>Comments</strong> for files');
}
- /**
- * @return int whether the filter should be rather on the top or bottom of
- * the admin section. The filters are arranged in ascending order of the
- * priority values. It is required to return a value between 0 and 100.
- * @since 11.0.0
- */
- public function getPriority() {
+ public function getPriority(): int {
return 50;
}
- /**
- * @return bool True when the option can be changed for the stream
- * @since 11.0.0
- */
- public function canChangeStream() {
+ public function canChangeStream(): bool {
return true;
}
- /**
- * @return bool True when the option can be changed for the stream
- * @since 11.0.0
- */
- public function isDefaultEnabledStream() {
+ public function isDefaultEnabledStream(): bool {
return true;
}
- /**
- * @return bool True when the option can be changed for the mail
- * @since 11.0.0
- */
- public function canChangeMail() {
+ public function canChangeMail(): bool {
return true;
}
- /**
- * @return bool True when the option can be changed for the stream
- * @since 11.0.0
- */
- public function isDefaultEnabledMail() {
+ public function isDefaultEnabledMail(): bool {
return false;
}
}
diff --git a/apps/comments/lib/AppInfo/Application.php b/apps/comments/lib/AppInfo/Application.php
index 527c5d99fc3..bfd66c43ecd 100644
--- a/apps/comments/lib/AppInfo/Application.php
+++ b/apps/comments/lib/AppInfo/Application.php
@@ -28,7 +28,6 @@ namespace OCA\Comments\AppInfo;
use Closure;
use OCA\Comments\Capabilities;
-use OCA\Comments\Controller\Notifications;
use OCA\Comments\EventHandler;
use OCA\Comments\Listener\CommentsEntityEventListener;
use OCA\Comments\Listener\LoadAdditionalScripts;
@@ -58,8 +57,6 @@ class Application extends App implements IBootstrap {
public function register(IRegistrationContext $context): void {
$context->registerCapability(Capabilities::class);
- $context->registerServiceAlias('NotificationsController', Notifications::class);
-
$context->registerEventListener(
LoadAdditionalScriptsEvent::class,
LoadAdditionalScripts::class
diff --git a/apps/comments/lib/Collaboration/CommentersSorter.php b/apps/comments/lib/Collaboration/CommentersSorter.php
index 8723b132e03..b7c993b4f20 100644
--- a/apps/comments/lib/Collaboration/CommentersSorter.php
+++ b/apps/comments/lib/Collaboration/CommentersSorter.php
@@ -27,14 +27,13 @@ use OCP\Collaboration\AutoComplete\ISorter;
use OCP\Comments\ICommentsManager;
class CommentersSorter implements ISorter {
-
private ICommentsManager $commentsManager;
public function __construct(ICommentsManager $commentsManager) {
$this->commentsManager = $commentsManager;
}
- public function getId() {
+ public function getId(): string {
return 'commenters';
}
@@ -42,10 +41,10 @@ class CommentersSorter implements ISorter {
* Sorts people who commented on the given item atop (descelating) of the
* others
*
- * @param array $sortArray
+ * @param array &$sortArray
* @param array $context
*/
- public function sort(array &$sortArray, array $context) {
+ public function sort(array &$sortArray, array $context): void {
$commenters = $this->retrieveCommentsInformation($context['itemType'], $context['itemId']);
if (count($commenters) === 0) {
return;
@@ -76,6 +75,9 @@ class CommentersSorter implements ISorter {
}
}
+ /**
+ * @return array<string, array<string, int>>
+ */
protected function retrieveCommentsInformation(string $type, string $id): array {
$comments = $this->commentsManager->getForObject($type, $id);
if (count($comments) === 0) {
diff --git a/apps/comments/lib/Controller/Notifications.php b/apps/comments/lib/Controller/NotificationsController.php
index ba61a0d33cd..41a9541a684 100644
--- a/apps/comments/lib/Controller/Notifications.php
+++ b/apps/comments/lib/Controller/NotificationsController.php
@@ -38,11 +38,11 @@ use OCP\IUserSession;
use OCP\Notification\IManager;
/**
- * Class Notifications
+ * Class NotificationsController
*
* @package OCA\Comments\Controller
*/
-class Notifications extends Controller {
+class NotificationsController extends Controller {
protected IRootFolder $rootFolder;
protected ICommentsManager $commentsManager;
@@ -51,7 +51,7 @@ class Notifications extends Controller {
protected IUserSession $userSession;
/**
- * Notifications constructor.
+ * NotificationsController constructor.
*/
public function __construct(
string $appName,
diff --git a/apps/comments/lib/EventHandler.php b/apps/comments/lib/EventHandler.php
index 6027a24b026..722e3b8cc72 100644
--- a/apps/comments/lib/EventHandler.php
+++ b/apps/comments/lib/EventHandler.php
@@ -34,21 +34,15 @@ use OCP\Comments\ICommentsEventHandler;
* @package OCA\Comments
*/
class EventHandler implements ICommentsEventHandler {
- /** @var ActivityListener */
- private $activityListener;
-
- /** @var NotificationListener */
- private $notificationListener;
+ private ActivityListener $activityListener;
+ private NotificationListener $notificationListener;
public function __construct(ActivityListener $activityListener, NotificationListener $notificationListener) {
$this->activityListener = $activityListener;
$this->notificationListener = $notificationListener;
}
- /**
- * @param CommentsEvent $event
- */
- public function handle(CommentsEvent $event) {
+ public function handle(CommentsEvent $event): void {
if ($event->getComment()->getObjectType() !== 'files') {
// this is a 'files'-specific Handler
return;
@@ -73,17 +67,11 @@ class EventHandler implements ICommentsEventHandler {
}
}
- /**
- * @param CommentsEvent $event
- */
- private function activityHandler(CommentsEvent $event) {
+ private function activityHandler(CommentsEvent $event): void {
$this->activityListener->commentEvent($event);
}
- /**
- * @param CommentsEvent $event
- */
- private function notificationHandler(CommentsEvent $event) {
+ private function notificationHandler(CommentsEvent $event): void {
$this->notificationListener->evaluate($event);
}
}
diff --git a/apps/comments/lib/Listener/CommentsEntityEventListener.php b/apps/comments/lib/Listener/CommentsEntityEventListener.php
index 5675e1904cc..b49304c409b 100644
--- a/apps/comments/lib/Listener/CommentsEntityEventListener.php
+++ b/apps/comments/lib/Listener/CommentsEntityEventListener.php
@@ -28,16 +28,25 @@ namespace OCA\Comments\Listener;
use OCP\Comments\CommentsEntityEvent;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
+use OCP\Files\IRootFolder;
class CommentsEntityEventListener implements IEventListener {
+ private IRootFolder $rootFolder;
+ private ?string $userId;
+
+ public function __construct(IRootFolder $rootFolder, ?string $userId = null) {
+ $this->rootFolder = $rootFolder;
+ $this->userId = $userId;
+ }
+
public function handle(Event $event): void {
if (!($event instanceof CommentsEntityEvent)) {
// Unrelated
return;
}
- $event->addEntityCollection('files', function ($name) {
- $nodes = \OC::$server->getUserFolder()->getById((int)$name);
+ $event->addEntityCollection('files', function ($name): bool {
+ $nodes = $this->rootFolder->getUserFolder($this->userId)->getById((int)$name);
return !empty($nodes);
});
}
diff --git a/apps/comments/lib/MaxAutoCompleteResultsInitialState.php b/apps/comments/lib/MaxAutoCompleteResultsInitialState.php
index 015eaf19d84..cf7335e84c8 100644
--- a/apps/comments/lib/MaxAutoCompleteResultsInitialState.php
+++ b/apps/comments/lib/MaxAutoCompleteResultsInitialState.php
@@ -31,9 +31,7 @@ use OCP\AppFramework\Services\InitialStateProvider;
use OCP\IConfig;
class MaxAutoCompleteResultsInitialState extends InitialStateProvider {
-
- /** @var IConfig */
- private $config;
+ private IConfig $config;
public function __construct(IConfig $config) {
$this->config = $config;
diff --git a/apps/comments/lib/Notification/Listener.php b/apps/comments/lib/Notification/Listener.php
index d1662f84266..bbea310ef7e 100644
--- a/apps/comments/lib/Notification/Listener.php
+++ b/apps/comments/lib/Notification/Listener.php
@@ -27,15 +27,12 @@ use OCP\Comments\CommentsEvent;
use OCP\Comments\IComment;
use OCP\IUserManager;
use OCP\Notification\IManager;
+use OCP\Notification\INotification;
class Listener {
-
protected IManager $notificationManager;
protected IUserManager $userManager;
- /**
- * Listener constructor.
- */
public function __construct(
IManager $notificationManager,
IUserManager $userManager
@@ -44,10 +41,7 @@ class Listener {
$this->userManager = $userManager;
}
- /**
- * @param CommentsEvent $event
- */
- public function evaluate(CommentsEvent $event) {
+ public function evaluate(CommentsEvent $event): void {
$comment = $event->getComment();
$mentions = $this->extractMentions($comment->getMentions());
@@ -77,12 +71,9 @@ class Listener {
}
/**
- * creates a notification instance and fills it with comment data
- *
- * @param IComment $comment
- * @return \OCP\Notification\INotification
+ * Creates a notification instance and fills it with comment data
*/
- public function instantiateNotification(IComment $comment) {
+ public function instantiateNotification(IComment $comment): INotification {
$notification = $this->notificationManager->createNotification();
$notification
->setApp('comments')
@@ -94,12 +85,12 @@ class Listener {
}
/**
- * flattens the mention array returned from comments to a list of user ids.
+ * Flattens the mention array returned from comments to a list of user ids.
*
* @param array $mentions
- * @return string[] containing the mentions, e.g. ['alice', 'bob']
+ * @return list<string> containing the mentions, e.g. ['alice', 'bob']
*/
- public function extractMentions(array $mentions) {
+ public function extractMentions(array $mentions): array {
if (empty($mentions)) {
return [];
}
diff --git a/apps/comments/lib/Search/CommentsSearchProvider.php b/apps/comments/lib/Search/CommentsSearchProvider.php
index b36f82f8401..cca01c8ac44 100644
--- a/apps/comments/lib/Search/CommentsSearchProvider.php
+++ b/apps/comments/lib/Search/CommentsSearchProvider.php
@@ -39,7 +39,6 @@ use function array_map;
use function pathinfo;
class CommentsSearchProvider implements IProvider {
-
private IUserManager $userManager;
private IL10N $l10n;
private IURLGenerator $urlGenerator;
@@ -55,23 +54,14 @@ class CommentsSearchProvider implements IProvider {
$this->legacyProvider = $legacyProvider;
}
- /**
- * @inheritDoc
- */
public function getId(): string {
return 'comments';
}
- /**
- * @inheritDoc
- */
public function getName(): string {
return $this->l10n->t('Comments');
}
- /**
- * @inheritDoc
- */
public function getOrder(string $route, array $routeParameters): int {
if ($route === 'files.View.index') {
// Files first
@@ -80,9 +70,6 @@ class CommentsSearchProvider implements IProvider {
return 10;
}
- /**
- * @inheritDoc
- */
public function search(IUser $user, ISearchQuery $query): SearchResult {
return SearchResult::complete(
$this->l10n->t('Comments'),
diff --git a/apps/comments/lib/Search/Result.php b/apps/comments/lib/Search/Result.php
index ec799b7e30a..06016d2b46d 100644
--- a/apps/comments/lib/Search/Result.php
+++ b/apps/comments/lib/Search/Result.php
@@ -58,10 +58,6 @@ class Result extends BaseResult {
public $fileName;
/**
- * @param string $search
- * @param IComment $comment
- * @param string $authorName
- * @param string $path
* @throws NotFoundException
* @deprecated 20.0.0
*/
@@ -70,7 +66,7 @@ class Result extends BaseResult {
string $authorName,
string $path) {
parent::__construct(
- (int) $comment->getId(),
+ $comment->getId(),
$comment->getMessage()
/* @todo , [link to file] */
);
@@ -83,8 +79,6 @@ class Result extends BaseResult {
}
/**
- * @param string $path
- * @return string
* @throws NotFoundException
*/
protected function getVisiblePath(string $path): string {
@@ -98,9 +92,6 @@ class Result extends BaseResult {
}
/**
- * @param string $message
- * @param string $search
- * @return string
* @throws NotFoundException
*/
protected function getRelevantMessagePart(string $message, string $search): string {
diff --git a/apps/comments/tests/Unit/AppInfo/ApplicationTest.php b/apps/comments/tests/Unit/AppInfo/ApplicationTest.php
index 6e3658c0e5b..a0ec722b368 100644
--- a/apps/comments/tests/Unit/AppInfo/ApplicationTest.php
+++ b/apps/comments/tests/Unit/AppInfo/ApplicationTest.php
@@ -51,11 +51,8 @@ class ApplicationTest extends TestCase {
$app = new Application();
$c = $app->getContainer();
- // assert service instances in the container are properly setup
- $s = $c->get('NotificationsController');
- $this->assertInstanceOf('OCA\Comments\Controller\Notifications', $s);
-
$services = [
+ 'OCA\Comments\Controller\NotificationsController',
'OCA\Comments\Activity\Filter',
'OCA\Comments\Activity\Listener',
'OCA\Comments\Activity\Provider',
diff --git a/apps/comments/tests/Unit/Controller/NotificationsTest.php b/apps/comments/tests/Unit/Controller/NotificationsTest.php
index c21101030e8..4ccb553739b 100644
--- a/apps/comments/tests/Unit/Controller/NotificationsTest.php
+++ b/apps/comments/tests/Unit/Controller/NotificationsTest.php
@@ -25,7 +25,7 @@
*/
namespace OCA\Comments\Tests\Unit\Controller;
-use OCA\Comments\Controller\Notifications;
+use OCA\Comments\Controller\NotificationsController;
use OCP\AppFramework\Http\NotFoundResponse;
use OCP\AppFramework\Http\RedirectResponse;
use OCP\Comments\IComment;
@@ -43,7 +43,7 @@ use OCP\Notification\INotification;
use Test\TestCase;
class NotificationsTest extends TestCase {
- /** @var Notifications */
+ /** @var NotificationsController */
protected $notificationsController;
/** @var ICommentsManager|\PHPUnit\Framework\MockObject\MockObject */
@@ -70,7 +70,7 @@ class NotificationsTest extends TestCase {
$this->notificationManager = $this->createMock(IManager::class);
$this->urlGenerator = $this->createMock(IURLGenerator::class);
- $this->notificationsController = new Notifications(
+ $this->notificationsController = new NotificationsController(
'comments',
$this->createMock(IRequest::class),
$this->commentsManager,