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
2 changed files with 28 additions and 12 deletions
|
@ -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))
|
||||
|
|
|
@ -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) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue