Skip to content

Commit

Permalink
OCM via ScienceMesh
Browse files Browse the repository at this point in the history
Signed-off-by: Michiel de Jong <[email protected]>
  • Loading branch information
michielbdejong committed Jan 24, 2023
1 parent dba4cf1 commit 6c448ed
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 1 deletion.
13 changes: 13 additions & 0 deletions apps/files_sharing/lib/Controller/ShareesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
/**
Expand Down
3 changes: 2 additions & 1 deletion apps/files_sharing/tests/API/ShareesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
10 changes: 10 additions & 0 deletions changelog/unreleased/40577
Original file line number Diff line number Diff line change
@@ -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
49 changes: 49 additions & 0 deletions lib/public/Share/IRemoteShareesSearch.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
/**
* @author Michiel de Jong <[email protected]>
*
* @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 <http://www.gnu.org/licenses/>
*
*/

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);
}

0 comments on commit 6c448ed

Please sign in to comment.