Browse Source

Update ApiV1Controller, add v2 search endpoint

Daniel Supernault 5 years ago
parent
commit
69d36fc1c1
1 changed files with 30 additions and 1 deletions
  1. 30 1
      app/Http/Controllers/Api/ApiV1Controller.php

+ 30 - 1
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);
+    }
 }