From b9154e309016744f072f10c95c0529fc792bfb9f Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 30 Dec 2022 23:23:39 -0700 Subject: [PATCH] Update api routes --- app/Http/Controllers/Api/ApiV1Controller.php | 6 ++++++ app/Http/Controllers/DiscoverController.php | 6 +++++- routes/api.php | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Api/ApiV1Controller.php b/app/Http/Controllers/Api/ApiV1Controller.php index 8b18efb77..11ab3a01b 100644 --- a/app/Http/Controllers/Api/ApiV1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Controller.php @@ -2855,6 +2855,8 @@ class ApiV1Controller extends Controller */ public function timelineHashtag(Request $request, $hashtag) { + abort_if(!$request->user(), 403); + $this->validate($request,[ 'page' => 'nullable|integer|max:40', 'min_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX, @@ -2870,6 +2872,10 @@ class ApiV1Controller extends Controller return response()->json([]); } + if($tag->is_banned == true) { + return $this->json([]); + } + $min = $request->input('min_id'); $max = $request->input('max_id'); $limit = $request->input('limit', 20); diff --git a/app/Http/Controllers/DiscoverController.php b/app/Http/Controllers/DiscoverController.php index dd2b00bcf..3dab2b40b 100644 --- a/app/Http/Controllers/DiscoverController.php +++ b/app/Http/Controllers/DiscoverController.php @@ -41,6 +41,7 @@ class DiscoverController extends Controller $tag = Hashtag::whereName($hashtag) ->orWhere('slug', $hashtag) + ->where('is_banned', '!=', true) ->firstOrFail(); $tagCount = StatusHashtagService::count($tag->id); return view('discover.tags.show', compact('tag', 'tagCount')); @@ -53,7 +54,7 @@ class DiscoverController extends Controller $this->validate($request, [ 'hashtag' => 'required|string|min:1|max:124', - 'page' => 'nullable|integer|min:1|max:' . ($user ? 29 : 10) + 'page' => 'nullable|integer|min:1|max:' . ($user ? 29 : 3) ]); $page = $request->input('page') ?? '1'; @@ -61,6 +62,9 @@ class DiscoverController extends Controller $tag = $request->input('hashtag'); $hashtag = Hashtag::whereName($tag)->firstOrFail(); + if($hashtag->is_banned == true) { + return []; + } if($user) { $res['follows'] = HashtagService::isFollowing($user->profile_id, $hashtag->id); } diff --git a/routes/api.php b/routes/api.php index f1051a33e..3d4df4c54 100644 --- a/routes/api.php +++ b/routes/api.php @@ -81,7 +81,7 @@ Route::group(['prefix' => 'api'], function() use($middleware) { Route::get('timelines/home', 'Api\ApiV1Controller@timelineHome')->middleware($middleware); Route::get('timelines/public', 'Api\ApiV1Controller@timelinePublic')->middleware($middleware); - Route::get('timelines/tag/{hashtag}', 'Api\ApiV1Controller@timelineHashtag'); + Route::get('timelines/tag/{hashtag}', 'Api\ApiV1Controller@timelineHashtag')->middleware($middleware); Route::get('discover/posts', 'Api\ApiV1Controller@discoverPosts')->middleware($middleware); Route::get('preferences', 'Api\ApiV1Controller@getPreferences')->middleware($middleware);