mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-20 20:13:17 +00:00
Merge pull request #849 from pixelfed/frontend-ui-refactor
Update PublicApiController
This commit is contained in:
commit
1fda4c8386
1 changed files with 14 additions and 6 deletions
|
@ -174,12 +174,13 @@ class PublicApiController extends Controller
|
||||||
switch ($status->scope) {
|
switch ($status->scope) {
|
||||||
case 'public':
|
case 'public':
|
||||||
case 'unlisted':
|
case 'unlisted':
|
||||||
|
break;
|
||||||
case 'private':
|
case 'private':
|
||||||
$user = Auth::check() ? Auth::user() : false;
|
$user = Auth::check() ? Auth::user() : false;
|
||||||
if($user && $profile->is_private) {
|
if(!$user) {
|
||||||
$follows = Follower::whereProfileId($user->profile->id)
|
abort(403);
|
||||||
->whereFollowingId($profile->id)
|
} else {
|
||||||
->exists();
|
$follows = $profile->followedBy(Auth::user()->profile);
|
||||||
if($follows == false && $profile->id !== $user->profile->id) {
|
if($follows == false && $profile->id !== $user->profile->id) {
|
||||||
abort(404);
|
abort(404);
|
||||||
}
|
}
|
||||||
|
@ -430,7 +431,14 @@ class PublicApiController extends Controller
|
||||||
$only_media = $request->only_media ?? false;
|
$only_media = $request->only_media ?? false;
|
||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
$account = Profile::findOrFail($id);
|
$account = Profile::findOrFail($id);
|
||||||
$statuses = $account->statuses()->getQuery()->whereNull('uri');
|
$statuses = $account->statuses()
|
||||||
|
->getQuery()
|
||||||
|
->whereNull('uri');
|
||||||
|
if(!$user || $user->profile->id != $account->id && !$user->profile->follows($account)) {
|
||||||
|
$statuses = $statuses->whereVisibility('public');
|
||||||
|
} else {
|
||||||
|
$statuses = $statuses->whereIn('visibility', ['public', 'unlisted', 'private']);
|
||||||
|
}
|
||||||
if($only_media == true) {
|
if($only_media == true) {
|
||||||
$statuses = $statuses
|
$statuses = $statuses
|
||||||
->whereHas('media')
|
->whereHas('media')
|
||||||
|
@ -453,7 +461,7 @@ class PublicApiController extends Controller
|
||||||
->orderBy('id', 'DESC')
|
->orderBy('id', 'DESC')
|
||||||
->paginate($limit);
|
->paginate($limit);
|
||||||
} else {
|
} else {
|
||||||
$statuses = $statuses->whereVisibility('public')->orderBy('id', 'desc')->paginate($limit);
|
$statuses = $statuses->orderBy('id', 'desc')->paginate($limit);
|
||||||
}
|
}
|
||||||
$resource = new Fractal\Resource\Collection($statuses, new StatusTransformer());
|
$resource = new Fractal\Resource\Collection($statuses, new StatusTransformer());
|
||||||
$res = $this->fractal->createData($resource)->toArray();
|
$res = $this->fractal->createData($resource)->toArray();
|
||||||
|
|
Loading…
Reference in a new issue