mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-23 06:51:27 +00:00
Update ApiV1Controller
This commit is contained in:
parent
7bb9fb1f01
commit
eeca1fbc54
1 changed files with 36 additions and 9 deletions
|
@ -205,19 +205,32 @@ class ApiV1Controller extends Controller
|
||||||
public function accountFollowersById(Request $request, $id)
|
public function accountFollowersById(Request $request, $id)
|
||||||
{
|
{
|
||||||
abort_if(!$request->user(), 403);
|
abort_if(!$request->user(), 403);
|
||||||
|
|
||||||
|
$user = $request->user();
|
||||||
$profile = Profile::whereNull('status')->findOrFail($id);
|
$profile = Profile::whereNull('status')->findOrFail($id);
|
||||||
|
$limit = $request->input('limit') ?? 40;
|
||||||
|
|
||||||
if($profile->domain) {
|
if($profile->domain) {
|
||||||
$res = [];
|
$res = [];
|
||||||
} else {
|
} else {
|
||||||
$settings = $profile->user->settings;
|
if($profile->id == $user->profile_id) {
|
||||||
if($settings->show_profile_followers == true) {
|
|
||||||
$limit = $request->input('limit') ?? 40;
|
|
||||||
$followers = $profile->followers()->paginate($limit);
|
$followers = $profile->followers()->paginate($limit);
|
||||||
$resource = new Fractal\Resource\Collection($followers, new AccountTransformer());
|
$resource = new Fractal\Resource\Collection($followers, new AccountTransformer());
|
||||||
$res = $this->fractal->createData($resource)->toArray();
|
$res = $this->fractal->createData($resource)->toArray();
|
||||||
} else {
|
} else {
|
||||||
|
if($profile->is_private) {
|
||||||
|
abort_if(!$profile->followedBy($user->profile), 403);
|
||||||
|
}
|
||||||
|
$settings = $profile->user->settings;
|
||||||
|
if( in_array($user->profile_id, $profile->blockedIds()->toArray()) ||
|
||||||
|
$settings->show_profile_followers == false
|
||||||
|
) {
|
||||||
$res = [];
|
$res = [];
|
||||||
|
} else {
|
||||||
|
$followers = $profile->followers()->paginate($limit);
|
||||||
|
$resource = new Fractal\Resource\Collection($followers, new AccountTransformer());
|
||||||
|
$res = $this->fractal->createData($resource)->toArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return response()->json($res);
|
return response()->json($res);
|
||||||
|
@ -233,21 +246,35 @@ class ApiV1Controller extends Controller
|
||||||
public function accountFollowingById(Request $request, $id)
|
public function accountFollowingById(Request $request, $id)
|
||||||
{
|
{
|
||||||
abort_if(!$request->user(), 403);
|
abort_if(!$request->user(), 403);
|
||||||
|
|
||||||
|
$user = $request->user();
|
||||||
$profile = Profile::whereNull('status')->findOrFail($id);
|
$profile = Profile::whereNull('status')->findOrFail($id);
|
||||||
|
$limit = $request->input('limit') ?? 40;
|
||||||
|
|
||||||
if($profile->domain) {
|
if($profile->domain) {
|
||||||
$res = [];
|
$res = [];
|
||||||
} else {
|
} else {
|
||||||
$settings = $profile->user->settings;
|
if($profile->id == $user->profile_id) {
|
||||||
if($settings->show_profile_following == true) {
|
|
||||||
$limit = $request->input('limit') ?? 40;
|
|
||||||
$following = $profile->following()->paginate($limit);
|
$following = $profile->following()->paginate($limit);
|
||||||
$resource = new Fractal\Resource\Collection($following, new AccountTransformer());
|
$resource = new Fractal\Resource\Collection($following, new AccountTransformer());
|
||||||
$res = $this->fractal->createData($resource)->toArray();
|
$res = $this->fractal->createData($resource)->toArray();
|
||||||
} else {
|
} else {
|
||||||
|
if($profile->is_private) {
|
||||||
|
abort_if(!$profile->followedBy($user->profile), 403);
|
||||||
|
}
|
||||||
|
$settings = $profile->user->settings;
|
||||||
|
if( in_array($user->profile_id, $profile->blockedIds()->toArray()) ||
|
||||||
|
$settings->show_profile_following == false
|
||||||
|
) {
|
||||||
$res = [];
|
$res = [];
|
||||||
|
} else {
|
||||||
|
$following = $profile->following()->paginate($limit);
|
||||||
|
$resource = new Fractal\Resource\Collection($following, new AccountTransformer());
|
||||||
|
$res = $this->fractal->createData($resource)->toArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return response()->json($res);
|
return response()->json($res);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue