Update api routes

This commit is contained in:
Daniel Supernault 2022-12-30 23:23:39 -07:00
parent 936f1e7a9b
commit b9154e3090
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
3 changed files with 12 additions and 2 deletions

View file

@ -2855,6 +2855,8 @@ class ApiV1Controller extends Controller
*/ */
public function timelineHashtag(Request $request, $hashtag) public function timelineHashtag(Request $request, $hashtag)
{ {
abort_if(!$request->user(), 403);
$this->validate($request,[ $this->validate($request,[
'page' => 'nullable|integer|max:40', 'page' => 'nullable|integer|max:40',
'min_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX, 'min_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
@ -2870,6 +2872,10 @@ class ApiV1Controller extends Controller
return response()->json([]); return response()->json([]);
} }
if($tag->is_banned == true) {
return $this->json([]);
}
$min = $request->input('min_id'); $min = $request->input('min_id');
$max = $request->input('max_id'); $max = $request->input('max_id');
$limit = $request->input('limit', 20); $limit = $request->input('limit', 20);

View file

@ -41,6 +41,7 @@ class DiscoverController extends Controller
$tag = Hashtag::whereName($hashtag) $tag = Hashtag::whereName($hashtag)
->orWhere('slug', $hashtag) ->orWhere('slug', $hashtag)
->where('is_banned', '!=', true)
->firstOrFail(); ->firstOrFail();
$tagCount = StatusHashtagService::count($tag->id); $tagCount = StatusHashtagService::count($tag->id);
return view('discover.tags.show', compact('tag', 'tagCount')); return view('discover.tags.show', compact('tag', 'tagCount'));
@ -53,7 +54,7 @@ class DiscoverController extends Controller
$this->validate($request, [ $this->validate($request, [
'hashtag' => 'required|string|min:1|max:124', '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'; $page = $request->input('page') ?? '1';
@ -61,6 +62,9 @@ class DiscoverController extends Controller
$tag = $request->input('hashtag'); $tag = $request->input('hashtag');
$hashtag = Hashtag::whereName($tag)->firstOrFail(); $hashtag = Hashtag::whereName($tag)->firstOrFail();
if($hashtag->is_banned == true) {
return [];
}
if($user) { if($user) {
$res['follows'] = HashtagService::isFollowing($user->profile_id, $hashtag->id); $res['follows'] = HashtagService::isFollowing($user->profile_id, $hashtag->id);
} }

View file

@ -81,7 +81,7 @@ Route::group(['prefix' => 'api'], function() use($middleware) {
Route::get('timelines/home', 'Api\ApiV1Controller@timelineHome')->middleware($middleware); Route::get('timelines/home', 'Api\ApiV1Controller@timelineHome')->middleware($middleware);
Route::get('timelines/public', 'Api\ApiV1Controller@timelinePublic')->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('discover/posts', 'Api\ApiV1Controller@discoverPosts')->middleware($middleware);
Route::get('preferences', 'Api\ApiV1Controller@getPreferences')->middleware($middleware); Route::get('preferences', 'Api\ApiV1Controller@getPreferences')->middleware($middleware);