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)
{
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);

View File

@ -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);
}

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/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);