diff --git a/apps/files_sharing/lib/Controller/ShareesController.php b/apps/files_sharing/lib/Controller/ShareesController.php index d907c5f7a371..63ea141f7274 100644 --- a/apps/files_sharing/lib/Controller/ShareesController.php +++ b/apps/files_sharing/lib/Controller/ShareesController.php @@ -41,6 +41,7 @@ use OCP\IUserManager; use OCP\IUserSession; use OCP\Share; +use OCA\Files_Sharing\AppInfo\Application; use OCA\Files_Sharing\SharingBlacklist; use OCP\Util\UserSearch; @@ -381,6 +382,18 @@ protected function getGroups($search) { * @return void */ protected function getRemote($search) { + $pluginClass = $this->config->getSystemValue('sharing.remoteShareesSearch'); + if ($pluginClass !== '') { + $this->result['remotes'] = []; + $app = new Application(); + $container = $app->getContainer(); + /** @var \OCP\Share\IRemoteShareesSearch $plugin */ + $plugin = $container->query($pluginClass); + $result = $plugin->search($search); + $this->result['exact']['remotes'] = $result; + $this->reachedEndFor[] = 'remotes'; + return; + } $this->result['remotes'] = []; // Fetch remote search properties from app config /** diff --git a/apps/files_sharing/tests/API/ShareesTest.php b/apps/files_sharing/tests/API/ShareesTest.php index 364a5401ba6a..dd869cbfa1dd 100644 --- a/apps/files_sharing/tests/API/ShareesTest.php +++ b/apps/files_sharing/tests/API/ShareesTest.php @@ -1513,7 +1513,8 @@ public function testGetRemote($searchTerm, $contacts, $shareeEnumeration, $exact $configMap = [ ['trusted_domains', [], ['trusted.domain.tld', 'trusted2.domain.tld']], - ['accounts.enable_medial_search', true, true] + ['accounts.enable_medial_search', true, true], + ['sharing.remoteShareesSearch', '', ''] ]; $this->config->expects($this->any()) diff --git a/changelog/unreleased/40577 b/changelog/unreleased/40577 new file mode 100644 index 000000000000..02ebc8dcb44e --- /dev/null +++ b/changelog/unreleased/40577 @@ -0,0 +1,10 @@ +Enhancement: Add support for OCM via ScienceMesh + + +We've added an if-statement in the files_sharing ShareesController +code that searches for remote sharees. When the 'sciencemesh' app +is installed, use it instead of the federatedfilesharing app to +find sharee matches for OCM sharing. + +https://github.com/owncloud/core/issues/40577 +https://github.com/pondersource/oc-sciencemesh/pull/39 \ No newline at end of file diff --git a/lib/public/Share/IRemoteShareesSearch.php b/lib/public/Share/IRemoteShareesSearch.php new file mode 100644 index 000000000000..0f3ce75d97e1 --- /dev/null +++ b/lib/public/Share/IRemoteShareesSearch.php @@ -0,0 +1,49 @@ + + * + * @copyright Copyright (c) 2018, ownCloud GmbH + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * 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, version 3, + * along with this program. If not, see + * + */ + +namespace OCP\Share; + +/** + * Interface IRemoteShareesSearch + * Used in the ShareesController of the files_sharing app. + * See the 'sciencemesh' app for an example implementation + * of this interface. + * + * @package OCP\Share + * @since 10.12.0 + */ +interface IRemoteShareesSearch { + /** + * Return the identifier of this provider. + * @param string search string for autocomplete + * @return array[] this function should return an array + * where each element is an associative array, containing: + * - label: a string to display as label + * - value: an associative array containing: + * - shareType: int, to be used as share type + * - shareWith: string, identifying the sharee + * - server (optional): string, URL of the server, e.g. + * https://github.com/owncloud/core/blob/v10.12.0-beta.1/apps/files_sharing/lib/Controller/ShareesController.php#L421 + * + * @since 10.12.0 + */ + public function search($search); +}