Fix path handling for activities
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
737af44b63
commit
f1e01dbbbc
|
@ -29,6 +29,7 @@ use OCP\Activity\IEventMerger;
|
||||||
use OCP\Activity\IManager;
|
use OCP\Activity\IManager;
|
||||||
use OCP\Activity\IProvider;
|
use OCP\Activity\IProvider;
|
||||||
use OCP\Files\Folder;
|
use OCP\Files\Folder;
|
||||||
|
use OCP\Files\InvalidPathException;
|
||||||
use OCP\Files\IRootFolder;
|
use OCP\Files\IRootFolder;
|
||||||
use OCP\Files\Node;
|
use OCP\Files\Node;
|
||||||
use OCP\Files\NotFoundException;
|
use OCP\Files\NotFoundException;
|
||||||
|
@ -342,13 +343,25 @@ class Provider implements IProvider {
|
||||||
$encryptionContainer = $this->getEndToEndEncryptionContainer($id, basename($path));
|
$encryptionContainer = $this->getEndToEndEncryptionContainer($id, basename($path));
|
||||||
if ($encryptionContainer instanceof Folder) {
|
if ($encryptionContainer instanceof Folder) {
|
||||||
$this->fileIsEncrypted = true;
|
$this->fileIsEncrypted = true;
|
||||||
return [
|
try {
|
||||||
'type' => 'file',
|
$fullPath = rtrim($encryptionContainer->getPath(), '/');
|
||||||
'id' => $encryptionContainer->getId(),
|
// Remove /user/files/...
|
||||||
'name' => $encryptionContainer->getName(),
|
list(,,, $path) = explode('/', $fullPath, 4);
|
||||||
'path' => trim($encryptionContainer->getPath(), '/'), // FIXME remove /user/files/...
|
if (!$path) {
|
||||||
'link' => $this->url->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $encryptionContainer->getId()]),
|
throw new InvalidPathException('Path could not be split correctly');
|
||||||
];
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'type' => 'file',
|
||||||
|
'id' => $encryptionContainer->getId(),
|
||||||
|
'name' => $encryptionContainer->getName(),
|
||||||
|
'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 [
|
return [
|
||||||
|
|
Loading…
Reference in New Issue