diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_sharing/lib/Controller/ShareesAPIController.php | 44 | ||||
-rw-r--r-- | apps/lookup_server_connector/lib/UpdateLookupServer.php | 2 |
2 files changed, 41 insertions, 5 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareesAPIController.php b/apps/files_sharing/lib/Controller/ShareesAPIController.php index 09912b7758a..d9540aba1d9 100644 --- a/apps/files_sharing/lib/Controller/ShareesAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareesAPIController.php @@ -28,6 +28,7 @@ use OCP\AppFramework\Http; use OCP\AppFramework\OCS\OCSBadRequestException; use OCP\AppFramework\OCSController; use OCP\Contacts\IManager; +use OCP\Http\Client\IClientService; use OCP\IGroup; use OCP\IGroupManager; use OCP\ILogger; @@ -65,6 +66,9 @@ class ShareesAPIController extends OCSController { /** @var \OCP\Share\IManager */ protected $shareManager; + /** @var IClientService */ + protected $clientService; + /** @var bool */ protected $shareWithGroupOnly = false; @@ -89,6 +93,7 @@ class ShareesAPIController extends OCSController { 'groups' => [], 'remotes' => [], 'emails' => [], + 'lookup' => [], ]; protected $reachedEndFor = []; @@ -104,6 +109,7 @@ class ShareesAPIController extends OCSController { * @param IURLGenerator $urlGenerator * @param ILogger $logger * @param \OCP\Share\IManager $shareManager + * @param IClientService $clientService */ public function __construct($appName, IRequest $request, @@ -114,7 +120,8 @@ class ShareesAPIController extends OCSController { IUserSession $userSession, IURLGenerator $urlGenerator, ILogger $logger, - \OCP\Share\IManager $shareManager) { + \OCP\Share\IManager $shareManager, + IClientService $clientService) { parent::__construct($appName, $request); $this->groupManager = $groupManager; @@ -125,6 +132,7 @@ class ShareesAPIController extends OCSController { $this->urlGenerator = $urlGenerator; $this->logger = $logger; $this->shareManager = $shareManager; + $this->clientService = $clientService; } /** @@ -414,10 +422,11 @@ class ShareesAPIController extends OCSController { * @param int $page * @param int $perPage * @param int|int[] $shareType + * @param bool $lookup * @return Http\DataResponse * @throws OCSBadRequestException */ - public function search($search = '', $itemType = null, $page = 1, $perPage = 200, $shareType = null) { + public function search($search = '', $itemType = null, $page = 1, $perPage = 200, $shareType = null, $lookup = true) { if ($perPage <= 0) { throw new OCSBadRequestException('Invalid perPage argument'); } @@ -459,7 +468,7 @@ class ShareesAPIController extends OCSController { $this->limit = (int) $perPage; $this->offset = $perPage * ($page - 1); - return $this->searchSharees($search, $itemType, $shareTypes, $page, $perPage); + return $this->searchSharees($search, $itemType, $shareTypes, $page, $perPage, $lookup); } /** @@ -485,10 +494,11 @@ class ShareesAPIController extends OCSController { * @param array $shareTypes * @param int $page * @param int $perPage + * @param bool $lookup * @return Http\DataResponse * @throws OCSBadRequestException */ - protected function searchSharees($search, $itemType, array $shareTypes, $page, $perPage) { + protected function searchSharees($search, $itemType, array $shareTypes, $page, $perPage, $lookup) { // Verify arguments if ($itemType === null) { throw new OCSBadRequestException('Missing itemType'); @@ -510,11 +520,17 @@ class ShareesAPIController extends OCSController { $remoteResults = $this->getRemote($search); } + // Get emails $mailResults = ['results' => [], 'exact' => [], 'exactIdMatch' => false]; if (in_array(Share::SHARE_TYPE_EMAIL, $shareTypes)) { $mailResults = $this->getEmail($search); } + // Get from lookup server + if ($lookup) { + $this->getLookup($search); + } + // if we have a exact match, either for the federated cloud id or for the // email address we only return the exact match. It is highly unlikely // that the exact same email address and federated cloud id exists @@ -609,6 +625,26 @@ class ShareesAPIController extends OCSController { return $result; } + protected function getLookup($search) { + $client = $this->clientService->newClient(); + + $response = $client->get('http://127.0.0.1:3000/users?search='.urlencode($search)); + $body = json_decode($response->getBody(), true); + + $result = []; + foreach ($body as $lookup) { + $result[] = [ + 'label' => $lookup['federationId'], + 'value' => [ + 'shareType' => Share::SHARE_TYPE_REMOTE, + 'shareWith' => $lookup['federationId'], + ], + 'extra' => $lookup, + ]; + } + $this->result['lookup'] = $result; + } + /** * Generates a bunch of pagination links for the current page * diff --git a/apps/lookup_server_connector/lib/UpdateLookupServer.php b/apps/lookup_server_connector/lib/UpdateLookupServer.php index fc20ddcd143..abbc0e2b2d5 100644 --- a/apps/lookup_server_connector/lib/UpdateLookupServer.php +++ b/apps/lookup_server_connector/lib/UpdateLookupServer.php @@ -49,7 +49,7 @@ class UpdateLookupServer { /** @var Signer */ private $signer; /** @var string URL point to lookup server */ - private $lookupServer = 'http://192.168.176.105/lookup-server/server/'; + private $lookupServer = 'http://127.0.0.1:3000/index2.php/users'; /** * @param AccountManager $accountManager |