Skip to content

Commit

Permalink
Merge pull request #309 from nextcloud/backport/306/306-stable24
Browse files Browse the repository at this point in the history
[stable24] remove link to file
  • Loading branch information
emoral435 authored Jan 17, 2024
2 parents 1e11342 + 34a63ed commit 2cbd7a1
Showing 1 changed file with 5 additions and 23 deletions.
28 changes: 5 additions & 23 deletions lib/Activity/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,16 @@ public function parse($language, IEvent $event, IEvent $previousEvent = null) {
'id' => $params[0],
'name' => $params[0],
];
$parameters['file'] = [
'type' => 'highlight',
'id' => $event->getObjectName(),
'name' => $event->getObjectName(),
];

if ($event->getMessage() === self::MESSAGE_FILE_DELETED) {
$event->setParsedMessage($l->t('The file has been removed'));

$parameters['file'] = $this->getFileDeleted($event);
$event->setIcon($this->urlGenerator->imagePath('files_antivirus', 'shield-dark.svg'));
} else {
$parameters['file'] = $this->getFileExisting($event);
$event->setIcon($this->urlGenerator->imagePath('files_antivirus', 'shield-red.svg'));
}
}
Expand All @@ -131,24 +133,4 @@ private function setSubjects(IEvent $event, string $subject, array $parameters):
$event->setParsedSubject(str_replace($placeholders, $replacements, $subject))
->setRichSubject($subject, $parameters);
}

private function getFileExisting(IEvent $event) {
$res = $this->getFileDeleted($event);
$res['link'] = $this->urlGenerator->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $event->getObjectId()]);
return $res;
}

/**
* @return (int|string)[]
*
* @psalm-return array{type: 'file', id: int, name: string, path: string}
*/
private function getFileDeleted(IEvent $event): array {
return [
'type' => 'file',
'id' => $event->getObjectId(),
'name' => basename($event->getObjectName()),
'path' => $event->getObjectName(),
];
}
}

0 comments on commit 2cbd7a1

Please sign in to comment.