aboutsummaryrefslogtreecommitdiffstats
path: root/apps/comments/lib/Activity
diff options
context:
space:
mode:
Diffstat (limited to 'apps/comments/lib/Activity')
-rw-r--r--apps/comments/lib/Activity/Filter.php1
-rw-r--r--apps/comments/lib/Activity/Listener.php6
-rw-r--r--apps/comments/lib/Activity/Provider.php27
-rw-r--r--apps/comments/lib/Activity/Setting.php13
4 files changed, 31 insertions, 16 deletions
diff --git a/apps/comments/lib/Activity/Filter.php b/apps/comments/lib/Activity/Filter.php
index 6f010d855cb..8dcafd872d7 100644
--- a/apps/comments/lib/Activity/Filter.php
+++ b/apps/comments/lib/Activity/Filter.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
diff --git a/apps/comments/lib/Activity/Listener.php b/apps/comments/lib/Activity/Listener.php
index f49f2077a61..45064f4a6be 100644
--- a/apps/comments/lib/Activity/Listener.php
+++ b/apps/comments/lib/Activity/Listener.php
@@ -31,7 +31,7 @@ class Listener {
public function commentEvent(CommentsEvent $event): void {
if ($event->getComment()->getObjectType() !== 'files'
|| $event->getEvent() !== CommentsEvent::EVENT_ADD
- || !$this->appManager->isInstalled('activity')) {
+ || !$this->appManager->isEnabledForAnyone('activity')) {
// Comment not for file, not adding a comment or no activity-app enabled (save the energy)
return;
}
@@ -67,7 +67,7 @@ class Listener {
$activity->setApp('comments')
->setType('comments')
->setAuthor($actor)
- ->setObject($event->getComment()->getObjectType(), (int) $event->getComment()->getObjectId())
+ ->setObject($event->getComment()->getObjectType(), (int)$event->getComment()->getObjectId())
->setMessage('add_comment_message', [
'commentId' => $event->getComment()->getId(),
]);
@@ -79,7 +79,7 @@ class Listener {
$activity->setSubject('add_comment_subject', [
'actor' => $actor,
- 'fileId' => (int) $event->getComment()->getObjectId(),
+ 'fileId' => (int)$event->getComment()->getObjectId(),
'filePath' => trim($path, '/'),
]);
$this->activityManager->publish($activity);
diff --git a/apps/comments/lib/Activity/Provider.php b/apps/comments/lib/Activity/Provider.php
index 704ef0e0a48..ee53357efdb 100644
--- a/apps/comments/lib/Activity/Provider.php
+++ b/apps/comments/lib/Activity/Provider.php
@@ -1,10 +1,12 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Comments\Activity;
+use OCP\Activity\Exceptions\UnknownActivityException;
use OCP\Activity\IEvent;
use OCP\Activity\IManager;
use OCP\Activity\IProvider;
@@ -32,12 +34,12 @@ class Provider implements IProvider {
* @param IEvent $event
* @param IEvent|null $previousEvent
* @return IEvent
- * @throws \InvalidArgumentException
+ * @throws UnknownActivityException
* @since 11.0.0
*/
public function parse($language, IEvent $event, ?IEvent $previousEvent = null): IEvent {
if ($event->getApp() !== 'comments') {
- throw new \InvalidArgumentException();
+ throw new UnknownActivityException();
}
$this->l = $this->languageFactory->get('comments', $language);
@@ -53,19 +55,19 @@ class Provider implements IProvider {
if ($this->activityManager->isFormattingFilteredObject()) {
try {
return $this->parseShortVersion($event);
- } catch (\InvalidArgumentException $e) {
+ } catch (UnknownActivityException) {
// Ignore and simply use the long version...
}
}
return $this->parseLongVersion($event);
- } else {
- throw new \InvalidArgumentException();
}
+ throw new UnknownActivityException();
+
}
/**
- * @throws \InvalidArgumentException
+ * @throws UnknownActivityException
*/
protected function parseShortVersion(IEvent $event): IEvent {
$subjectParameters = $this->getSubjectParameters($event);
@@ -80,14 +82,14 @@ class Provider implements IProvider {
]);
}
} else {
- throw new \InvalidArgumentException();
+ throw new UnknownActivityException();
}
return $event;
}
/**
- * @throws \InvalidArgumentException
+ * @throws UnknownActivityException
*/
protected function parseLongVersion(IEvent $event): IEvent {
$subjectParameters = $this->getSubjectParameters($event);
@@ -112,7 +114,7 @@ class Provider implements IProvider {
]);
}
} else {
- throw new \InvalidArgumentException();
+ throw new UnknownActivityException();
}
return $event;
@@ -148,7 +150,7 @@ class Provider implements IProvider {
$commentId = $messageParameters['commentId'] ?? $messageParameters[0];
try {
- $comment = $this->commentsManager->get((string) $commentId);
+ $comment = $this->commentsManager->get((string)$commentId);
$message = $comment->getMessage();
$mentionCount = 1;
@@ -173,10 +175,13 @@ class Provider implements IProvider {
}
}
+ /**
+ * @return array<string, string>
+ */
protected function generateFileParameter(int $id, string $path): array {
return [
'type' => 'file',
- 'id' => $id,
+ 'id' => (string)$id,
'name' => basename($path),
'path' => $path,
'link' => $this->url->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $id]),
diff --git a/apps/comments/lib/Activity/Setting.php b/apps/comments/lib/Activity/Setting.php
index cc7c47784ac..7fbf4001b20 100644
--- a/apps/comments/lib/Activity/Setting.php
+++ b/apps/comments/lib/Activity/Setting.php
@@ -1,14 +1,15 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Comments\Activity;
-use OCP\Activity\ISetting;
+use OCP\Activity\ActivitySettings;
use OCP\IL10N;
-class Setting implements ISetting {
+class Setting extends ActivitySettings {
public function __construct(
protected IL10N $l,
) {
@@ -22,6 +23,14 @@ class Setting implements ISetting {
return $this->l->t('<strong>Comments</strong> for files');
}
+ public function getGroupIdentifier() {
+ return 'files';
+ }
+
+ public function getGroupName() {
+ return $this->l->t('Files');
+ }
+
public function getPriority(): int {
return 50;
}