diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2017-02-21 18:10:38 +0100 |
---|---|---|
committer | Bjoern Schiessle <bjoern@schiessle.org> | 2017-02-21 18:31:20 +0100 |
commit | 869ea38ffe77e92b9a5651fe07020b4035d1f1d3 (patch) | |
tree | a36225e8e1a858478a6f615277865f14f42ac1c5 /apps/files_sharing/lib/Controller/ShareesAPIController.php | |
parent | 0453a7dabd031cacd43843660d921f7a861f4eef (diff) | |
download | nextcloud-server-869ea38ffe77e92b9a5651fe07020b4035d1f1d3.tar.gz nextcloud-server-869ea38ffe77e92b9a5651fe07020b4035d1f1d3.zip |
allow to configure a min-length of search strings for auto-compeltion and a max number for of results returned
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'apps/files_sharing/lib/Controller/ShareesAPIController.php')
-rw-r--r-- | apps/files_sharing/lib/Controller/ShareesAPIController.php | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareesAPIController.php b/apps/files_sharing/lib/Controller/ShareesAPIController.php index 40a9b272bc8..171fac4dbd2 100644 --- a/apps/files_sharing/lib/Controller/ShareesAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareesAPIController.php @@ -413,6 +413,18 @@ class ShareesAPIController extends OCSController { * @throws OCSBadRequestException */ public function search($search = '', $itemType = null, $page = 1, $perPage = 200, $shareType = null, $lookup = true) { + + // only search for string larger than a given threshold + $threshold = $this->config->getSystemValue('sharing.minSearchStringLength', 0); + if (strlen($search) < $threshold) { + return new Http\DataResponse($this->result); + } + + // never return more than the max. number of results configured in the config.php + $maxResults = $this->config->getSystemValue('sharing.maxAutocompleteResults', 0); + if ($maxResults > 0) { + $perPage = min($perPage, $maxResults); + } if ($perPage <= 0) { throw new OCSBadRequestException('Invalid perPage argument'); } |