Skip to content
Merged
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
23 changes: 0 additions & 23 deletions apps/admin_audit/lib/Listener/SharingEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,18 +148,6 @@ private function shareCreated(ShareCreatedEvent $event): void {
'id',
]
),
IShare::TYPE_SCIENCEMESH => $this->log(
'The %s "%s" with ID "%s" has been shared to the sciencemesh user "%s" with permissions "%s" (Share ID: %s)',
$params,
[
'itemType',
'path',
'itemSource',
'shareWith',
'permissions',
'id',
]
),
default => null
};
}
Expand Down Expand Up @@ -274,17 +262,6 @@ private function shareDeleted(ShareDeletedEvent $event): void {
'id',
]
),
IShare::TYPE_SCIENCEMESH => $this->log(
'The %s "%s" with ID "%s" has been unshared from the sciencemesh user "%s" (Share ID: %s)',
$params,
[
'itemType',
'fileTarget',
'itemSource',
'shareWith',
'id',
]
),
default => null
};
}
Expand Down
1 change: 0 additions & 1 deletion apps/dav/lib/Connector/Sabre/SharesPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ private function getShare(Node $node): array {
IShare::TYPE_ROOM,
IShare::TYPE_CIRCLE,
IShare::TYPE_DECK,
IShare::TYPE_SCIENCEMESH,
];

foreach ($requestedShareTypes as $requestedShareType) {
Expand Down
1 change: 0 additions & 1 deletion apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ public static function sharesGetPropertiesDataProvider(): array {
[[IShare::TYPE_REMOTE]],
[[IShare::TYPE_ROOM]],
[[IShare::TYPE_DECK]],
[[IShare::TYPE_SCIENCEMESH]],
[[IShare::TYPE_USER, IShare::TYPE_GROUP]],
[[IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_LINK]],
[[IShare::TYPE_USER, IShare::TYPE_LINK]],
Expand Down
1 change: 0 additions & 1 deletion apps/files/lib/Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ private function getShareTypesForNodes(array $nodes): array {
IShare::TYPE_EMAIL,
IShare::TYPE_ROOM,
IShare::TYPE_DECK,
IShare::TYPE_SCIENCEMESH,
];
$shareTypes = [];

Expand Down
1 change: 0 additions & 1 deletion apps/files/lib/Service/OwnershipTransferService.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@ private function collectUsersShares(
IShare::TYPE_EMAIL,
IShare::TYPE_CIRCLE,
IShare::TYPE_DECK,
IShare::TYPE_SCIENCEMESH,
];

foreach ($supportedShareTypes as $shareType) {
Expand Down
57 changes: 16 additions & 41 deletions apps/files_sharing/lib/Controller/DeletedShareAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*/
namespace OCA\Files_Sharing\Controller;

use OCA\Deck\Sharing\ShareAPIHelper;
use OCA\Files_Sharing\ResponseDefinitions;
use OCP\App\IAppManager;
use OCP\AppFramework\Http;
Expand All @@ -29,6 +28,7 @@
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IManager as ShareManager;
use OCP\Share\IShare;
use Psr\Container\ContainerExceptionInterface;

/**
* @psalm-import-type Files_SharingDeletedShare from ResponseDefinitions
Expand Down Expand Up @@ -108,24 +108,18 @@ private function formatShare(IShare $share): array {
$result['share_with_displayname'] = '';

try {
/** @psalm-suppress UndefinedClass */
$result = array_merge($result, $this->getRoomShareHelper()->formatShare($share));
} catch (QueryException $e) {
} catch (ContainerExceptionInterface) {
}
} elseif ($share->getShareType() === IShare::TYPE_DECK) {
$result['share_with'] = $share->getSharedWith();
$result['share_with_displayname'] = '';

try {
/** @psalm-suppress UndefinedClass */
$result = array_merge($result, $this->getDeckShareHelper()->formatShare($share));
} catch (QueryException $e) {
}
} elseif ($share->getShareType() === IShare::TYPE_SCIENCEMESH) {
$result['share_with'] = $share->getSharedWith();
$result['share_with_displayname'] = '';

try {
$result = array_merge($result, $this->getSciencemeshShareHelper()->formatShare($share));
} catch (QueryException $e) {
} catch (ContainerExceptionInterface) {
}
}

Expand All @@ -145,13 +139,9 @@ public function index(): DataResponse {
$teamShares = $this->shareManager->getDeletedSharedWith($this->userId, IShare::TYPE_CIRCLE, null, -1, 0);
$roomShares = $this->shareManager->getDeletedSharedWith($this->userId, IShare::TYPE_ROOM, null, -1, 0);
$deckShares = $this->shareManager->getDeletedSharedWith($this->userId, IShare::TYPE_DECK, null, -1, 0);
$sciencemeshShares = $this->shareManager->getDeletedSharedWith($this->userId, IShare::TYPE_SCIENCEMESH, null, -1, 0);

$shares = array_merge($groupShares, $teamShares, $roomShares, $deckShares, $sciencemeshShares);

$shares = array_values(array_map(function (IShare $share) {
return $this->formatShare($share);
}, $shares));
$shares = array_merge($groupShares, $teamShares, $roomShares, $deckShares);
$shares = array_values(array_map(fn (IShare $share): array => $this->formatShare($share), $shares));

return new DataResponse($shares);
}
Expand All @@ -170,7 +160,7 @@ public function index(): DataResponse {
public function undelete(string $id): DataResponse {
try {
$share = $this->shareManager->getShareById($id, $this->userId);
} catch (ShareNotFound $e) {
} catch (ShareNotFound) {
throw new OCSNotFoundException('Share not found');
}

Expand All @@ -193,15 +183,16 @@ public function undelete(string $id): DataResponse {
* If the Talk application is not enabled or the helper is not available
* a QueryException is thrown instead.
*
* @return \OCA\Talk\Share\Helper\DeletedShareAPIController
* @psalm-suppress UndefinedClass
* @throws QueryException
*/
private function getRoomShareHelper() {
private function getRoomShareHelper(): \OCA\Talk\Share\Helper\DeletedShareAPIController {
if (!$this->appManager->isEnabledForUser('spreed')) {
throw new QueryException();
}

return Server::get('\OCA\Talk\Share\Helper\DeletedShareAPIController');
/** @psalm-suppress UndefinedClass */
return Server::get(\OCA\Talk\Share\Helper\DeletedShareAPIController::class);
}

/**
Expand All @@ -210,31 +201,15 @@ private function getRoomShareHelper() {
* If the Deck application is not enabled or the helper is not available
* a QueryException is thrown instead.
*
* @return ShareAPIHelper
* @psalm-suppress UndefinedClass
* @throws QueryException
*/
private function getDeckShareHelper() {
private function getDeckShareHelper(): \OCA\Deck\Sharing\ShareAPIHelper {
if (!$this->appManager->isEnabledForUser('deck')) {
throw new QueryException();
}

return Server::get('\OCA\Deck\Sharing\ShareAPIHelper');
}

/**
* Returns the helper of DeletedShareAPIHelper for sciencemesh shares.
*
* If the sciencemesh application is not enabled or the helper is not available
* a QueryException is thrown instead.
*
* @return ShareAPIHelper
* @throws QueryException
*/
private function getSciencemeshShareHelper() {
if (!$this->appManager->isEnabledForUser('sciencemesh')) {
throw new QueryException();
}

return Server::get('\OCA\ScienceMesh\Sharing\ShareAPIHelper');
/** @psalm-suppress UndefinedClass */
return Server::get(\OCA\Deck\Sharing\ShareAPIHelper::class);
}
}
43 changes: 2 additions & 41 deletions apps/files_sharing/lib/Controller/ShareAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,16 +331,6 @@ protected function formatShare(IShare $share, ?Node $recipientNode = null): arra
$result = array_merge($result, $deckShare);
} catch (ContainerExceptionInterface $e) {
}
} elseif ($share->getShareType() === IShare::TYPE_SCIENCEMESH) {
$result['share_with'] = $share->getSharedWith();
$result['share_with_displayname'] = '';

try {
/** @var array{share_with: string, share_with_displayname: string, token: string} $scienceMeshShare */
$scienceMeshShare = $this->getSciencemeshShareHelper()->formatShare($share);
$result = array_merge($result, $scienceMeshShare);
} catch (ContainerExceptionInterface $e) {
}
}


Expand Down Expand Up @@ -819,12 +809,6 @@ public function createShare(
} catch (ContainerExceptionInterface $e) {
throw new OCSForbiddenException($this->l->t('Sharing %s failed because the back end does not support room shares', [$node->getPath()]));
}
} elseif ($shareType === IShare::TYPE_SCIENCEMESH) {
try {
$this->getSciencemeshShareHelper()->createShare($share, $shareWith, $permissions, $expireDate ?? '');
} catch (ContainerExceptionInterface $e) {
throw new OCSForbiddenException($this->l->t('Sharing %s failed because the back end does not support ScienceMesh shares', [$node->getPath()]));
}
} else {
throw new OCSBadRequestException($this->l->t('Unknown share type'));
}
Expand Down Expand Up @@ -866,9 +850,8 @@ private function getSharedWithMe($node, bool $includeTags): array {
$circleShares = $this->shareManager->getSharedWith($this->userId, IShare::TYPE_CIRCLE, $node, -1, 0);
$roomShares = $this->shareManager->getSharedWith($this->userId, IShare::TYPE_ROOM, $node, -1, 0);
$deckShares = $this->shareManager->getSharedWith($this->userId, IShare::TYPE_DECK, $node, -1, 0);
$sciencemeshShares = $this->shareManager->getSharedWith($this->userId, IShare::TYPE_SCIENCEMESH, $node, -1, 0);

$shares = array_merge($userShares, $groupShares, $circleShares, $roomShares, $deckShares, $sciencemeshShares);
$shares = array_merge($userShares, $groupShares, $circleShares, $roomShares, $deckShares);

$filteredShares = array_filter($shares, function (IShare $share) {
return $share->getShareOwner() !== $this->userId && $share->getSharedBy() !== $this->userId;
Expand Down Expand Up @@ -1579,14 +1562,6 @@ protected function canAccessShare(IShare $share, bool $checkGroups = true): bool
}
}

if ($share->getShareType() === IShare::TYPE_SCIENCEMESH) {
try {
return $this->getSciencemeshShareHelper()->canAccessShare($share, $this->userId);
} catch (ContainerExceptionInterface $e) {
return false;
}
}

return false;
}

Expand Down Expand Up @@ -1676,7 +1651,6 @@ protected function canDeleteShareFromSelf(IShare $share): bool {
if ($share->getShareType() !== IShare::TYPE_GROUP
&& $share->getShareType() !== IShare::TYPE_ROOM
&& $share->getShareType() !== IShare::TYPE_DECK
&& $share->getShareType() !== IShare::TYPE_SCIENCEMESH
) {
return false;
}
Expand Down Expand Up @@ -1713,14 +1687,6 @@ protected function canDeleteShareFromSelf(IShare $share): bool {
}
}

if ($share->getShareType() === IShare::TYPE_SCIENCEMESH) {
try {
return $this->getSciencemeshShareHelper()->canAccessShare($share, $this->userId);
} catch (ContainerExceptionInterface $e) {
return false;
}
}

return false;
}

Expand Down Expand Up @@ -1761,7 +1727,6 @@ private function getShareById(string $id): IShare {
'ocMailShare' => IShare::TYPE_EMAIL,
'ocRoomShare' => null,
'deck' => IShare::TYPE_DECK,
'sciencemesh' => IShare::TYPE_SCIENCEMESH,
];

// Add federated sharing as a provider only if it's allowed
Expand Down Expand Up @@ -1875,7 +1840,6 @@ private function getSharesFromNode(string $viewer, $node, bool $reShares): array
IShare::TYPE_CIRCLE,
IShare::TYPE_ROOM,
IShare::TYPE_DECK,
IShare::TYPE_SCIENCEMESH
];

// Should we assume that the (currentUser) viewer is the owner of the node !?
Expand Down Expand Up @@ -2031,9 +1995,6 @@ private function getAllShares(?Node $path = null, bool $reshares = false) {
// DECK SHARES
$deckShares = $this->shareManager->getSharesBy($this->userId, IShare::TYPE_DECK, $path, $reshares, -1, 0);

// SCIENCEMESH SHARES
$sciencemeshShares = $this->shareManager->getSharesBy($this->userId, IShare::TYPE_SCIENCEMESH, $path, $reshares, -1, 0);

// FEDERATION
if ($this->shareManager->outgoingServer2ServerSharesAllowed()) {
$federatedShares = $this->shareManager->getSharesBy($this->userId, IShare::TYPE_REMOTE, $path, $reshares, -1, 0);
Expand All @@ -2046,7 +2007,7 @@ private function getAllShares(?Node $path = null, bool $reshares = false) {
$federatedGroupShares = [];
}

return array_merge($userShares, $groupShares, $linkShares, $mailShares, $circleShares, $roomShares, $deckShares, $sciencemeshShares, $federatedShares, $federatedGroupShares);
return array_merge($userShares, $groupShares, $linkShares, $mailShares, $circleShares, $roomShares, $deckShares, $federatedShares, $federatedGroupShares);
}


Expand Down
8 changes: 0 additions & 8 deletions apps/files_sharing/lib/Controller/ShareesAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,6 @@ public function search(string $search = '', ?string $itemType = null, int $page
if ($this->shareManager->shareProviderExists(IShare::TYPE_ROOM)) {
$shareTypes[] = IShare::TYPE_ROOM;
}

if ($this->shareManager->shareProviderExists(IShare::TYPE_SCIENCEMESH)) {
$shareTypes[] = IShare::TYPE_SCIENCEMESH;
}
} else {
if ($this->shareManager->allowGroupSharing()) {
$shareTypes[] = IShare::TYPE_GROUP;
Expand All @@ -162,10 +158,6 @@ public function search(string $search = '', ?string $itemType = null, int $page
$shareTypes[] = IShare::TYPE_CIRCLE;
}

if ($this->shareManager->shareProviderExists(IShare::TYPE_SCIENCEMESH)) {
$shareTypes[] = IShare::TYPE_SCIENCEMESH;
}

if ($itemType === 'calendar') {
$shareTypes[] = IShare::TYPE_REMOTE;
}
Expand Down
1 change: 0 additions & 1 deletion apps/files_sharing/lib/MountProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public function getMountsForUser(IUser $user, IStorageFactory $loader) {
$this->shareManager->getSharedWith($userId, IShare::TYPE_CIRCLE, null, -1),
$this->shareManager->getSharedWith($userId, IShare::TYPE_ROOM, null, -1),
$this->shareManager->getSharedWith($userId, IShare::TYPE_DECK, null, -1),
$this->shareManager->getSharedWith($userId, IShare::TYPE_SCIENCEMESH, null, -1),
);

$shares = $this->filterShares($shares, $userId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,10 @@ public function testDeleteShareShareNotFound(): void {
$this->expectExceptionMessage('Wrong share ID, share does not exist');

$this->shareManager
->expects($this->exactly(7))
->expects($this->exactly(6))
->method('getShareById')
->willReturnCallback(function ($id): void {
if ($id === 'ocinternal:42' || $id === 'ocRoomShare:42' || $id === 'ocFederatedSharing:42' || $id === 'ocCircleShare:42' || $id === 'ocMailShare:42' || $id === 'deck:42' || $id === 'sciencemesh:42') {
if ($id === 'ocinternal:42' || $id === 'ocRoomShare:42' || $id === 'ocFederatedSharing:42' || $id === 'ocCircleShare:42' || $id === 'ocMailShare:42' || $id === 'deck:42') {
throw new ShareNotFound();
} else {
throw new \Exception();
Expand Down
8 changes: 3 additions & 5 deletions apps/files_sharing/tests/MountProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,14 @@ public function testExcludeShares(): void {
$this->user->expects($this->any())
->method('getUID')
->willReturn('user1');
$this->shareManager->expects($this->exactly(6))
$this->shareManager->expects($this->exactly(5))
->method('getSharedWith')
->willReturnMap([
['user1', IShare::TYPE_USER, null, -1, 0, $userShares],
['user1', IShare::TYPE_GROUP, null, -1, 0, $groupShares],
['user1', IShare::TYPE_CIRCLE, null, -1, 0, $circleShares],
['user1', IShare::TYPE_ROOM, null, -1, 0, $roomShares],
['user1', IShare::TYPE_DECK, null, -1, 0, $deckShares],
['user1', IShare::TYPE_SCIENCEMESH, null, -1, 0, $scienceMeshShares],
]);

$this->shareManager->expects($this->any())
Expand Down Expand Up @@ -337,7 +336,7 @@ public static function mergeSharesDataProvider(): array {
* @param array $expectedShares array of expected supershare specs
*/
#[\PHPUnit\Framework\Attributes\DataProvider('mergeSharesDataProvider')]
public function testMergeShares($userShares, $groupShares, $expectedShares, $moveFails = false): void {
public function testMergeShares(array $userShares, array $groupShares, array $expectedShares, bool $moveFails = false): void {
$rootFolder = $this->createMock(IRootFolder::class);
$userManager = $this->createMock(IUserManager::class);

Expand All @@ -357,15 +356,14 @@ public function testMergeShares($userShares, $groupShares, $expectedShares, $mov
$roomShares = [];
$deckShares = [];
$scienceMeshShares = [];
$this->shareManager->expects($this->exactly(6))
$this->shareManager->expects($this->exactly(5))
->method('getSharedWith')
->willReturnMap([
['user1', IShare::TYPE_USER, null, -1, 0, $userShares],
['user1', IShare::TYPE_GROUP, null, -1, 0, $groupShares],
['user1', IShare::TYPE_CIRCLE, null, -1, 0, $circleShares],
['user1', IShare::TYPE_ROOM, null, -1, 0, $roomShares],
['user1', IShare::TYPE_DECK, null, -1, 0, $deckShares],
['user1', IShare::TYPE_SCIENCEMESH, null, -1, 0, $scienceMeshShares],
]);

$this->shareManager->expects($this->any())
Expand Down
Loading
Loading