Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@
'OCP\\Share\\IShare' => $baseDir . '/lib/public/Share/IShare.php',
'OCP\\Share\\IShareHelper' => $baseDir . '/lib/public/Share/IShareHelper.php',
'OCP\\Share\\IShareProvider' => $baseDir . '/lib/public/Share/IShareProvider.php',
'OCP\\Share\\IShareProviderGetUsers' => $baseDir . '/lib/public/Share/IShareProviderGetUsers.php',
'OCP\\Share\\IShareProviderSupportsAccept' => $baseDir . '/lib/public/Share/IShareProviderSupportsAccept.php',
'OCP\\Share\\IShareProviderSupportsAllSharesInFolder' => $baseDir . '/lib/public/Share/IShareProviderSupportsAllSharesInFolder.php',
'OCP\\Share\\IShareProviderWithNotification' => $baseDir . '/lib/public/Share/IShareProviderWithNotification.php',
Expand Down
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OCP\\Share\\IShare' => __DIR__ . '/../../..' . '/lib/public/Share/IShare.php',
'OCP\\Share\\IShareHelper' => __DIR__ . '/../../..' . '/lib/public/Share/IShareHelper.php',
'OCP\\Share\\IShareProvider' => __DIR__ . '/../../..' . '/lib/public/Share/IShareProvider.php',
'OCP\\Share\\IShareProviderGetUsers' => __DIR__ . '/../../..' . '/lib/public/Share/IShareProviderGetUsers.php',
'OCP\\Share\\IShareProviderSupportsAccept' => __DIR__ . '/../../..' . '/lib/public/Share/IShareProviderSupportsAccept.php',
'OCP\\Share\\IShareProviderSupportsAllSharesInFolder' => __DIR__ . '/../../..' . '/lib/public/Share/IShareProviderSupportsAllSharesInFolder.php',
'OCP\\Share\\IShareProviderWithNotification' => __DIR__ . '/../../..' . '/lib/public/Share/IShareProviderWithNotification.php',
Expand Down
18 changes: 17 additions & 1 deletion lib/private/Share20/DefaultShareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use OCP\Share\IAttributes;
use OCP\Share\IManager;
use OCP\Share\IShare;
use OCP\Share\IShareProviderGetUsers;
use OCP\Share\IShareProviderSupportsAccept;
use OCP\Share\IShareProviderSupportsAllSharesInFolder;
use OCP\Share\IShareProviderWithNotification;
Expand All @@ -44,7 +45,11 @@
*
* @package OC\Share20
*/
class DefaultShareProvider implements IShareProviderWithNotification, IShareProviderSupportsAccept, IShareProviderSupportsAllSharesInFolder {
class DefaultShareProvider implements
IShareProviderWithNotification,
IShareProviderSupportsAccept,
IShareProviderSupportsAllSharesInFolder,
IShareProviderGetUsers {
public function __construct(
private IDBConnection $dbConn,
private IUserManager $userManager,
Expand Down Expand Up @@ -1678,4 +1683,15 @@ protected function formatShareAttributes(?IAttributes $attributes): ?string {
}
return \json_encode($compressedAttributes);
}

public function getUsersForShare(IShare $share): iterable {
if ($share->getShareType() === IShare::TYPE_USER) {
return [new LazyUser($share->getSharedWith(), $this->userManager)];
} elseif ($share->getShareType() === IShare::TYPE_GROUP) {
$group = $this->groupManager->get($share->getSharedWith());
return $group->getUsers();
} else {
return [];
}
}
}
9 changes: 9 additions & 0 deletions lib/private/Share20/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -1884,4 +1884,13 @@ private function dispatchEvent(Event $event, string $name): void {
$this->logger->error("Error while sending ' . $name . ' event", ['exception' => $e]);
}
}

public function getUsersForShare(IShare $share): iterable {
$provider = $this->factory->getProviderForType($share->getShareType());
if ($provider instanceof Share\IShareProviderGetUsers) {
return $provider->getUsersForShare($share);
} else {
return [];
}
}
}
9 changes: 9 additions & 0 deletions lib/public/Share/IManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -518,4 +518,13 @@ public function getAllShares(): iterable;
* @since 31.0.0
*/
public function generateToken(): string;

/**
* Get all users with access to a share
*
* @param IShare $share
* @return iterable<IUser>
* @since 33.0.0
*/
public function getUsersForShare(IShare $share): iterable;
}
28 changes: 28 additions & 0 deletions lib/public/Share/IShareProviderGetUsers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCP\Share;

use OCP\IUser;

/**
* Interface IShareProviderSupportsAccept
*
* This interface allows to define IShareProvider that can list users for share with the getUsersForShare method,
* which is available since Nextcloud 17.
*
* @since 33.0.0
*/
interface IShareProviderGetUsers extends IShareProvider {
/**
* Get all users with access to a share
*
* @param IShare $share
* @return iterable<IUser>
* @since 33.0.0
*/
public function getUsersForShare(IShare $share): iterable;
}
Loading