Skip to content

Commit

Permalink
Remove leading slash from sharing activity
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Dec 15, 2016
1 parent 3714a6a commit 6de0eb0
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion apps/comments/lib/Activity/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ protected function generateFileParameter($id, $path) {
'type' => 'file',
'id' => $id,
'name' => basename($path),
'path' => $path,
'path' => trim($path, '/'),
'link' => $this->url->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $id]),
];
}
Expand Down
5 changes: 3 additions & 2 deletions apps/files/lib/Activity/FavoriteProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,11 @@ protected function setSubjects(IEvent $event, $subject) {
'type' => 'file',
'id' => $event->getObjectId(),
'name' => basename($event->getObjectName()),
'path' => $event->getObjectName(),
'path' => trim($event->getObjectName(), '/'),
'link' => $this->url->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $event->getObjectId()]),
];

$event->setParsedSubject(str_replace('{file}', trim($parameter['path'], '/'), $subject))
$event->setParsedSubject(str_replace('{file}', $parameter['path'], $subject))
->setRichSubject($subject, ['file' => $parameter]);
}
}
5 changes: 3 additions & 2 deletions apps/files/lib/Activity/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ protected function setSubjects(IEvent $event, $subject, array $parameters) {
foreach ($parameters as $placeholder => $parameter) {
$placeholders[] = '{' . $placeholder . '}';
if ($parameter['type'] === 'file') {
$replacements[] = trim($parameter['path'], '/');
$replacements[] = $parameter['path'];
} else {
$replacements[] = $parameter['name'];
}
Expand Down Expand Up @@ -253,7 +253,8 @@ protected function getRichFileParameter($parameter) {
'type' => 'file',
'id' => $id,
'name' => basename($path),
'path' => $path,
'path' => trim($path, '/'),
'link' => $this->url->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $id]),
];
}

Expand Down
2 changes: 1 addition & 1 deletion apps/files_sharing/lib/Activity/Providers/Downloads.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ protected function generateFileParameter($id, $path) {
'type' => 'file',
'id' => $id,
'name' => basename($path),
'path' => $path,
'path' => trim($path, '/'),
'link' => $this->url->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $id]),
];
}
Expand Down
2 changes: 1 addition & 1 deletion apps/files_sharing/lib/Activity/Providers/Groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ protected function generateFileParameter($id, $path) {
'type' => 'file',
'id' => $id,
'name' => basename($path),
'path' => $path,
'path' => trim($path, '/'),
'link' => $this->url->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $id]),
];
}
Expand Down
2 changes: 1 addition & 1 deletion apps/files_sharing/lib/Activity/Providers/PublicLinks.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ protected function generateFileParameter($id, $path) {
'type' => 'file',
'id' => $id,
'name' => basename($path),
'path' => $path,
'path' => trim($path, '/'),
'link' => $this->url->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $id]),
];
}
Expand Down
2 changes: 1 addition & 1 deletion apps/files_sharing/lib/Activity/Providers/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ protected function generateFileParameter($id, $path) {
'type' => 'file',
'id' => $id,
'name' => basename($path),
'path' => $path,
'path' => trim($path, '/'),
'link' => $this->url->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $id]),
];
}
Expand Down
2 changes: 1 addition & 1 deletion apps/sharebymail/lib/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ protected function generateFileParameter($id, $path) {
'type' => 'file',
'id' => $id,
'name' => basename($path),
'path' => $path,
'path' => trim($path, '/'),
'link' => $this->url->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $id]),
];
}
Expand Down
2 changes: 1 addition & 1 deletion lib/public/RichObjectStrings/Definitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class Definitions {
'path' => [
'since' => '11.0.0',
'required' => true,
'description' => 'The full path of the file for the user',
'description' => 'The full path of the file for the user, should not start with a slash',
'example' => 'path/to/file.txt',
],
'link' => [
Expand Down

0 comments on commit 6de0eb0

Please sign in to comment.