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

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2017-01-20 14:48:46 +0300
committerJoas Schilling <coding@schilljs.com>2017-02-10 12:35:29 +0300
commit372474603d7aa156cf40aefebfab20791a6a5091 (patch)
tree2ecbc85e45260b0ad0a47e20ee5178b541cee6b3
parent5c1bf139b4975af3f78fccd018828f3c0e793c7d (diff)
Make sure the file information is available when sending the email
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--apps/files/lib/Activity/FavoriteProvider.php16
-rw-r--r--apps/files/lib/Service/TagService.php23
2 files changed, 28 insertions, 11 deletions
diff --git a/apps/files/lib/Activity/FavoriteProvider.php b/apps/files/lib/Activity/FavoriteProvider.php
index 8047eb1319e..7289becf971 100644
--- a/apps/files/lib/Activity/FavoriteProvider.php
+++ b/apps/files/lib/Activity/FavoriteProvider.php
@@ -138,11 +138,21 @@ class FavoriteProvider implements IProvider {
* @param string $subject
*/
protected function setSubjects(IEvent $event, $subject) {
+ $subjectParams = $event->getSubjectParameters();
+ if (empty($subjectParams)) {
+ // Try to fall back to the old way, but this does not work for emails.
+ // But at least old activities still work.
+ $subjectParams = [
+ 'id' => $event->getObjectId(),
+ 'path' => $event->getObjectName(),
+ ];
+ }
$parameter = [
'type' => 'file',
- 'id' => $event->getObjectId(),
- 'name' => basename($event->getObjectName()),
- 'path' => $event->getObjectName(),
+ 'id' => $subjectParams['id'],
+ 'name' => basename($subjectParams['path']),
+ 'path' => trim($subjectParams['path'], '/'),
+ 'link' => $this->url->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $subjectParams['id']]),
];
$event->setParsedSubject(str_replace('{file}', trim($parameter['path'], '/'), $subject))
diff --git a/apps/files/lib/Service/TagService.php b/apps/files/lib/Service/TagService.php
index cf80d780eaf..cea26d26d16 100644
--- a/apps/files/lib/Service/TagService.php
+++ b/apps/files/lib/Service/TagService.php
@@ -116,14 +116,21 @@ class TagService {
}
$event = $this->activityManager->generateEvent();
- $event->setApp('files')
- ->setObject('files', $fileId, $path)
- ->setType('favorite')
- ->setAuthor($user->getUID())
- ->setAffectedUser($user->getUID())
- ->setTimestamp(time())
- ->setSubject($addToFavorite ? FavoriteProvider::SUBJECT_ADDED : FavoriteProvider::SUBJECT_REMOVED);
- $this->activityManager->publish($event);
+ try {
+ $event->setApp('files')
+ ->setObject('files', $fileId, $path)
+ ->setType('favorite')
+ ->setAuthor($user->getUID())
+ ->setAffectedUser($user->getUID())
+ ->setTimestamp(time())
+ ->setSubject(
+ $addToFavorite ? FavoriteProvider::SUBJECT_ADDED : FavoriteProvider::SUBJECT_REMOVED,
+ ['id' => $fileId, 'path' => $path]
+ );
+ $this->activityManager->publish($event);
+ } catch (\InvalidArgumentException $e) {
+ } catch (\BadMethodCallException $e) {
+ }
}
}