-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Add new share type for federated groups #34132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
smesterheide
wants to merge
4
commits into
nextcloud:master
from
smesterheide:vo-federation-features
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f2b5edf
Add new share type federated_group and provider for VO app
smesterheide a7e8a78
Add support for share type federated_group in files_sharing app
smesterheide 47eca65
Add share type support for federation providers
smesterheide 30425db
Add migration for share_external table
smesterheide File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| * @author Bjoern Schiessle <[email protected]> | ||
| * @author Christoph Wurst <[email protected]> | ||
| * @author Roeland Jago Douma <[email protected]> | ||
| * @author Sandro Mesterheide <[email protected]> | ||
| * | ||
| * @license GNU AGPL version 3 or any later version | ||
| * | ||
|
|
@@ -177,6 +178,10 @@ public function addShare($shareWith, $name, $description, $providerId, $owner, $ | |
| } | ||
| } | ||
|
|
||
| if ($shareType === 'federation') { | ||
| // Allow creation of pending shares by federation provider | ||
| } | ||
|
|
||
| // if no explicit display name is given, we use the uid as display name | ||
| $ownerDisplayName = $ownerDisplayName === null ? $owner : $ownerDisplayName; | ||
| $sharedByDisplayName = $sharedByDisplayName === null ? $sharedBy : $sharedByDisplayName; | ||
|
|
@@ -188,7 +193,7 @@ public function addShare($shareWith, $name, $description, $providerId, $owner, $ | |
| } | ||
|
|
||
| try { | ||
| $provider = $this->cloudFederationProviderManager->getCloudFederationProvider($resourceType); | ||
| $provider = $this->cloudFederationProviderManager->getCloudFederationProvider($resourceType, $shareType); | ||
| $share = $this->factory->getCloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, '', $shareType, $resourceType); | ||
| $share->setProtocol($protocol); | ||
| $provider->shareReceived($share); | ||
|
|
@@ -249,7 +254,7 @@ public function receiveNotification($notificationType, $resourceType, $providerI | |
| } | ||
|
|
||
| try { | ||
| $provider = $this->cloudFederationProviderManager->getCloudFederationProvider($resourceType); | ||
| $provider = $this->cloudFederationProviderManager->getCloudFederationProvider($resourceType, $notification['shareType']); | ||
| $result = $provider->notificationReceived($notificationType, $providerId, $notification); | ||
| } catch (ProviderDoesNotExistsException $e) { | ||
| return new JSONResponse( | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ | |
| * @author Richard Steinmetz <[email protected]> | ||
| * @author Robin Appelman <[email protected]> | ||
| * @author Roeland Jago Douma <[email protected]> | ||
| * @author Sandro Mesterheide <[email protected]> | ||
| * @author Valdnet <[email protected]> | ||
| * @author Vincent Petry <[email protected]> | ||
| * @author waleczny <[email protected]> | ||
|
|
@@ -320,7 +321,15 @@ protected function formatShare(IShare $share, Node $recipientNode = null): array | |
| $result = array_merge($result, $this->getDeckShareHelper()->formatShare($share)); | ||
| } catch (QueryException $e) { | ||
| } | ||
| } | ||
| } elseif ($share->getShareType() === IShare::TYPE_FEDERATED_GROUP) { | ||
| $group = $this->groupManager->get($share->getSharedWith()); | ||
| $result['share_with'] = $share->getSharedWith(); | ||
| $result['share_with_displayname'] = $group !== null ? $group->getDisplayName() : $share->getSharedWith(); | ||
| try { | ||
| $result = array_merge($result, $this->getFederatedGroupShareHelper()->formatShare($share)); | ||
| } catch (QueryException $e) { | ||
| } | ||
| } | ||
|
|
||
|
|
||
| $result['mail_send'] = $share->getMailSend() ? 1 : 0; | ||
|
|
@@ -648,7 +657,7 @@ public function createShare( | |
| throw new OCSNotFoundException($this->l->t('Invalid date, date format must be YYYY-MM-DD')); | ||
| } | ||
| } | ||
| } elseif ($shareType === IShare::TYPE_REMOTE_GROUP) { | ||
| } elseif ($shareType === IShare::TYPE_REMOTE_GROUP || $shareType === IShare::TYPE_FEDERATED_GROUP) { | ||
| if (!$this->shareManager->outgoingServer2ServerGroupSharesAllowed()) { | ||
| throw new OCSForbiddenException($this->l->t('Sharing %1$s failed because the back end does not allow shares from type %2$s', [$node->getPath(), $shareType])); | ||
| } | ||
|
|
@@ -1609,6 +1618,16 @@ private function getShareById(string $id): IShare { | |
| if (!$this->shareManager->outgoingServer2ServerSharesAllowed()) { | ||
| throw new ShareNotFound(); | ||
| } | ||
|
|
||
| try { | ||
| if ($this->shareManager->shareProviderExists(IShare::TYPE_FEDERATED_GROUP)) { | ||
| $share = $this->shareManager->getShareById('ocFederatedGroupShare:' . $id, $this->currentUser); | ||
| return $share; | ||
| } | ||
| } catch (ShareNotFound $e) { | ||
| // Do nothing, just try the other share type | ||
| } | ||
|
|
||
| $share = $this->shareManager->getShareById('ocFederatedSharing:' . $id, $this->currentUser); | ||
|
|
||
| return $share; | ||
|
|
@@ -1669,6 +1688,23 @@ private function getDeckShareHelper() { | |
| return $this->serverContainer->get('\OCA\Deck\Sharing\ShareAPIHelper'); | ||
| } | ||
|
|
||
| /** | ||
| * Returns the helper of ShareAPIHelper for federated group shares. | ||
| * | ||
| * If the VO federation application is not enabled or the helper is not available | ||
| * a QueryException is thrown instead. | ||
| * | ||
| * @return \OCA\VO_Federation\Sharing\ShareAPIHelper | ||
| * @throws QueryException | ||
| */ | ||
| private function getFederatedGroupShareHelper() { | ||
| if (!$this->appManager->isEnabledForUser('vo_federation')) { | ||
| throw new QueryException(); | ||
Check failureCode scanning / Psalm UndefinedDocblockClass
Docblock-defined class, interface or enum named OCA\VO_Federation\Sharing\ShareAPIHelper does not exist
|
||
| } | ||
|
|
||
| return $this->serverContainer->get('\OCA\VO_Federation\Sharing\ShareAPIHelper'); | ||
| } | ||
|
|
||
Check noticeCode scanning / Psalm DeprecatedClass
OCP\AppFramework\QueryException is marked deprecated
|
||
| /** | ||
| * @param string $viewer | ||
| * @param Node $node | ||
|
|
@@ -1710,6 +1746,12 @@ private function getSharesFromNode(string $viewer, $node, bool $reShares): array | |
| $federatedShares = $this->shareManager->getSharesBy( | ||
| $this->currentUser, IShare::TYPE_REMOTE_GROUP, $node, $reShares, -1, 0 | ||
| ); | ||
| if ($this->shareManager->shareProviderExists(IShare::TYPE_FEDERATED_GROUP)) { | ||
| $federatedGroupShares = $this->shareManager->getSharesBy( | ||
| $this->currentUser, IShare::TYPE_FEDERATED_GROUP, $node, $reShares, -1, 0 | ||
| ); | ||
| $federatedShares = array_merge($federatedShares, $federatedGroupShares); | ||
| } | ||
| $shares = array_merge($shares, $federatedShares); | ||
| } | ||
|
|
||
|
|
@@ -1840,18 +1882,18 @@ private function getAllShares(?Node $path = null, bool $reshares = false) { | |
| $deckShares = $this->shareManager->getSharesBy($this->currentUser, IShare::TYPE_DECK, $path, $reshares, -1, 0); | ||
|
|
||
| // FEDERATION | ||
| $federatedShares = []; | ||
| if ($this->shareManager->outgoingServer2ServerSharesAllowed()) { | ||
| $federatedShares = $this->shareManager->getSharesBy($this->currentUser, IShare::TYPE_REMOTE, $path, $reshares, -1, 0); | ||
| } else { | ||
| $federatedShares = []; | ||
| $remoteShares = $this->shareManager->getSharesBy($this->currentUser, IShare::TYPE_REMOTE, $path, $reshares, -1, 0); | ||
| $federatedShares = array_merge($federatedShares, $remoteShares); | ||
| } | ||
| if ($this->shareManager->outgoingServer2ServerGroupSharesAllowed()) { | ||
| $federatedGroupShares = $this->shareManager->getSharesBy($this->currentUser, IShare::TYPE_REMOTE_GROUP, $path, $reshares, -1, 0); | ||
| } else { | ||
| $federatedGroupShares = []; | ||
| $remoteGroupShares = $this->shareManager->getSharesBy($this->currentUser, IShare::TYPE_REMOTE_GROUP, $path, $reshares, -1, 0); | ||
| $federatedGroupShares = $this->shareManager->getSharesBy($this->currentUser, IShare::TYPE_FEDERATED_GROUP, $path, $reshares, -1, 0); | ||
| $federatedShares = array_merge($federatedShares, $remoteGroupShares, $federatedGroupShares); | ||
| } | ||
|
|
||
| return array_merge($userShares, $groupShares, $linkShares, $mailShares, $circleShares, $roomShares, $deckShares, $federatedShares, $federatedGroupShares); | ||
| return array_merge($userShares, $groupShares, $linkShares, $mailShares, $circleShares, $roomShares, $deckShares, $federatedShares); | ||
| } | ||
|
|
||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |
| * @author Morris Jobke <[email protected]> | ||
| * @author Robin Appelman <[email protected]> | ||
| * @author Roeland Jago Douma <[email protected]> | ||
| * @author Sandro Mesterheide <[email protected]> | ||
| * | ||
| * @license AGPL-3.0 | ||
| * | ||
|
|
@@ -82,6 +83,7 @@ class ShareesAPIController extends OCSController { | |
| 'groups' => [], | ||
| 'remotes' => [], | ||
| 'remote_groups' => [], | ||
| 'federated_groups' => [], | ||
| 'emails' => [], | ||
| 'circles' => [], | ||
| 'rooms' => [], | ||
|
|
@@ -91,6 +93,7 @@ class ShareesAPIController extends OCSController { | |
| 'groups' => [], | ||
| 'remotes' => [], | ||
| 'remote_groups' => [], | ||
| 'federated_groups' => [], | ||
| 'emails' => [], | ||
| 'lookup' => [], | ||
| 'circles' => [], | ||
|
|
@@ -178,6 +181,10 @@ public function search(string $search = '', string $itemType = null, int $page = | |
|
|
||
| if ($this->isRemoteGroupSharingAllowed($itemType)) { | ||
| $shareTypes[] = IShare::TYPE_REMOTE_GROUP; | ||
|
|
||
| if ($this->shareManager->shareProviderExists(IShare::TYPE_FEDERATED_GROUP)) { | ||
| $shareTypes[] = IShare::TYPE_FEDERATED_GROUP; | ||
| } | ||
| } | ||
|
|
||
| if ($this->shareManager->shareProviderExists(IShare::TYPE_EMAIL)) { | ||
|
|
@@ -284,6 +291,7 @@ private function sortShareesByFrequency(array $sharees): array { | |
| IShare::TYPE_GROUP => 'groups', | ||
| IShare::TYPE_REMOTE => 'remotes', | ||
| IShare::TYPE_REMOTE_GROUP => 'remote_groups', | ||
| IShare::TYPE_FEDERATED_GROUP => 'federated_groups', | ||
| IShare::TYPE_EMAIL => 'emails', | ||
| ]; | ||
|
|
||
|
|
@@ -356,6 +364,10 @@ public function findRecommended(string $itemType = null, $shareType = null): Dat | |
|
|
||
| if ($this->isRemoteGroupSharingAllowed($itemType)) { | ||
| $shareTypes[] = IShare::TYPE_REMOTE_GROUP; | ||
|
|
||
| if ($this->shareManager->shareProviderExists(IShare::TYPE_FEDERATED_GROUP)) { | ||
| $shareTypes[] = IShare::TYPE_FEDERATED_GROUP; | ||
| } | ||
| } | ||
|
|
||
| if ($this->shareManager->shareProviderExists(IShare::TYPE_EMAIL)) { | ||
|
|
||
72 changes: 72 additions & 0 deletions
72
apps/files_sharing/lib/Migration/Version26000Date20230117143027.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * @copyright Copyright (c) 2023 Sandro Mesterheide <[email protected]> | ||
| * | ||
| * @author Sandro Mesterheide <[email protected]> | ||
| * | ||
| * @license GNU AGPL version 3 or any later version | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Affero General Public License as | ||
| * published by the Free Software Foundation, either version 3 of the | ||
| * License, or (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU Affero General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Affero General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| * | ||
| */ | ||
|
|
||
| namespace OCA\Files_Sharing\Migration; | ||
|
|
||
| use Closure; | ||
| use OCP\DB\ISchemaWrapper; | ||
| use OCP\DB\Types; | ||
| use OCP\Migration\IOutput; | ||
| use OCP\Migration\SimpleMigrationStep; | ||
|
|
||
| /** | ||
| * Auto-generated migration step: Please modify to your needs! | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove the autocomment and instead add a line explaining what the migration do. |
||
| */ | ||
| class Version26000Date20230117143027 extends SimpleMigrationStep { | ||
| /** | ||
| * @param IOutput $output | ||
| * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` | ||
| * @param array $options | ||
| * @return null|ISchemaWrapper | ||
| */ | ||
| public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { | ||
| /** @var ISchemaWrapper $schema */ | ||
| $schema = $schemaClosure(); | ||
|
|
||
| $table = $schema->getTable('share_external'); | ||
| $changed = false; | ||
|
|
||
| $column = $table->getColumn('user'); | ||
| if ($column->getLength() < 255) { | ||
| $column->setLength(255); | ||
| $changed = true; | ||
| } | ||
|
|
||
| if (!$table->hasColumn('remote_share_type')) { | ||
| $table->addColumn('remote_share_type', Types::INTEGER, [ | ||
| 'notnull' => false, | ||
| 'length' => 4, | ||
| ]); | ||
| $changed = true; | ||
| } | ||
|
|
||
| if ($changed) { | ||
| return $schema; | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check failure
Code scanning / Psalm
UndefinedDocblockClass