summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorBjörn Schießle <bjoern@schiessle.org>2017-02-22 16:30:21 +0100
committerGitHub <noreply@github.com>2017-02-22 16:30:21 +0100
commit621f920d682c78b12b8a57abcf0d4af09a11757b (patch)
treed21a39b2edec56b32088755eb41ce17305ab353f /apps
parenta2e16fd5bada32559fca9450b4b635d7c0708668 (diff)
parent11e5a3dcf4767149a3f7e14deb8e684bb6500276 (diff)
downloadnextcloud-server-621f920d682c78b12b8a57abcf0d4af09a11757b.tar.gz
nextcloud-server-621f920d682c78b12b8a57abcf0d4af09a11757b.zip
Merge pull request #3567 from nextcloud/autocomplete-settings
some sharing settings
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/lib/Controller/ShareesAPIController.php20
1 files changed, 16 insertions, 4 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareesAPIController.php b/apps/files_sharing/lib/Controller/ShareesAPIController.php
index 40a9b272bc8..e4b5b0ce19c 100644
--- a/apps/files_sharing/lib/Controller/ShareesAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareesAPIController.php
@@ -24,7 +24,7 @@
*/
namespace OCA\Files_Sharing\Controller;
-use OCP\AppFramework\Http;
+use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCS\OCSBadRequestException;
use OCP\AppFramework\OCSController;
use OCP\Contacts\IManager;
@@ -409,10 +409,22 @@ class ShareesAPIController extends OCSController {
* @param int $perPage
* @param int|int[] $shareType
* @param bool $lookup
- * @return Http\DataResponse
+ * @return DataResponse
* @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 = (int)$this->config->getSystemValue('sharing.minSearchStringLength', 0);
+ if (strlen($search) < $threshold) {
+ return new DataResponse($this->result);
+ }
+
+ // never return more than the max. number of results configured in the config.php
+ $maxResults = (int)$this->config->getSystemValue('sharing.maxAutocompleteResults', 0);
+ if ($maxResults > 0) {
+ $perPage = min($perPage, $maxResults);
+ }
if ($perPage <= 0) {
throw new OCSBadRequestException('Invalid perPage argument');
}
@@ -481,7 +493,7 @@ class ShareesAPIController extends OCSController {
* @param int $page
* @param int $perPage
* @param bool $lookup
- * @return Http\DataResponse
+ * @return DataResponse
* @throws OCSBadRequestException
*/
protected function searchSharees($search, $itemType, array $shareTypes, $page, $perPage, $lookup) {
@@ -533,7 +545,7 @@ class ShareesAPIController extends OCSController {
$this->result['exact']['emails'] = $mailResults['exact'];
}
- $response = new Http\DataResponse($this->result);
+ $response = new DataResponse($this->result);
if (sizeof($this->reachedEndFor) < 3) {
$response->addHeader('Link', $this->getPaginationLink($page, [