Skip to content

Commit ef56f92

Browse files
committed
Update BookmarkController
1 parent 02b6df5 commit ef56f92

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Diff for: app/Http/Controllers/BookmarkController.php

+11
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Auth;
88
use Illuminate\Http\Request;
99
use App\Services\BookmarkService;
10+
use App\Services\FollowerService;
1011

1112
class BookmarkController extends Controller
1213
{
@@ -24,6 +25,16 @@ public function store(Request $request)
2425
$profile = Auth::user()->profile;
2526
$status = Status::findOrFail($request->input('item'));
2627

28+
abort_if(!in_array($status->scope, ['public', 'unlisted', 'private']), 404);
29+
30+
if($status->scope == 'private') {
31+
abort_if(
32+
$profile->id !== $status->profile_id && !FollowerService::follows($profile->id, $status->profile_id),
33+
404,
34+
'Error: Cannot bookmark private posts from accounts you do not follow.'
35+
);
36+
}
37+
2738
$bookmark = Bookmark::firstOrCreate(
2839
['status_id' => $status->id], ['profile_id' => $profile->id]
2940
);

0 commit comments

Comments
 (0)