Fix path handling for activities

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2018-02-12 16:05:42 +01:00
parent 737af44b63
commit f1e01dbbbc
No known key found for this signature in database
GPG Key ID: 7076EA9751AACDDA
1 changed files with 20 additions and 7 deletions

View File

@ -29,6 +29,7 @@ use OCP\Activity\IEventMerger;
use OCP\Activity\IManager;
use OCP\Activity\IProvider;
use OCP\Files\Folder;
use OCP\Files\InvalidPathException;
use OCP\Files\IRootFolder;
use OCP\Files\Node;
use OCP\Files\NotFoundException;
@ -342,13 +343,25 @@ class Provider implements IProvider {
$encryptionContainer = $this->getEndToEndEncryptionContainer($id, basename($path));
if ($encryptionContainer instanceof Folder) {
$this->fileIsEncrypted = true;
try {
$fullPath = rtrim($encryptionContainer->getPath(), '/');
// Remove /user/files/...
list(,,, $path) = explode('/', $fullPath, 4);
if (!$path) {
throw new InvalidPathException('Path could not be split correctly');
}
return [
'type' => 'file',
'id' => $encryptionContainer->getId(),
'name' => $encryptionContainer->getName(),
'path' => trim($encryptionContainer->getPath(), '/'), // FIXME remove /user/files/...
'path' => $path,
'link' => $this->url->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $encryptionContainer->getId()]),
];
} catch (\Exception $e) {
// fall back to the normal one
$this->fileIsEncrypted = false;
}
}
return [