diff --git a/lib/Connector/Sabre/PropFindPlugin.php b/lib/Connector/Sabre/PropFindPlugin.php index b327aaf0..24b800ac 100644 --- a/lib/Connector/Sabre/PropFindPlugin.php +++ b/lib/Connector/Sabre/PropFindPlugin.php @@ -37,6 +37,8 @@ use Sabre\HTTP\RequestInterface; class PropFindPlugin extends APlugin { + public const IS_ENCRYPTED_PROPERTYNAME = '{http://nextcloud.org/ns}is-encrypted'; + private UserAgentManager $userAgentManager; private IRequest $request; protected ?Server $server = null; @@ -59,9 +61,19 @@ public function initialize(Server $server) { $this->server = $server; $this->server->on('afterMethod:PROPFIND', [$this, 'checkAccess'], 50); + $this->server->on('propFind', [$this, 'setEncryptedProperty'], 104); $this->server->on('propFind', [$this, 'updateProperty'], 105); } + public function setEncryptedProperty(PropFind $propFind, \Sabre\DAV\INode $node) { + // Only folders can be e2e encrypted, so we only respond for directories. + if ($node instanceof Directory) { + $propFind->handle(self::IS_ENCRYPTED_PROPERTYNAME, function () use ($node) { + return $node->getFileInfo()->isEncrypted() ? '1' : '0'; + }); + } + } + /** * Remove permissions of end-to-end encrypted files for unsupported clients * diff --git a/tests/stub.phpstub b/tests/stub.phpstub index 1624ecd8..5e7d4929 100644 --- a/tests/stub.phpstub +++ b/tests/stub.phpstub @@ -65,6 +65,7 @@ namespace Sabre\DAV { public function set(string $key, string $value, int $stuff) {} public function getPath(): string {} public function setPath(string $string): void {} + public function handle($propertyName, $valueOrCallBack) } class Server {