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>
This commit is contained in:
parent
0b8deebb4f
commit
a5f0f3f4f6
|
@ -427,6 +427,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');
|
||||
}
|
||||
|
|
|
@ -1064,6 +1064,17 @@ $CONFIG = array(
|
|||
*/
|
||||
'sharing.managerFactory' => '\OC\Share20\ProviderFactory',
|
||||
|
||||
/**
|
||||
* Define max number of results returned by the user search for auto-completion
|
||||
* Default is unlimited (value set to 0).
|
||||
*/
|
||||
'sharing.maxAutocompleteResults' => 0,
|
||||
|
||||
/**
|
||||
* Define the minimum length of the search string before we start auto-completion
|
||||
* Default is no limit (value set to 0)
|
||||
*/
|
||||
'sharing.minSearchStringLength' => 0,
|
||||
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue