summaryrefslogtreecommitdiffstats
path: root/apps/files/lib
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/files/lib
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/files/lib')
-rw-r--r--apps/files/lib/Activity/FavoriteProvider.php3
-rw-r--r--apps/files/lib/Activity/Provider.php17
-rw-r--r--apps/files/lib/Notification/Notifier.php33
3 files changed, 12 insertions, 41 deletions
diff --git a/apps/files/lib/Activity/FavoriteProvider.php b/apps/files/lib/Activity/FavoriteProvider.php
index a1c08370e4e..9c7018e6a5c 100644
--- a/apps/files/lib/Activity/FavoriteProvider.php
+++ b/apps/files/lib/Activity/FavoriteProvider.php
@@ -172,7 +172,6 @@ class FavoriteProvider implements IProvider {
'link' => $this->url->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $subjectParams['id']]),
];
- $event->setParsedSubject(str_replace('{file}', $parameter['path'], $subject))
- ->setRichSubject($subject, ['file' => $parameter]);
+ $event->setRichSubject($subject, ['file' => $parameter]);
}
}
diff --git a/apps/files/lib/Activity/Provider.php b/apps/files/lib/Activity/Provider.php
index c21e8f9ad16..2cfd48ede3b 100644
--- a/apps/files/lib/Activity/Provider.php
+++ b/apps/files/lib/Activity/Provider.php
@@ -38,12 +38,10 @@ use OCP\Files\Node;
use OCP\Files\NotFoundException;
use OCP\IL10N;
use OCP\IURLGenerator;
-use OCP\IUser;
use OCP\IUserManager;
use OCP\L10N\IFactory;
class Provider implements IProvider {
-
/** @var IFactory */
protected $languageFactory;
@@ -306,19 +304,8 @@ class Provider implements IProvider {
return strlen($filename) > 0 && $filename[0] === '.';
}
- protected function setSubjects(IEvent $event, $subject, array $parameters) {
- $placeholders = $replacements = [];
- foreach ($parameters as $placeholder => $parameter) {
- $placeholders[] = '{' . $placeholder . '}';
- if ($parameter['type'] === 'file') {
- $replacements[] = $parameter['path'];
- } else {
- $replacements[] = $parameter['name'];
- }
- }
-
- $event->setParsedSubject(str_replace($placeholders, $replacements, $subject))
- ->setRichSubject($subject, $parameters);
+ protected function setSubjects(IEvent $event, string $subject, array $parameters): void {
+ $event->setRichSubject($subject, $parameters);
}
/**
diff --git a/apps/files/lib/Notification/Notifier.php b/apps/files/lib/Notification/Notifier.php
index 1a7a3726229..90784749b27 100644
--- a/apps/files/lib/Notification/Notifier.php
+++ b/apps/files/lib/Notification/Notifier.php
@@ -41,7 +41,6 @@ use OCP\Notification\INotification;
use OCP\Notification\INotifier;
class Notifier implements INotifier, IDismissableNotifier {
-
/** @var IFactory */
protected $l10nFactory;
@@ -151,7 +150,6 @@ class Notifier implements INotifier, IDismissableNotifier {
'name' => $sourceUser->getDisplayName(),
],
])
- ->setParsedSubject(str_replace('{user}', $sourceUser->getDisplayName(), $l->t('Incoming ownership transfer from {user}')))
->setRichMessage(
$l->t("Do you want to accept {path}?\n\nNote: The transfer process after accepting may take up to 1 hour."),
[
@@ -160,20 +158,17 @@ class Notifier implements INotifier, IDismissableNotifier {
'id' => $param['targetUser'] . '::' . $param['nodeName'],
'name' => $param['nodeName'],
]
- ])
- ->setParsedMessage(str_replace('{path}', $param['nodeName'], $l->t("Do you want to accept {path}?\n\nNote: The transfer process after accepting may take up to 1 hour.")));
+ ]);
return $notification;
}
- public function handleTransferOwnershipFailedSource(INotification $notification, string $languageCode): INotification {
+ public function handleTransferOwnershipFailedSource(INotification $notification, string $languageCode): INotification {
$l = $this->l10nFactory->get('files', $languageCode);
$param = $notification->getSubjectParameters();
$targetUser = $this->getUser($param['targetUser']);
$notification->setRichSubject($l->t('Ownership transfer failed'))
- ->setParsedSubject($l->t('Ownership transfer failed'))
-
->setRichMessage(
$l->t('Your ownership transfer of {path} to {user} failed.'),
[
@@ -187,19 +182,16 @@ class Notifier implements INotifier, IDismissableNotifier {
'id' => $targetUser->getUID(),
'name' => $targetUser->getDisplayName(),
],
- ])
- ->setParsedMessage(str_replace(['{path}', '{user}'], [$param['nodeName'], $targetUser->getDisplayName()], $l->t('Your ownership transfer of {path} to {user} failed.')));
+ ]);
return $notification;
}
- public function handleTransferOwnershipFailedTarget(INotification $notification, string $languageCode): INotification {
+ public function handleTransferOwnershipFailedTarget(INotification $notification, string $languageCode): INotification {
$l = $this->l10nFactory->get('files', $languageCode);
$param = $notification->getSubjectParameters();
$sourceUser = $this->getUser($param['sourceUser']);
$notification->setRichSubject($l->t('Ownership transfer failed'))
- ->setParsedSubject($l->t('Ownership transfer failed'))
-
->setRichMessage(
$l->t('The ownership transfer of {path} from {user} failed.'),
[
@@ -213,20 +205,17 @@ class Notifier implements INotifier, IDismissableNotifier {
'id' => $sourceUser->getUID(),
'name' => $sourceUser->getDisplayName(),
],
- ])
- ->setParsedMessage(str_replace(['{path}', '{user}'], [$param['nodeName'], $sourceUser->getDisplayName()], $l->t('The ownership transfer of {path} from {user} failed.')));
+ ]);
return $notification;
}
- public function handleTransferOwnershipDoneSource(INotification $notification, string $languageCode): INotification {
+ public function handleTransferOwnershipDoneSource(INotification $notification, string $languageCode): INotification {
$l = $this->l10nFactory->get('files', $languageCode);
$param = $notification->getSubjectParameters();
$targetUser = $this->getUser($param['targetUser']);
$notification->setRichSubject($l->t('Ownership transfer done'))
- ->setParsedSubject($l->t('Ownership transfer done'))
-
->setRichMessage(
$l->t('Your ownership transfer of {path} to {user} has completed.'),
[
@@ -240,20 +229,17 @@ class Notifier implements INotifier, IDismissableNotifier {
'id' => $targetUser->getUID(),
'name' => $targetUser->getDisplayName(),
],
- ])
- ->setParsedMessage(str_replace(['{path}', '{user}'], [$param['nodeName'], $targetUser->getDisplayName()], $l->t('Your ownership transfer of {path} to {user} has completed.')));
+ ]);
return $notification;
}
- public function handleTransferOwnershipDoneTarget(INotification $notification, string $languageCode): INotification {
+ public function handleTransferOwnershipDoneTarget(INotification $notification, string $languageCode): INotification {
$l = $this->l10nFactory->get('files', $languageCode);
$param = $notification->getSubjectParameters();
$sourceUser = $this->getUser($param['sourceUser']);
$notification->setRichSubject($l->t('Ownership transfer done'))
- ->setParsedSubject($l->t('Ownership transfer done'))
-
->setRichMessage(
$l->t('The ownership transfer of {path} from {user} has completed.'),
[
@@ -267,8 +253,7 @@ class Notifier implements INotifier, IDismissableNotifier {
'id' => $sourceUser->getUID(),
'name' => $sourceUser->getDisplayName(),
],
- ])
- ->setParsedMessage(str_replace(['{path}', '{user}'], [$param['nodeName'], $sourceUser->getDisplayName()], $l->t('The ownership transfer of {path} from {user} has completed.')));
+ ]);
return $notification;
}