mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-25 15:55:22 +00:00
Add /api/v1/accounts/{id}/following endpoint
This commit is contained in:
parent
41c91cba43
commit
607eb51b4e
2 changed files with 25 additions and 1 deletions
|
@ -165,6 +165,30 @@ class ApiV1Controller extends Controller
|
|||
return response()->json($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/v1/accounts/{id}/following
|
||||
*
|
||||
* @param integer $id
|
||||
*
|
||||
* @return \App\Transformer\Api\AccountTransformer
|
||||
*/
|
||||
public function accountFollowingById(Request $request, $id)
|
||||
{
|
||||
abort_if(!$request->user(), 403);
|
||||
$profile = Profile::whereNull('status')->findOrFail($id);
|
||||
|
||||
$settings = $profile->user->settings;
|
||||
if($settings->show_profile_following == true) {
|
||||
$limit = $request->input('limit') ?? 40;
|
||||
$following = $profile->following()->paginate($limit);
|
||||
$resource = new Fractal\Resource\Collection($following, new AccountTransformer());
|
||||
$res = $this->fractal->createData($resource)->toArray();
|
||||
} else {
|
||||
$res = [];
|
||||
}
|
||||
return response()->json($res);
|
||||
}
|
||||
|
||||
public function statusById(Request $request, $id)
|
||||
{
|
||||
$status = Status::whereVisibility('public')->findOrFail($id);
|
||||
|
|
|
@ -81,7 +81,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
|
|||
Route::patch('accounts/update_credentials', 'Api\ApiV1Controller@accountUpdateCredentials')->middleware('auth:api');
|
||||
Route::get('accounts/relationships', 'PublicApiController@relationships')->middleware('auth:api');
|
||||
Route::get('accounts/{id}/statuses', 'PublicApiController@accountStatuses')->middleware('auth:api');
|
||||
Route::get('accounts/{id}/following', 'PublicApiController@accountFollowing')->middleware('auth:api');
|
||||
Route::get('accounts/{id}/following', 'Api\ApiV1Controller@accountFollowingById')->middleware('auth:api');
|
||||
Route::get('accounts/{id}/followers', 'Api\ApiV1Controller@accountFollowersById')->middleware('auth:api');
|
||||
// Route::get('accounts/{id}', 'PublicApiController@account');
|
||||
Route::get('accounts/{id}', 'Api\ApiV1Controller@accountById');
|
||||
|
|
Loading…
Reference in a new issue