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
11 changes: 9 additions & 2 deletions apps/cloud_federation_api/lib/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,15 @@ public function __construct(
*/
public function getSupportedShareTypes($resourceType) {
try {
$provider = $this->cloudFederationProviderManager->getCloudFederationProvider($resourceType);
return $provider->getSupportedShareTypes();
$supportedShareTypes = [];
$cloudFederationProviders = $this->cloudFederationProviderManager->getAllCloudFederationProviders();
foreach ($cloudFederationProviders as $providerWrapper) {
if ($providerWrapper['resourceType'] === $resourceType) {
$providerSupportedShareTypes = $providerWrapper['provider']->getSupportedShareTypes();
$supportedShareTypes = array_merge($supportedShareTypes, $providerSupportedShareTypes);
}
}
return array_unique($supportedShareTypes);
} catch (\Exception $e) {
$this->logger->error('Failed to create federation provider', ['exception' => $e]);
return [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ public function addShare($shareWith, $name, $description, $providerId, $owner, $
}
}

if ($shareType === 'federation') {
// Allow creation of pending shares by federation provider
}
Comment on lines +171 to +173
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?


// if no explicit display name is given, we use the uid as display name
$ownerDisplayName = $ownerDisplayName === null ? $owner : $ownerDisplayName;
$sharedByDisplayName = $sharedByDisplayName === null ? $sharedBy : $sharedByDisplayName;
Expand All @@ -179,7 +183,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);
Expand Down Expand Up @@ -258,7 +262,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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
'OCA\\Files_Sharing\\Migration\\Version22000Date20210216084241' => $baseDir . '/../lib/Migration/Version22000Date20210216084241.php',
'OCA\\Files_Sharing\\Migration\\Version24000Date20220208195521' => $baseDir . '/../lib/Migration/Version24000Date20220208195521.php',
'OCA\\Files_Sharing\\Migration\\Version24000Date20220404142216' => $baseDir . '/../lib/Migration/Version24000Date20220404142216.php',
'OCA\\Files_Sharing\\Migration\\Version26000Date20230117143027' => $baseDir . '/../lib/Migration/Version32000Date20230117143027.php',
'OCA\\Files_Sharing\\Migration\\Version31000Date20240821142813' => $baseDir . '/../lib/Migration/Version31000Date20240821142813.php',
'OCA\\Files_Sharing\\MountProvider' => $baseDir . '/../lib/MountProvider.php',
'OCA\\Files_Sharing\\Notification\\Listener' => $baseDir . '/../lib/Notification/Listener.php',
Expand Down
1 change: 1 addition & 0 deletions apps/files_sharing/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class ComposerStaticInitFiles_Sharing
'OCA\\Files_Sharing\\Migration\\Version22000Date20210216084241' => __DIR__ . '/..' . '/../lib/Migration/Version22000Date20210216084241.php',
'OCA\\Files_Sharing\\Migration\\Version24000Date20220208195521' => __DIR__ . '/..' . '/../lib/Migration/Version24000Date20220208195521.php',
'OCA\\Files_Sharing\\Migration\\Version24000Date20220404142216' => __DIR__ . '/..' . '/../lib/Migration/Version24000Date20220404142216.php',
'OCA\\Files_Sharing\\Migration\\Version26000Date20230117143027' => __DIR__ . '/..' . '/../lib/Migration/Version32000Date20230117143027.php',
'OCA\\Files_Sharing\\Migration\\Version31000Date20240821142813' => __DIR__ . '/..' . '/../lib/Migration/Version31000Date20240821142813.php',
'OCA\\Files_Sharing\\MountProvider' => __DIR__ . '/..' . '/../lib/MountProvider.php',
'OCA\\Files_Sharing\\Notification\\Listener' => __DIR__ . '/..' . '/../lib/Notification/Listener.php',
Expand Down
64 changes: 59 additions & 5 deletions apps/files_sharing/lib/Controller/ShareAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function __construct(
*
* @param IShare $share
* @param Node|null $recipientNode
* @return Files_SharingShare
* @return array
* @throws NotFoundException In case the node can't be resolved.
*
* @suppress PhanUndeclaredClassMethod
Expand Down Expand Up @@ -305,6 +305,14 @@ protected function formatShare(IShare $share, ?Node $recipientNode = null): arra
$result = array_merge($result, $scienceMeshShare);
} catch (ContainerExceptionInterface $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) {
}
}


Expand Down Expand Up @@ -746,6 +754,15 @@ public function createShare(
$share->setPermissions($permissions);
$share->setSharedWithDisplayName($this->getCachedFederatedDisplayName($shareWith, false));
} elseif ($shareType === IShare::TYPE_REMOTE_GROUP) {
if ($expireDate !== '') {
try {
$expireDate = $this->parseDate($expireDate);
$share->setExpirationDate($expireDate);
} catch (\Exception $e) {
throw new OCSNotFoundException($this->l->t('Invalid date, date format must be YYYY-MM-DD'));
}
}
} elseif ($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]));
}
Expand Down Expand Up @@ -1771,6 +1788,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->userId);
return $share;
}
} catch (ShareNotFound $e) {
// Do nothing, just try the other share type
}

$share = $this->shareManager->getShareById('ocFederatedSharing:' . $id, $this->userId);

return $share;
Expand Down Expand Up @@ -1848,6 +1875,25 @@ private function getSciencemeshShareHelper() {
return $this->serverContainer->get('\OCA\ScienceMesh\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 ContainerExceptionInterface
* @throws QueryException
* @throws \Psr\Container\NotFoundExceptionInterface
*/
private function getFederatedGroupShareHelper() {
if (!$this->appManager->isEnabledForUser('vo_federation')) {
throw new QueryException();
}

return $this->serverContainer->get('\OCA\VO_Federation\Sharing\ShareAPIHelper');
}

/**
* @param string $viewer
* @param Node $node
Expand Down Expand Up @@ -1890,6 +1936,12 @@ private function getSharesFromNode(string $viewer, $node, bool $reShares): array
$federatedShares = $this->shareManager->getSharesBy(
$this->userId, IShare::TYPE_REMOTE_GROUP, $node, $reShares, -1, 0
);
if ($this->shareManager->shareProviderExists(IShare::TYPE_FEDERATED_GROUP)) {
$federatedGroupShares = $this->shareManager->getSharesBy(
$this->userId, IShare::TYPE_FEDERATED_GROUP, $node, $reShares, -1, 0
);
$federatedShares = array_merge($federatedShares, $federatedGroupShares);
}
$shares = array_merge($shares, $federatedShares);
}

Expand Down Expand Up @@ -2025,17 +2077,19 @@ private function getAllShares(?Node $path = null, bool $reshares = false) {

// FEDERATION
if ($this->shareManager->outgoingServer2ServerSharesAllowed()) {
$federatedShares = $this->shareManager->getSharesBy($this->userId, IShare::TYPE_REMOTE, $path, $reshares, -1, 0);
$remoteShares = $this->shareManager->getSharesBy($this->userId, IShare::TYPE_REMOTE, $path, $reshares, -1, 0);
} else {
$federatedShares = [];
$remoteShares = [];
}
if ($this->shareManager->outgoingServer2ServerGroupSharesAllowed()) {
$federatedGroupShares = $this->shareManager->getSharesBy($this->userId, IShare::TYPE_REMOTE_GROUP, $path, $reshares, -1, 0);
$remoteGroupShares = $this->shareManager->getSharesBy($this->userId, IShare::TYPE_REMOTE_GROUP, $path, $reshares, -1, 0);
$federatedGroupShares = $this->shareManager->getSharesBy($this->userId, IShare::TYPE_FEDERATED_GROUP, $path, $reshares, -1, 0);
} else {
$remoteGroupShares = [];
$federatedGroupShares = [];
}

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


Expand Down
11 changes: 11 additions & 0 deletions apps/files_sharing/lib/Controller/ShareesAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class ShareesAPIController extends OCSController {
'groups' => [],
'remotes' => [],
'remote_groups' => [],
'federated_groups' => [],
'emails' => [],
'circles' => [],
'rooms' => [],
Expand All @@ -60,6 +61,7 @@ class ShareesAPIController extends OCSController {
'groups' => [],
'remotes' => [],
'remote_groups' => [],
'federated_groups' => [],
'emails' => [],
'lookup' => [],
'circles' => [],
Expand Down Expand Up @@ -137,6 +139,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)) {
Expand Down Expand Up @@ -239,6 +245,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',
];

Expand Down Expand Up @@ -312,6 +319,10 @@ public function findRecommended(string $itemType, $shareType = null): DataRespon

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)) {
Expand Down
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!
*/
class Version32000Date20230117143027 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;
}
Comment on lines +58 to +64
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The table already has a column share_type


if ($changed) {
return $schema;
}

return null;
}
}
2 changes: 2 additions & 0 deletions apps/files_sharing/src/components/SharingEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ export default {
title += ` (${t('files_sharing', 'remote group')})`
} else if (this.share.type === ShareType.Guest) {
title += ` (${t('files_sharing', 'guest')})`
} else if (this.share.type === this.SHARE_TYPES.SHARE_TYPE_FEDERATED_GROUP) {
title += ` (${t('files_sharing', 'federated group')})`
}
if (!this.isShareOwner && this.share.ownerDisplayName) {
title += ' ' + t('files_sharing', 'by {initiator}', {
Expand Down
7 changes: 6 additions & 1 deletion apps/files_sharing/src/components/SharingInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export default {

let shareType = []

const remoteTypes = [ShareType.Remote, ShareType.RemoteGroup]
const remoteTypes = [ShareType.Remote, ShareType.RemoteGroup, ShareType.FederatedGroup]

if (this.isExternal && !this.config.showFederatedSharesAsInternal) {
shareType.push(...remoteTypes)
Expand Down Expand Up @@ -443,6 +443,11 @@ export default {
icon: 'icon-sciencemesh',
iconTitle: t('files_sharing', 'ScienceMesh'),
}
case this.SHARE_TYPES.SHARE_TYPE_FEDERATED_GROUP:
return {
icon: 'icon-organization',
iconTitle: t('files_sharing', 'Virtual organization'),
}
default:
return {}
}
Expand Down
16 changes: 16 additions & 0 deletions core/img/actions/organization.svg
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be an outlined icon as per our new icon guidelines

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions core/src/icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const icons = {
'menu': path.join(__dirname, '../img', 'actions', 'menu.svg'),
'more': path.join(__dirname, '../img', 'actions', 'more.svg'),
'music': path.join(__dirname, '../img', 'places', 'music.svg'),
'organization': path.join(__dirname, '../img', 'actions', 'organization.svg'),
'password': path.join(__dirname, '../img', 'actions', 'password.svg'),
'pause': path.join(__dirname, '../img', 'actions', 'pause.svg'),
'phone': path.join(__dirname, '../img', 'clients', 'phone.svg'),
Expand Down
Loading