Skip to content

Commit 32327c6

Browse files
Merge pull request #56773 from nextcloud/carl/remove-sciencemesh
refactor(share): Remove code related to science mesh integration
2 parents 752d90c + cc76551 commit 32327c6

File tree

16 files changed

+25
-133
lines changed

16 files changed

+25
-133
lines changed

apps/admin_audit/lib/Listener/SharingEventListener.php

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -148,18 +148,6 @@ private function shareCreated(ShareCreatedEvent $event): void {
148148
'id',
149149
]
150150
),
151-
IShare::TYPE_SCIENCEMESH => $this->log(
152-
'The %s "%s" with ID "%s" has been shared to the sciencemesh user "%s" with permissions "%s" (Share ID: %s)',
153-
$params,
154-
[
155-
'itemType',
156-
'path',
157-
'itemSource',
158-
'shareWith',
159-
'permissions',
160-
'id',
161-
]
162-
),
163151
default => null
164152
};
165153
}
@@ -274,17 +262,6 @@ private function shareDeleted(ShareDeletedEvent $event): void {
274262
'id',
275263
]
276264
),
277-
IShare::TYPE_SCIENCEMESH => $this->log(
278-
'The %s "%s" with ID "%s" has been unshared from the sciencemesh user "%s" (Share ID: %s)',
279-
$params,
280-
[
281-
'itemType',
282-
'fileTarget',
283-
'itemSource',
284-
'shareWith',
285-
'id',
286-
]
287-
),
288265
default => null
289266
};
290267
}

apps/dav/lib/Connector/Sabre/SharesPlugin.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ private function getShare(Node $node): array {
9999
IShare::TYPE_ROOM,
100100
IShare::TYPE_CIRCLE,
101101
IShare::TYPE_DECK,
102-
IShare::TYPE_SCIENCEMESH,
103102
];
104103

105104
foreach ($requestedShareTypes as $requestedShareType) {

apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ public static function sharesGetPropertiesDataProvider(): array {
253253
[[IShare::TYPE_REMOTE]],
254254
[[IShare::TYPE_ROOM]],
255255
[[IShare::TYPE_DECK]],
256-
[[IShare::TYPE_SCIENCEMESH]],
257256
[[IShare::TYPE_USER, IShare::TYPE_GROUP]],
258257
[[IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_LINK]],
259258
[[IShare::TYPE_USER, IShare::TYPE_LINK]],

apps/files/lib/Controller/ApiController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ private function getShareTypesForNodes(array $nodes): array {
198198
IShare::TYPE_EMAIL,
199199
IShare::TYPE_ROOM,
200200
IShare::TYPE_DECK,
201-
IShare::TYPE_SCIENCEMESH,
202201
];
203202
$shareTypes = [];
204203

apps/files/lib/Service/OwnershipTransferService.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,6 @@ private function collectUsersShares(
328328
IShare::TYPE_EMAIL,
329329
IShare::TYPE_CIRCLE,
330330
IShare::TYPE_DECK,
331-
IShare::TYPE_SCIENCEMESH,
332331
];
333332

334333
foreach ($supportedShareTypes as $shareType) {

apps/files_sharing/lib/Controller/DeletedShareAPIController.php

Lines changed: 16 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
*/
99
namespace OCA\Files_Sharing\Controller;
1010

11-
use OCA\Deck\Sharing\ShareAPIHelper;
1211
use OCA\Files_Sharing\ResponseDefinitions;
1312
use OCP\App\IAppManager;
1413
use OCP\AppFramework\Http;
@@ -29,6 +28,7 @@
2928
use OCP\Share\Exceptions\ShareNotFound;
3029
use OCP\Share\IManager as ShareManager;
3130
use OCP\Share\IShare;
31+
use Psr\Container\ContainerExceptionInterface;
3232

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

110110
try {
111+
/** @psalm-suppress UndefinedClass */
111112
$result = array_merge($result, $this->getRoomShareHelper()->formatShare($share));
112-
} catch (QueryException $e) {
113+
} catch (ContainerExceptionInterface) {
113114
}
114115
} elseif ($share->getShareType() === IShare::TYPE_DECK) {
115116
$result['share_with'] = $share->getSharedWith();
116117
$result['share_with_displayname'] = '';
117118

118119
try {
120+
/** @psalm-suppress UndefinedClass */
119121
$result = array_merge($result, $this->getDeckShareHelper()->formatShare($share));
120-
} catch (QueryException $e) {
121-
}
122-
} elseif ($share->getShareType() === IShare::TYPE_SCIENCEMESH) {
123-
$result['share_with'] = $share->getSharedWith();
124-
$result['share_with_displayname'] = '';
125-
126-
try {
127-
$result = array_merge($result, $this->getSciencemeshShareHelper()->formatShare($share));
128-
} catch (QueryException $e) {
122+
} catch (ContainerExceptionInterface) {
129123
}
130124
}
131125

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

150-
$shares = array_merge($groupShares, $teamShares, $roomShares, $deckShares, $sciencemeshShares);
151-
152-
$shares = array_values(array_map(function (IShare $share) {
153-
return $this->formatShare($share);
154-
}, $shares));
143+
$shares = array_merge($groupShares, $teamShares, $roomShares, $deckShares);
144+
$shares = array_values(array_map(fn (IShare $share): array => $this->formatShare($share), $shares));
155145

156146
return new DataResponse($shares);
157147
}
@@ -170,7 +160,7 @@ public function index(): DataResponse {
170160
public function undelete(string $id): DataResponse {
171161
try {
172162
$share = $this->shareManager->getShareById($id, $this->userId);
173-
} catch (ShareNotFound $e) {
163+
} catch (ShareNotFound) {
174164
throw new OCSNotFoundException('Share not found');
175165
}
176166

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

204-
return Server::get('\OCA\Talk\Share\Helper\DeletedShareAPIController');
194+
/** @psalm-suppress UndefinedClass */
195+
return Server::get(\OCA\Talk\Share\Helper\DeletedShareAPIController::class);
205196
}
206197

207198
/**
@@ -210,31 +201,15 @@ private function getRoomShareHelper() {
210201
* If the Deck application is not enabled or the helper is not available
211202
* a QueryException is thrown instead.
212203
*
213-
* @return ShareAPIHelper
204+
* @psalm-suppress UndefinedClass
214205
* @throws QueryException
215206
*/
216-
private function getDeckShareHelper() {
207+
private function getDeckShareHelper(): \OCA\Deck\Sharing\ShareAPIHelper {
217208
if (!$this->appManager->isEnabledForUser('deck')) {
218209
throw new QueryException();
219210
}
220211

221-
return Server::get('\OCA\Deck\Sharing\ShareAPIHelper');
222-
}
223-
224-
/**
225-
* Returns the helper of DeletedShareAPIHelper for sciencemesh shares.
226-
*
227-
* If the sciencemesh application is not enabled or the helper is not available
228-
* a QueryException is thrown instead.
229-
*
230-
* @return ShareAPIHelper
231-
* @throws QueryException
232-
*/
233-
private function getSciencemeshShareHelper() {
234-
if (!$this->appManager->isEnabledForUser('sciencemesh')) {
235-
throw new QueryException();
236-
}
237-
238-
return Server::get('\OCA\ScienceMesh\Sharing\ShareAPIHelper');
212+
/** @psalm-suppress UndefinedClass */
213+
return Server::get(\OCA\Deck\Sharing\ShareAPIHelper::class);
239214
}
240215
}

apps/files_sharing/lib/Controller/ShareAPIController.php

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -331,16 +331,6 @@ protected function formatShare(IShare $share, ?Node $recipientNode = null): arra
331331
$result = array_merge($result, $deckShare);
332332
} catch (ContainerExceptionInterface $e) {
333333
}
334-
} elseif ($share->getShareType() === IShare::TYPE_SCIENCEMESH) {
335-
$result['share_with'] = $share->getSharedWith();
336-
$result['share_with_displayname'] = '';
337-
338-
try {
339-
/** @var array{share_with: string, share_with_displayname: string, token: string} $scienceMeshShare */
340-
$scienceMeshShare = $this->getSciencemeshShareHelper()->formatShare($share);
341-
$result = array_merge($result, $scienceMeshShare);
342-
} catch (ContainerExceptionInterface $e) {
343-
}
344334
}
345335

346336

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

871-
$shares = array_merge($userShares, $groupShares, $circleShares, $roomShares, $deckShares, $sciencemeshShares);
854+
$shares = array_merge($userShares, $groupShares, $circleShares, $roomShares, $deckShares);
872855

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

1582-
if ($share->getShareType() === IShare::TYPE_SCIENCEMESH) {
1583-
try {
1584-
return $this->getSciencemeshShareHelper()->canAccessShare($share, $this->userId);
1585-
} catch (ContainerExceptionInterface $e) {
1586-
return false;
1587-
}
1588-
}
1589-
15901565
return false;
15911566
}
15921567

@@ -1676,7 +1651,6 @@ protected function canDeleteShareFromSelf(IShare $share): bool {
16761651
if ($share->getShareType() !== IShare::TYPE_GROUP
16771652
&& $share->getShareType() !== IShare::TYPE_ROOM
16781653
&& $share->getShareType() !== IShare::TYPE_DECK
1679-
&& $share->getShareType() !== IShare::TYPE_SCIENCEMESH
16801654
) {
16811655
return false;
16821656
}
@@ -1713,14 +1687,6 @@ protected function canDeleteShareFromSelf(IShare $share): bool {
17131687
}
17141688
}
17151689

1716-
if ($share->getShareType() === IShare::TYPE_SCIENCEMESH) {
1717-
try {
1718-
return $this->getSciencemeshShareHelper()->canAccessShare($share, $this->userId);
1719-
} catch (ContainerExceptionInterface $e) {
1720-
return false;
1721-
}
1722-
}
1723-
17241690
return false;
17251691
}
17261692

@@ -1761,7 +1727,6 @@ private function getShareById(string $id): IShare {
17611727
'ocMailShare' => IShare::TYPE_EMAIL,
17621728
'ocRoomShare' => null,
17631729
'deck' => IShare::TYPE_DECK,
1764-
'sciencemesh' => IShare::TYPE_SCIENCEMESH,
17651730
];
17661731

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

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

2034-
// SCIENCEMESH SHARES
2035-
$sciencemeshShares = $this->shareManager->getSharesBy($this->userId, IShare::TYPE_SCIENCEMESH, $path, $reshares, -1, 0);
2036-
20371998
// FEDERATION
20381999
if ($this->shareManager->outgoingServer2ServerSharesAllowed()) {
20392000
$federatedShares = $this->shareManager->getSharesBy($this->userId, IShare::TYPE_REMOTE, $path, $reshares, -1, 0);
@@ -2046,7 +2007,7 @@ private function getAllShares(?Node $path = null, bool $reshares = false) {
20462007
$federatedGroupShares = [];
20472008
}
20482009

2049-
return array_merge($userShares, $groupShares, $linkShares, $mailShares, $circleShares, $roomShares, $deckShares, $sciencemeshShares, $federatedShares, $federatedGroupShares);
2010+
return array_merge($userShares, $groupShares, $linkShares, $mailShares, $circleShares, $roomShares, $deckShares, $federatedShares, $federatedGroupShares);
20502011
}
20512012

20522013

apps/files_sharing/lib/Controller/ShareesAPIController.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,6 @@ public function search(string $search = '', ?string $itemType = null, int $page
141141
if ($this->shareManager->shareProviderExists(IShare::TYPE_ROOM)) {
142142
$shareTypes[] = IShare::TYPE_ROOM;
143143
}
144-
145-
if ($this->shareManager->shareProviderExists(IShare::TYPE_SCIENCEMESH)) {
146-
$shareTypes[] = IShare::TYPE_SCIENCEMESH;
147-
}
148144
} else {
149145
if ($this->shareManager->allowGroupSharing()) {
150146
$shareTypes[] = IShare::TYPE_GROUP;
@@ -157,10 +153,6 @@ public function search(string $search = '', ?string $itemType = null, int $page
157153
$shareTypes[] = IShare::TYPE_CIRCLE;
158154
}
159155

160-
if ($this->shareManager->shareProviderExists(IShare::TYPE_SCIENCEMESH)) {
161-
$shareTypes[] = IShare::TYPE_SCIENCEMESH;
162-
}
163-
164156
if ($itemType === 'calendar') {
165157
$shareTypes[] = IShare::TYPE_REMOTE;
166158
}

apps/files_sharing/lib/MountProvider.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ public function getMountsForUser(IUser $user, IStorageFactory $loader) {
5757
$this->shareManager->getSharedWith($userId, IShare::TYPE_CIRCLE, null, -1),
5858
$this->shareManager->getSharedWith($userId, IShare::TYPE_ROOM, null, -1),
5959
$this->shareManager->getSharedWith($userId, IShare::TYPE_DECK, null, -1),
60-
$this->shareManager->getSharedWith($userId, IShare::TYPE_SCIENCEMESH, null, -1),
6160
);
6261

6362
$shares = $this->filterShares($shares, $userId);

apps/files_sharing/tests/Controller/ShareAPIControllerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,10 @@ public function testDeleteShareShareNotFound(): void {
217217
$this->expectExceptionMessage('Wrong share ID, share does not exist');
218218

219219
$this->shareManager
220-
->expects($this->exactly(7))
220+
->expects($this->exactly(6))
221221
->method('getShareById')
222222
->willReturnCallback(function ($id): void {
223-
if ($id === 'ocinternal:42' || $id === 'ocRoomShare:42' || $id === 'ocFederatedSharing:42' || $id === 'ocCircleShare:42' || $id === 'ocMailShare:42' || $id === 'deck:42' || $id === 'sciencemesh:42') {
223+
if ($id === 'ocinternal:42' || $id === 'ocRoomShare:42' || $id === 'ocFederatedSharing:42' || $id === 'ocCircleShare:42' || $id === 'ocMailShare:42' || $id === 'deck:42') {
224224
throw new ShareNotFound();
225225
} else {
226226
throw new \Exception();

0 commit comments

Comments
 (0)