From 69d36fc1c1f9a31068c41a80d21893b6c41228fe Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 6 Feb 2020 17:13:10 -0700 Subject: [PATCH] Update ApiV1Controller, add v2 search endpoint --- app/Http/Controllers/Api/ApiV1Controller.php | 31 +++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/ApiV1Controller.php b/app/Http/Controllers/Api/ApiV1Controller.php index 024427b8c..d093e9ef3 100644 --- a/app/Http/Controllers/Api/ApiV1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Controller.php @@ -44,7 +44,10 @@ use App\Jobs\VideoPipeline\{ VideoPostProcess, VideoThumbnail }; -use App\Services\NotificationService; +use App\Services\{ + NotificationService, + SearchApiV2Service +}; class ApiV1Controller extends Controller { @@ -1705,4 +1708,30 @@ class ApiV1Controller extends Controller $res = []; return response()->json($res); } + + /** + * GET /api/v2/search + * + * + * @return array + */ + public function searchV2(Request $request) + { + abort_if(!$request->user(), 403); + + $this->validate($request, [ + 'q' => 'required|string|min:1|max:80', + 'account_id' => 'nullable|string', + 'max_id' => 'nullable|string', + 'min_id' => 'nullable|string', + 'type' => 'nullable|in:accounts,hashtags,statuses', + 'exclude_unreviewed' => 'nullable', + 'resolve' => 'nullable', + 'limit' => 'nullable|integer|max:40', + 'offset' => 'nullable|integer', + 'following' => 'nullable|following' + ]); + + return SearchApiV2Service::query($request); + } } \ No newline at end of file