diff options
author | Joas Schilling <coding@schilljs.com> | 2017-01-20 12:48:46 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2017-01-20 12:52:56 +0100 |
commit | fef4462904c23fea4b512bddc892044de7286f7c (patch) | |
tree | a6f0001f950d8080d6a7cb5fd55b947f4aed5d0b /apps/files | |
parent | 13a5c5d64c3ef0942225f02e8d812e0a4f621aa9 (diff) | |
download | nextcloud-server-fef4462904c23fea4b512bddc892044de7286f7c.tar.gz nextcloud-server-fef4462904c23fea4b512bddc892044de7286f7c.zip |
Make sure the file information is available when sending the email
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/files')
-rw-r--r-- | apps/files/lib/Activity/FavoriteProvider.php | 17 | ||||
-rw-r--r-- | apps/files/lib/Service/TagService.php | 23 |
2 files changed, 28 insertions, 12 deletions
diff --git a/apps/files/lib/Activity/FavoriteProvider.php b/apps/files/lib/Activity/FavoriteProvider.php index ed00d50f221..941579e730d 100644 --- a/apps/files/lib/Activity/FavoriteProvider.php +++ b/apps/files/lib/Activity/FavoriteProvider.php @@ -138,12 +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' => trim($event->getObjectName(), '/'), - 'link' => $this->url->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $event->getObjectId()]), + '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}', $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) { + } } } |