1
0
Fork 0
forked from mirror/pixelfed

Update BaseApiController@accountStatuses, handle visibility scope properly

This commit is contained in:
Daniel Supernault 2018-08-31 18:54:50 -06:00
parent c1f66b968e
commit bfa04b7ad7
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -57,8 +57,14 @@ class BaseApiController extends Controller
public function accountStatuses(Request $request, $id) public function accountStatuses(Request $request, $id)
{ {
$pid = Auth::user()->profile->id;
$profile = Profile::findOrFail($id); $profile = Profile::findOrFail($id);
$statuses = $profile->statuses()->orderBy('id', 'desc')->paginate(20); $statuses = $profile->statuses();
if($pid === $profile->id) {
$statuses = $statuses->orderBy('id', 'desc')->paginate(20);
} else {
$statuses = $statuses->whereVisibility('public')->orderBy('id', 'desc')->paginate(20);
}
$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();