Fix username and avatar for external users

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2017-05-19 15:45:14 +02:00
parent bcddca9a64
commit edb4956290
No known key found for this signature in database
GPG key ID: E166FD8976B3BAC8

View file

@ -38,6 +38,8 @@ class Provider implements IProvider {
/** @var IL10N */ /** @var IL10N */
protected $l; protected $l;
/** @var IL10N */
protected $activityLang;
/** @var IURLGenerator */ /** @var IURLGenerator */
protected $url; protected $url;
@ -83,6 +85,7 @@ class Provider implements IProvider {
} }
$this->l = $this->languageFactory->get('files', $language); $this->l = $this->languageFactory->get('files', $language);
$this->activityLang = $this->languageFactory->get('activity', $language);
if ($this->activityManager->isFormattingFilteredObject()) { if ($this->activityManager->isFormattingFilteredObject()) {
try { try {
@ -126,6 +129,11 @@ class Provider implements IProvider {
throw new \InvalidArgumentException(); throw new \InvalidArgumentException();
} }
if (!isset($parsedParameters['user'])) {
// External user via public link share
$subject = str_replace('{user}', $this->activityLang->t('"remote user"'), $subject);
}
$this->setSubjects($event, $subject, $parsedParameters); $this->setSubjects($event, $subject, $parsedParameters);
return $this->eventMerger->mergeEvents('user', $event, $previousEvent); return $this->eventMerger->mergeEvents('user', $event, $previousEvent);
@ -182,6 +190,11 @@ class Provider implements IProvider {
throw new \InvalidArgumentException(); throw new \InvalidArgumentException();
} }
if (!isset($parsedParameters['user'])) {
// External user via public link share
$subject = str_replace('{user}', $this->activityLang->t('"remote user"'), $subject);
}
$this->setSubjects($event, $subject, $parsedParameters); $this->setSubjects($event, $subject, $parsedParameters);
$event = $this->eventMerger->mergeEvents('file', $event, $previousEvent); $event = $this->eventMerger->mergeEvents('file', $event, $previousEvent);
@ -229,6 +242,12 @@ class Provider implements IProvider {
case 'changed_by': case 'changed_by':
case 'deleted_by': case 'deleted_by':
case 'restored_by': case 'restored_by':
if ($parameters[1] === '') {
// External user via public link share
return [
'file' => $this->getFile($parameters[0], $event),
];
}
return [ return [
'file' => $this->getFile($parameters[0], $event), 'file' => $this->getFile($parameters[0], $event),
'user' => $this->getUser($parameters[1]), 'user' => $this->getUser($parameters[1]),
@ -241,6 +260,13 @@ class Provider implements IProvider {
]; ];
case 'renamed_by': case 'renamed_by':
case 'moved_by': case 'moved_by':
if ($parameters[1] === '') {
// External user via public link share
return [
'newfile' => $this->getFile($parameters[0]),
'oldfile' => $this->getFile($parameters[2]),
];
}
return [ return [
'newfile' => $this->getFile($parameters[0]), 'newfile' => $this->getFile($parameters[0]),
'user' => $this->getUser($parameters[1]), 'user' => $this->getUser($parameters[1]),