From 063558e3ace7dabe3998cf1152434878122e7eb3 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 28 Feb 2021 22:41:07 -0700 Subject: [PATCH] Update comment apis --- app/Http/Controllers/InternalApiController.php | 8 +++++--- app/Http/Controllers/PublicApiController.php | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/InternalApiController.php b/app/Http/Controllers/InternalApiController.php index 1a0af7d1..6766d944 100644 --- a/app/Http/Controllers/InternalApiController.php +++ b/app/Http/Controllers/InternalApiController.php @@ -132,13 +132,15 @@ class InternalApiController extends Controller public function statusReplies(Request $request, int $id) { + $this->validate($request, [ + 'limit' => 'nullable|int|min:1|max:6' + ]); $parent = Status::whereScope('public')->findOrFail($id); - + $limit = $request->input('limit') ?? 3; $children = Status::whereInReplyToId($parent->id) ->orderBy('created_at', 'desc') - ->take(3) + ->take($limit) ->get(); - $resource = new Fractal\Resource\Collection($children, new StatusTransformer()); $res = $this->fractal->createData($resource)->toArray(); diff --git a/app/Http/Controllers/PublicApiController.php b/app/Http/Controllers/PublicApiController.php index 1402940e..c1e8ef9f 100644 --- a/app/Http/Controllers/PublicApiController.php +++ b/app/Http/Controllers/PublicApiController.php @@ -166,7 +166,7 @@ class PublicApiController extends Controller ->whereNull('reblog_of_id') ->whereIn('scope', $scope) ->whereNotIn('profile_id', $filtered) - ->select('id', 'caption', 'is_nsfw', 'rendered', 'profile_id', 'in_reply_to_id', 'type', 'reply_count', 'created_at') + ->select('id', 'caption', 'local', 'is_nsfw', 'rendered', 'profile_id', 'in_reply_to_id', 'type', 'reply_count', 'created_at') ->where('id', '>=', $request->min_id) ->orderBy('id', 'desc') ->paginate($limit); @@ -176,7 +176,7 @@ class PublicApiController extends Controller ->whereNull('reblog_of_id') ->whereIn('scope', $scope) ->whereNotIn('profile_id', $filtered) - ->select('id', 'caption', 'is_nsfw', 'rendered', 'profile_id', 'in_reply_to_id', 'type', 'reply_count', 'created_at') + ->select('id', 'caption', 'local', 'is_nsfw', 'rendered', 'profile_id', 'in_reply_to_id', 'type', 'reply_count', 'created_at') ->where('id', '<=', $request->max_id) ->orderBy('id', 'desc') ->paginate($limit); @@ -186,7 +186,7 @@ class PublicApiController extends Controller ->whereNull('reblog_of_id') ->whereIn('scope', $scope) ->whereNotIn('profile_id', $filtered) - ->select('id', 'caption', 'is_nsfw', 'rendered', 'profile_id', 'in_reply_to_id', 'type', 'reply_count', 'created_at') + ->select('id', 'caption', 'local', 'is_nsfw', 'rendered', 'profile_id', 'in_reply_to_id', 'type', 'reply_count', 'created_at') ->orderBy('id', 'desc') ->paginate($limit); }