Skip to content

Commit

Permalink
Merge pull request #18337 from nextcloud/backport/18189/stable17
Browse files Browse the repository at this point in the history
[stable17] Sharee API GS fixes
  • Loading branch information
rullzer authored Dec 11, 2019
2 parents 1241380 + 08c4b86 commit 624302d
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 3 deletions.
5 changes: 5 additions & 0 deletions apps/files_sharing/lib/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ public function getCapabilities() {
'expire_date' => ['enabled' => true]
];

// Sharee searches
$res['sharee'] = [
'query_lookup_default' => $this->config->getSystemValueBool('gs.enabled', false)
];

return [
'files_sharing' => $res,
];
Expand Down
9 changes: 8 additions & 1 deletion apps/files_sharing/lib/Controller/ShareesAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,21 @@ public function search(string $search = '', string $itemType = null, int $page =
$this->limit = (int) $perPage;
$this->offset = $perPage * ($page - 1);

// In global scale mode we always search the loogup server
if ($this->config->getSystemValueBool('gs.enabled', false)) {
$lookup = true;
$this->result['lookupEnabled'] = true;
} else {
$this->result['lookupEnabled'] = $this->config->getAppValue('files_sharing', 'lookupServerEnabled', 'yes') === 'yes';
}

list($result, $hasMoreResults) = $this->collaboratorSearch->search($search, $shareTypes, $lookup, $this->limit, $this->offset);

// extra treatment for 'exact' subarray, with a single merge expected keys might be lost
if(isset($result['exact'])) {
$result['exact'] = array_merge($this->result['exact'], $result['exact']);
}
$this->result = array_merge($this->result, $result);
$this->result['lookupEnabled'] = $this->config->getAppValue('files_sharing', 'lookupServerEnabled', 'yes') === 'yes';
$response = new DataResponse($this->result);

if ($hasMoreResults) {
Expand Down
2 changes: 1 addition & 1 deletion core/js/dist/share_backend.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/js/dist/share_backend.js.map

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions core/js/sharedialogview.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@
var deferred = $.Deferred();
var view = this;

// query lookup GS by default if enabled
var capabilities = OC.getCapabilities()
if (capabilities.files_sharing
&& capabilities.files_sharing.sharee
&& capabilities.files_sharing.sharee.query_lookup_default) {
this._lookup = true;
}

$.get(
OC.linkToOCS('apps/files_sharing/api/v1') + 'sharees',
{
Expand Down

0 comments on commit 624302d

Please sign in to comment.