refactor(share): Remove code related to science mesh integration

The app was not updated for the past 2 years.

Signed-off-by: Carl Schwan <carl.schwan@nextcloud.com>
This commit is contained in:
Carl Schwan 2025-12-01 16:32:13 +01:00
parent 86c2dd467d
commit cc7655136c
No known key found for this signature in database
GPG key ID: 02325448204E452A
16 changed files with 25 additions and 133 deletions

View file

@ -148,18 +148,6 @@ class SharingEventListener extends Action implements IEventListener {
'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
};
}
@ -274,17 +262,6 @@ class SharingEventListener extends Action implements IEventListener {
'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
};
}

View file

@ -99,7 +99,6 @@ class SharesPlugin extends \Sabre\DAV\ServerPlugin {
IShare::TYPE_ROOM,
IShare::TYPE_CIRCLE,
IShare::TYPE_DECK,
IShare::TYPE_SCIENCEMESH,
];
foreach ($requestedShareTypes as $requestedShareType) {

View file

@ -253,7 +253,6 @@ class SharesPluginTest extends \Test\TestCase {
[[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]],

View file

@ -198,7 +198,6 @@ class ApiController extends Controller {
IShare::TYPE_EMAIL,
IShare::TYPE_ROOM,
IShare::TYPE_DECK,
IShare::TYPE_SCIENCEMESH,
];
$shareTypes = [];

View file

@ -319,7 +319,6 @@ class OwnershipTransferService {
IShare::TYPE_EMAIL,
IShare::TYPE_CIRCLE,
IShare::TYPE_DECK,
IShare::TYPE_SCIENCEMESH,
];
foreach ($supportedShareTypes as $shareType) {

View file

@ -8,7 +8,6 @@ declare(strict_types=1);
*/
namespace OCA\Files_Sharing\Controller;
use OCA\Deck\Sharing\ShareAPIHelper;
use OCA\Files_Sharing\ResponseDefinitions;
use OCP\App\IAppManager;
use OCP\AppFramework\Http;
@ -29,6 +28,7 @@ use OCP\Share\Exceptions\GenericShareException;
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
@ -108,24 +108,18 @@ class DeletedShareAPIController extends OCSController {
$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) {
}
}
@ -145,13 +139,9 @@ class DeletedShareAPIController extends OCSController {
$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);
}
@ -170,7 +160,7 @@ class DeletedShareAPIController extends OCSController {
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');
}
@ -193,15 +183,16 @@ class DeletedShareAPIController extends OCSController {
* 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);
}
/**
@ -210,31 +201,15 @@ class DeletedShareAPIController extends OCSController {
* 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);
}
}

View file

@ -331,16 +331,6 @@ class ShareAPIController extends OCSController {
$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) {
}
}
@ -819,12 +809,6 @@ class ShareAPIController extends OCSController {
} 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'));
}
@ -866,9 +850,8 @@ class ShareAPIController extends OCSController {
$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;
@ -1579,14 +1562,6 @@ class ShareAPIController extends OCSController {
}
}
if ($share->getShareType() === IShare::TYPE_SCIENCEMESH) {
try {
return $this->getSciencemeshShareHelper()->canAccessShare($share, $this->userId);
} catch (ContainerExceptionInterface $e) {
return false;
}
}
return false;
}
@ -1676,7 +1651,6 @@ class ShareAPIController extends OCSController {
if ($share->getShareType() !== IShare::TYPE_GROUP
&& $share->getShareType() !== IShare::TYPE_ROOM
&& $share->getShareType() !== IShare::TYPE_DECK
&& $share->getShareType() !== IShare::TYPE_SCIENCEMESH
) {
return false;
}
@ -1713,14 +1687,6 @@ class ShareAPIController extends OCSController {
}
}
if ($share->getShareType() === IShare::TYPE_SCIENCEMESH) {
try {
return $this->getSciencemeshShareHelper()->canAccessShare($share, $this->userId);
} catch (ContainerExceptionInterface $e) {
return false;
}
}
return false;
}
@ -1761,7 +1727,6 @@ class ShareAPIController extends OCSController {
'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
@ -1875,7 +1840,6 @@ class ShareAPIController extends OCSController {
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 !?
@ -2031,9 +1995,6 @@ class ShareAPIController extends OCSController {
// 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);
@ -2046,7 +2007,7 @@ class ShareAPIController extends OCSController {
$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);
}

View file

@ -146,10 +146,6 @@ class ShareesAPIController extends OCSController {
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;
@ -162,10 +158,6 @@ class ShareesAPIController extends OCSController {
$shareTypes[] = IShare::TYPE_CIRCLE;
}
if ($this->shareManager->shareProviderExists(IShare::TYPE_SCIENCEMESH)) {
$shareTypes[] = IShare::TYPE_SCIENCEMESH;
}
if ($itemType === 'calendar') {
$shareTypes[] = IShare::TYPE_REMOTE;
}

View file

@ -57,7 +57,6 @@ class MountProvider implements IMountProvider {
$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);

View file

@ -217,10 +217,10 @@ class ShareAPIControllerTest extends TestCase {
$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();

View file

@ -140,7 +140,7 @@ class MountProviderTest extends \Test\TestCase {
$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],
@ -148,7 +148,6 @@ class MountProviderTest extends \Test\TestCase {
['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())
@ -337,7 +336,7 @@ class MountProviderTest extends \Test\TestCase {
* @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);
@ -357,7 +356,7 @@ class MountProviderTest extends \Test\TestCase {
$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],
@ -365,7 +364,6 @@ class MountProviderTest extends \Test\TestCase {
['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())

View file

@ -1548,7 +1548,6 @@
<DeprecatedClass>
<code><![CDATA[new QueryException()]]></code>
<code><![CDATA[new QueryException()]]></code>
<code><![CDATA[new QueryException()]]></code>
</DeprecatedClass>
</file>
<file src="apps/files_sharing/lib/Controller/RemoteController.php">

View file

@ -1874,7 +1874,6 @@ class View {
IShare::TYPE_CIRCLE,
IShare::TYPE_ROOM,
IShare::TYPE_DECK,
IShare::TYPE_SCIENCEMESH
];
$shareManager = Server::get(IManager::class);
/** @var IShare[] $shares */

View file

@ -171,10 +171,7 @@ class Manager implements IManager {
if ($circle === null) {
throw new \InvalidArgumentException($this->l->t('Share recipient is not a valid circle'));
}
} elseif ($share->getShareType() === IShare::TYPE_ROOM) {
} elseif ($share->getShareType() === IShare::TYPE_DECK) {
} elseif ($share->getShareType() === IShare::TYPE_SCIENCEMESH) {
} else {
} elseif ($share->getShareType() !== IShare::TYPE_ROOM && $share->getShareType() !== IShare::TYPE_DECK) {
// We cannot handle other types yet
throw new \InvalidArgumentException($this->l->t('Unknown share type'));
}

View file

@ -189,8 +189,6 @@ class ProviderFactory implements IProviderFactory {
$provider = $this->getRoomShareProvider();
} elseif ($shareType === IShare::TYPE_DECK) {
$provider = $this->getProvider('deck');
} elseif ($shareType === IShare::TYPE_SCIENCEMESH) {
$provider = $this->getProvider('sciencemesh');
}

View file

@ -98,6 +98,7 @@ interface IShare {
/**
* @since 26.0.0
* @deprecated 33.0.0 The app is abandonned.
*/
public const TYPE_SCIENCEMESH = 15;