Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2018-11-07 22:31:33 +0300
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2018-11-08 23:07:40 +0300
commit86f25fb2a5da07570016bb74f95a2fccd8c1558c (patch)
tree73c34c62f46251d4dd54dbb326c8c554ed99c451 /lib/Notification/Notifier.php
parente13571f8f3bdd58ab8df7610e0107119a4058ab8 (diff)
Add the file to the notification subject
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Notification/Notifier.php')
-rw-r--r--lib/Notification/Notifier.php27
1 files changed, 23 insertions, 4 deletions
diff --git a/lib/Notification/Notifier.php b/lib/Notification/Notifier.php
index 3f7111dd8..416fdb6b7 100644
--- a/lib/Notification/Notifier.php
+++ b/lib/Notification/Notifier.php
@@ -464,23 +464,42 @@ class Notifier implements INotifier {
throw new \InvalidArgumentException('Unknown share');
}
+ try {
+ $segments = explode('/', $share->getNode()->getPath(), 4);
+ if (!isset($segments[3])) {
+ throw new \OCP\Files\NotFoundException('File not in /user/files/');
+ }
+ $file = [
+ 'type' => 'file',
+ 'id' => $share->getNodeId(),
+ 'name' => $share->getNode()->getName(),
+ 'path' => $segments[3],
+ 'link' => $this->url->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $share->getNodeId()]),
+ ];
+ } catch (\OCP\Files\NotFoundException $e) {
+ throw new \InvalidArgumentException('Unknown file');
+ }
+
if ($share->getShareType() === Share::SHARE_TYPE_EMAIL) {
$sharedWith = $share->getSharedWith();
$notification
- ->setParsedSubject(str_replace('{email}', $sharedWith, $l->t('{email} requested the password to access a share')))
+ ->setParsedSubject(str_replace(['{email}', '{file}'], [$sharedWith, $file['name']], $l->t('{email} requested the password to access {file}')))
->setRichSubject(
- $l->t('{email} requested the password to access a share'), [
+ $l->t('{email} requested the password to access {file}'),
+ [
'email' => [
'type' => 'email',
'id' => $sharedWith,
'name' => $sharedWith,
- ]
+ ],
+ 'file' => $file,
]
);
} else {
$notification
- ->setParsedSubject($l->t('Someone requested the password to access a share'));
+ ->setParsedSubject(str_replace('{file}', $file['name'], $l->t('Someone requested the password to access {file}')))
+ ->setRichSubject($l->t('Someone requested the password to access {file}'), ['file' => $file]);
}
return $notification;