diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2017-02-10 12:49:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-10 12:49:39 +0100 |
commit | 3f290315ef609f8914252389761820948161f0d1 (patch) | |
tree | fbc1107dc7396138b507c3a50bd52c8abf7734e3 /apps/files | |
parent | 733043061832bff53d100558a22f0c28723f0e3d (diff) | |
parent | 372474603d7aa156cf40aefebfab20791a6a5091 (diff) | |
download | nextcloud-server-3f290315ef609f8914252389761820948161f0d1.tar.gz nextcloud-server-3f290315ef609f8914252389761820948161f0d1.zip |
Merge pull request #3433 from nextcloud/backport-3181-fix-favorite-activity-mail
[stable11] Make sure the file information is available when sending the email
Diffstat (limited to 'apps/files')
-rw-r--r-- | apps/files/lib/Activity/FavoriteProvider.php | 16 | ||||
-rw-r--r-- | apps/files/lib/Service/TagService.php | 23 |
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) { + } } } |