mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-19 21:11:26 +00:00
Merge pull request #4103 from pixelfed/staging
Update BookmarkController
This commit is contained in:
commit
50f46a6aa2
1 changed files with 11 additions and 0 deletions
|
@ -7,6 +7,7 @@ use App\Status;
|
||||||
use Auth;
|
use Auth;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Services\BookmarkService;
|
use App\Services\BookmarkService;
|
||||||
|
use App\Services\FollowerService;
|
||||||
|
|
||||||
class BookmarkController extends Controller
|
class BookmarkController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -24,6 +25,16 @@ class BookmarkController extends Controller
|
||||||
$profile = Auth::user()->profile;
|
$profile = Auth::user()->profile;
|
||||||
$status = Status::findOrFail($request->input('item'));
|
$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(
|
$bookmark = Bookmark::firstOrCreate(
|
||||||
['status_id' => $status->id], ['profile_id' => $profile->id]
|
['status_id' => $status->id], ['profile_id' => $profile->id]
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue