Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(dav): Allow UploadHome to handle public shares
Signed-off-by: provokateurin <[email protected]>
  • Loading branch information
provokateurin committed May 5, 2025
commit a55e61d97c09b80afb4748edacdb14966710d300
1 change: 1 addition & 0 deletions apps/dav/lib/RootCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ public function __construct() {
Server::get(CleanupService::class),
$rootFolder,
$userSession,
$shareManager,
);
$uploadCollection->disableListing = $disableListing;

Expand Down
10 changes: 9 additions & 1 deletion apps/dav/lib/Upload/RootCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use OCP\Files\IRootFolder;
use OCP\IUserSession;
use OCP\Share\IManager;
use Sabre\DAVACL\AbstractPrincipalCollection;
use Sabre\DAVACL\PrincipalBackend;

Expand All @@ -22,6 +23,7 @@ public function __construct(
private CleanupService $cleanupService,
private IRootFolder $rootFolder,
private IUserSession $userSession,
private IManager $shareManager,
) {
parent::__construct($principalBackend, $principalPrefix);
}
Expand All @@ -30,7 +32,13 @@ public function __construct(
* @inheritdoc
*/
public function getChildForPrincipal(array $principalInfo): UploadHome {
return new UploadHome($principalInfo, $this->cleanupService, $this->rootFolder, $this->userSession);
return new UploadHome(
$principalInfo,
$this->cleanupService,
$this->rootFolder,
$this->userSession,
$this->shareManager,
);
}

/**
Expand Down
16 changes: 11 additions & 5 deletions apps/dav/lib/Upload/UploadHome.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,19 @@ public function __construct(
private readonly CleanupService $cleanupService,
private readonly IRootFolder $rootFolder,
private readonly IUserSession $userSession,
private readonly \OCP\Share\IManager $shareManager,
) {
$user = $this->userSession->getUser();
if (!$user) {
throw new Forbidden('Not logged in');
}
[$prefix, $name] = \Sabre\Uri\split($principalInfo['uri']);
if ($prefix === 'principals/shares') {
$this->uid = $this->shareManager->getShareByToken($name)->getShareOwner();
} else {
$user = $this->userSession->getUser();
if (!$user) {
throw new Forbidden('Not logged in');
}

$this->uid = $user->getUID();
$this->uid = $user->getUID();
}
}

public function createFile($name, $data = null) {
Expand Down