summaryrefslogtreecommitdiffstats
path: root/apps/comments
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2022-10-25 17:16:54 +0200
committerCôme Chilliet (Rebase PR Action) <come-nc@users.noreply.github.com>2022-11-29 14:36:29 +0000
commitd9151ff35c4280b8e5bbb92e33fe2b89c2bee458 (patch)
treec0b5864c0c667156b82763382b4541d1fa073d37 /apps/comments
parentdb995d464d06ace8231c41633287ce689b7d33b1 (diff)
downloadnextcloud-server-d9151ff35c4280b8e5bbb92e33fe2b89c2bee458.tar.gz
nextcloud-server-d9151ff35c4280b8e5bbb92e33fe2b89c2bee458.zip
Get rid of all useless calls to setParsedSubject now that setRichSubject is able to do it
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'apps/comments')
-rw-r--r--apps/comments/lib/Activity/Provider.php12
-rw-r--r--apps/comments/lib/Notification/Notifier.php19
2 files changed, 4 insertions, 27 deletions
diff --git a/apps/comments/lib/Activity/Provider.php b/apps/comments/lib/Activity/Provider.php
index c6e55326580..f9a5971c7f3 100644
--- a/apps/comments/lib/Activity/Provider.php
+++ b/apps/comments/lib/Activity/Provider.php
@@ -31,12 +31,10 @@ use OCP\Comments\ICommentsManager;
use OCP\Comments\NotFoundException;
use OCP\IL10N;
use OCP\IURLGenerator;
-use OCP\IUser;
use OCP\IUserManager;
use OCP\L10N\IFactory;
class Provider implements IProvider {
-
protected IFactory $languageFactory;
protected ?IL10N $l = null;
protected IUrlGenerator $url;
@@ -97,14 +95,12 @@ class Provider implements IProvider {
if ($event->getSubject() === 'add_comment_subject') {
if ($subjectParameters['actor'] === $this->activityManager->getCurrentUserId()) {
- $event->setParsedSubject($this->l->t('You commented'))
- ->setRichSubject($this->l->t('You commented'), []);
+ $event->setRichSubject($this->l->t('You commented'), []);
} else {
$author = $this->generateUserParameter($subjectParameters['actor']);
- $event->setParsedSubject($this->l->t('%1$s commented', [$author['name']]))
- ->setRichSubject($this->l->t('{author} commented'), [
- 'author' => $author,
- ]);
+ $event->setRichSubject($this->l->t('{author} commented'), [
+ 'author' => $author,
+ ]);
}
} else {
throw new \InvalidArgumentException();
diff --git a/apps/comments/lib/Notification/Notifier.php b/apps/comments/lib/Notification/Notifier.php
index 4ddb7295bfe..59f1ad5da5f 100644
--- a/apps/comments/lib/Notification/Notifier.php
+++ b/apps/comments/lib/Notification/Notifier.php
@@ -29,7 +29,6 @@ use OCP\Comments\ICommentsManager;
use OCP\Comments\NotFoundException;
use OCP\Files\IRootFolder;
use OCP\IURLGenerator;
-use OCP\IUser;
use OCP\IUserManager;
use OCP\L10N\IFactory;
use OCP\Notification\AlreadyProcessedException;
@@ -37,7 +36,6 @@ use OCP\Notification\INotification;
use OCP\Notification\INotifier;
class Notifier implements INotifier {
-
protected IFactory $l10nFactory;
protected IRootFolder $rootFolder;
protected ICommentsManager $commentsManager;
@@ -147,9 +145,7 @@ class Notifier implements INotifier {
}
[$message, $messageParameters] = $this->commentToRichMessage($comment);
$notification->setRichSubject($subject, $subjectParameters)
- ->setParsedSubject($this->richToParsed($subject, $subjectParameters))
->setRichMessage($message, $messageParameters)
- ->setParsedMessage($this->richToParsed($message, $messageParameters))
->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/comment.svg')))
->setLink($this->url->linkToRouteAbsolute(
'comments.Notifications.view',
@@ -205,19 +201,4 @@ class Notifier implements INotifier {
}
return [$message, $messageParameters];
}
-
- public function richToParsed(string $message, array $parameters): string {
- $placeholders = $replacements = [];
- foreach ($parameters as $placeholder => $parameter) {
- $placeholders[] = '{' . $placeholder . '}';
- if ($parameter['type'] === 'user') {
- $replacements[] = '@' . $parameter['name'];
- } elseif ($parameter['type'] === 'file') {
- $replacements[] = $parameter['path'];
- } else {
- $replacements[] = $parameter['name'];
- }
- }
- return str_replace($placeholders, $replacements, $message);
- }
}