Make sure the file information is available when sending the email

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2017-01-20 12:48:46 +01:00
parent 13a5c5d64c
commit fef4462904
No known key found for this signature in database
GPG Key ID: E166FD8976B3BAC8
2 changed files with 28 additions and 12 deletions

View File

@ -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))

View File

@ -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) {
}
}
}