Skip to content

Commit 0cd5784

Browse files
committed
Update ForYouFeedController
1 parent 403d349 commit 0cd5784

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

app/Http/Controllers/Api/ForYouFeedController.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Http\Controllers\Api;
44

5+
use App\Http\Controllers\Api\Traits\ApiHelpers;
56
use App\Http\Controllers\Controller;
67
use App\Models\FeedFeedback;
78
use App\Models\Video;
@@ -12,6 +13,8 @@
1213

1314
class ForYouFeedController extends Controller
1415
{
16+
use ApiHelpers;
17+
1518
public function __construct(
1619
private ForYouFeedService $feedService
1720
) {
@@ -21,6 +24,11 @@ public function __construct(
2124
public function index(Request $request): JsonResponse
2225
{
2326
abort_unless(app(ConfigService::class)->forYouFeed(), 404);
27+
28+
if ($request->user()->cannot('viewAny', [Video::class])) {
29+
return $this->error('Please finish setting up your account', 403);
30+
}
31+
2432
$profile = $request->user()->profile;
2533
$cursor = $request->input('cursor');
2634
$limit = min((int) $request->input('limit', 20), 50);
@@ -39,6 +47,10 @@ public function recordImpression(Request $request): JsonResponse
3947
'completed' => 'boolean',
4048
]);
4149

50+
if ($request->user()->cannot('viewAny', [Video::class])) {
51+
return $this->error('Please finish setting up your account', 403);
52+
}
53+
4254
$profile = $request->user()->profile;
4355

4456
if ($validated['completed']) {
@@ -67,6 +79,10 @@ public function recordFeedback(Request $request): JsonResponse
6779
],
6880
]);
6981

82+
if ($request->user()->cannot('viewAny', [Video::class])) {
83+
return $this->error('Please finish setting up your account', 403);
84+
}
85+
7086
$profile = $request->user()->profile;
7187

7288
$this->feedService->recordFeedback(

0 commit comments

Comments
 (0)