aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_reminders/lib/Notification/Notifier.php
diff options
context:
space:
mode:
authorChristopher Ng <chrng8@gmail.com>2023-07-31 12:10:50 -0700
committerChristopher Ng <chrng8@gmail.com>2023-08-03 15:30:11 -0700
commitc8a32a70cd7564e739b7c60196f804d50a954b8a (patch)
tree2ea0a9583c5281cd0cafd50d168b4a05239e3595 /apps/files_reminders/lib/Notification/Notifier.php
parentea5e128fefba6d87c400cdaafa87cd566746c109 (diff)
downloadnextcloud-server-c8a32a70cd7564e739b7c60196f804d50a954b8a.tar.gz
nextcloud-server-c8a32a70cd7564e739b7c60196f804d50a954b8a.zip
feat(files_reminders): add list command
Signed-off-by: Christopher Ng <chrng8@gmail.com>
Diffstat (limited to 'apps/files_reminders/lib/Notification/Notifier.php')
-rw-r--r--apps/files_reminders/lib/Notification/Notifier.php28
1 files changed, 8 insertions, 20 deletions
diff --git a/apps/files_reminders/lib/Notification/Notifier.php b/apps/files_reminders/lib/Notification/Notifier.php
index b3c1a98484a..fb1d3264dbd 100644
--- a/apps/files_reminders/lib/Notification/Notifier.php
+++ b/apps/files_reminders/lib/Notification/Notifier.php
@@ -29,9 +29,8 @@ namespace OCA\FilesReminders\Notification;
use InvalidArgumentException;
use OCA\FilesReminders\AppInfo\Application;
use OCA\FilesReminders\Exception\NodeNotFoundException;
+use OCA\FilesReminders\Service\ReminderService;
use OCP\Files\FileInfo;
-use OCP\Files\IRootFolder;
-use OCP\Files\Node;
use OCP\IURLGenerator;
use OCP\L10N\IFactory;
use OCP\Notification\IAction;
@@ -42,7 +41,7 @@ class Notifier implements INotifier {
public function __construct(
protected IFactory $l10nFactory,
protected IURLGenerator $urlGenerator,
- protected IRootFolder $root,
+ protected ReminderService $reminderService,
) {}
public function getID(): string {
@@ -66,8 +65,8 @@ class Notifier implements INotifier {
switch ($notification->getSubject()) {
case 'reminder-due':
- $fileId = $notification->getSubjectParameters()['fileId'];
- $node = $this->getNode($fileId);
+ $reminderId = (int)$notification->getObjectId();
+ $node = $this->reminderService->get($reminderId)->getNode();
$path = rtrim($node->getPath(), '/');
if (strpos($path, '/' . $notification->getUser() . '/files/') === 0) {
@@ -81,12 +80,13 @@ class Notifier implements INotifier {
['fileid' => $node->getId()],
);
- $subject = $l->t('Reminder for {filename}');
+ // TRANSLATORS The name placeholder is for a file or folder name
+ $subject = $l->t('Reminder for {name}');
$notification
->setRichSubject(
$subject,
[
- 'filename' => [
+ 'name' => [
'type' => 'file',
'id' => $node->getId(),
'name' => $node->getName(),
@@ -96,7 +96,7 @@ class Notifier implements INotifier {
],
)
->setParsedSubject(str_replace(
- ['{filename}'],
+ ['{name}'],
[$node->getName()],
$subject,
))
@@ -127,16 +127,4 @@ class Notifier implements INotifier {
$notification->addParsedAction($action);
}
-
- /**
- * @throws NodeNotFoundException
- */
- protected function getNode(int $fileId): Node {
- $nodes = $this->root->getById($fileId);
- if (empty($nodes)) {
- throw new NodeNotFoundException();
- }
- $node = reset($nodes);
- return $node;
- }
}