Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update BookmarkController
  • Loading branch information
dansup committed Jan 19, 2023
1 parent 02b6df5 commit ef56f92
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/Http/Controllers/BookmarkController.php
Expand Up @@ -7,6 +7,7 @@
use Auth;
use Illuminate\Http\Request;
use App\Services\BookmarkService;
use App\Services\FollowerService;

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

abort_if(!in_array($status->scope, ['public', 'unlisted', 'private']), 404);

if($status->scope == 'private') {
abort_if(
$profile->id !== $status->profile_id && !FollowerService::follows($profile->id, $status->profile_id),
404,
'Error: Cannot bookmark private posts from accounts you do not follow.'
);
}

$bookmark = Bookmark::firstOrCreate(
['status_id' => $status->id], ['profile_id' => $profile->id]
);
Expand Down

0 comments on commit ef56f92

Please sign in to comment.