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;
|
||||||
|
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 [
|
return [
|
||||||
'type' => 'file',
|
'type' => 'file',
|
||||||
'id' => $encryptionContainer->getId(),
|
'id' => $encryptionContainer->getId(),
|
||||||
'name' => $encryptionContainer->getName(),
|
'name' => $encryptionContainer->getName(),
|
||||||
'path' => trim($encryptionContainer->getPath(), '/'), // FIXME remove /user/files/...
|
'path' => $path,
|
||||||
'link' => $this->url->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $encryptionContainer->getId()]),
|
'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