Make sure the file information is available when sending the email
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
13a5c5d64c
commit
fef4462904
|
@ -138,12 +138,21 @@ class FavoriteProvider implements IProvider {
|
||||||
* @param string $subject
|
* @param string $subject
|
||||||
*/
|
*/
|
||||||
protected function setSubjects(IEvent $event, $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 = [
|
$parameter = [
|
||||||
'type' => 'file',
|
'type' => 'file',
|
||||||
'id' => $event->getObjectId(),
|
'id' => $subjectParams['id'],
|
||||||
'name' => basename($event->getObjectName()),
|
'name' => basename($subjectParams['path']),
|
||||||
'path' => trim($event->getObjectName(), '/'),
|
'path' => trim($subjectParams['path'], '/'),
|
||||||
'link' => $this->url->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $event->getObjectId()]),
|
'link' => $this->url->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $subjectParams['id']]),
|
||||||
];
|
];
|
||||||
|
|
||||||
$event->setParsedSubject(str_replace('{file}', $parameter['path'], $subject))
|
$event->setParsedSubject(str_replace('{file}', $parameter['path'], $subject))
|
||||||
|
|
|
@ -116,14 +116,21 @@ class TagService {
|
||||||
}
|
}
|
||||||
|
|
||||||
$event = $this->activityManager->generateEvent();
|
$event = $this->activityManager->generateEvent();
|
||||||
|
try {
|
||||||
$event->setApp('files')
|
$event->setApp('files')
|
||||||
->setObject('files', $fileId, $path)
|
->setObject('files', $fileId, $path)
|
||||||
->setType('favorite')
|
->setType('favorite')
|
||||||
->setAuthor($user->getUID())
|
->setAuthor($user->getUID())
|
||||||
->setAffectedUser($user->getUID())
|
->setAffectedUser($user->getUID())
|
||||||
->setTimestamp(time())
|
->setTimestamp(time())
|
||||||
->setSubject($addToFavorite ? FavoriteProvider::SUBJECT_ADDED : FavoriteProvider::SUBJECT_REMOVED);
|
->setSubject(
|
||||||
|
$addToFavorite ? FavoriteProvider::SUBJECT_ADDED : FavoriteProvider::SUBJECT_REMOVED,
|
||||||
|
['id' => $fileId, 'path' => $path]
|
||||||
|
);
|
||||||
$this->activityManager->publish($event);
|
$this->activityManager->publish($event);
|
||||||
|
} catch (\InvalidArgumentException $e) {
|
||||||
|
} catch (\BadMethodCallException $e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue