API: Search endpoint

This commit is contained in:
Michael 2021-05-17 22:22:51 +00:00
parent 2364a1fb43
commit c9110e03e1
4 changed files with 200 additions and 6 deletions

View file

@ -44,13 +44,13 @@ class Search extends BaseApi
$uid = self::getCurrentUserID();
// What to search for
$q = (int)!isset($_REQUEST['q']) ? 0 : $_REQUEST['q'];
$q = $_REQUEST['q'] ?? '';
// Maximum number of results. Defaults to 40.
$limit = (int)!isset($_REQUEST['limit']) ? 40 : $_REQUEST['limit'];
$limit = (int)$_REQUEST['limit'] ?? 40;
// Attempt WebFinger lookup. Defaults to false. Use this when q is an exact address.
$resolve = (int)!isset($_REQUEST['resolve']) ? 0 : $_REQUEST['resolve'];
$resolve = (bool)!isset($_REQUEST['resolve']) ? false : ($_REQUEST['resolve'] == 'true');
// Only who the user is following. Defaults to false.
$following = (int)!isset($_REQUEST['following']) ? 0 : $_REQUEST['following'];
$following = (bool)!isset($_REQUEST['following']) ? false : ($_REQUEST['following'] == 'true');
$accounts = [];