Skip to content

Commit

Permalink
debt: Own the handling of the is-encrypted DAV property
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chemineau <louis@chmn.me>
  • Loading branch information
artonge committed Aug 26, 2024
1 parent da63d9d commit 10b11a2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/Connector/Sabre/PropFindPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -58,10 +60,20 @@ public function initialize(Server $server) {
parent::initialize($server);

$this->server = $server;
$this->server->on('propFind', [$this, 'setEncryptedProperty']);

Check failure on line 63 in lib/Connector/Sabre/PropFindPlugin.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

TooFewArguments

lib/Connector/Sabre/PropFindPlugin.php:63:18: TooFewArguments: Too few arguments for Sabre\DAV\Server::on - expecting priority to be passed (see https://psalm.dev/025)

Check failure on line 63 in lib/Connector/Sabre/PropFindPlugin.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

TooFewArguments

lib/Connector/Sabre/PropFindPlugin.php:63:18: TooFewArguments: Too few arguments for method Sabre\DAV\Server::on saw 2 (see https://psalm.dev/025)
$this->server->on('afterMethod:PROPFIND', [$this, 'checkAccess'], 50);
$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) {

Check failure on line 71 in lib/Connector/Sabre/PropFindPlugin.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

UndefinedMethod

lib/Connector/Sabre/PropFindPlugin.php:71:15: UndefinedMethod: Method Sabre\DAV\PropFind::handle does not exist (see https://psalm.dev/022)
return $node->getFileInfo()->isEncrypted() ? '1' : '0';
});
}
}

/**
* Remove permissions of end-to-end encrypted files for unsupported clients
*
Expand Down

0 comments on commit 10b11a2

Please sign in to comment.