Update FollowerService

This commit is contained in:
Daniel Supernault 2021-07-11 07:43:29 -06:00
parent ff48400a38
commit c8824d1b51
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
3 changed files with 172 additions and 120 deletions

View file

@ -573,9 +573,13 @@ class PublicApiController extends Controller
{
abort_unless(Auth::check(), 403);
$profile = Profile::with('user')->whereNull('status')->whereNull('domain')->findOrFail($id);
$owner = Auth::id() == $profile->user_id;
if(Auth::id() != $profile->user_id && $profile->is_private || !$profile->user->settings->show_profile_followers) {
return response()->json([]);
}
if(!$owner && $request->page > 5) {
return [];
}
$followers = $profile->followers()->orderByDesc('followers.created_at')->paginate(10);
$resource = new Fractal\Resource\Collection($followers, new AccountTransformer());
$res = $this->fractal->createData($resource)->toArray();
@ -600,6 +604,10 @@ class PublicApiController extends Controller
abort_if($owner == false && $profile->is_private == true && !$profile->followedBy(Auth::user()->profile), 404);
abort_if($profile->user->settings->show_profile_following == false && $owner == false, 404);
if(!$owner && $request->page > 5) {
return [];
}
if($search) {
abort_if(!$owner, 404);
$following = $profile->following()