Skip to content

Commit

Permalink
remove link to file
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
  • Loading branch information
ArtificialOwl committed Jan 22, 2024
1 parent 791c356 commit 8db2c2b
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 8db2c2b

Please sign in to comment.