mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 06:21:27 +00:00
Add /api/v1/accounts/{id}/followers endpoint
This commit is contained in:
parent
6afd69702a
commit
41c91cba43
2 changed files with 38 additions and 1 deletions
|
@ -34,6 +34,7 @@ class ApiV1Controller extends Controller
|
|||
$this->fractal = new Fractal\Manager();
|
||||
$this->fractal->setSerializer(new ArraySerializer());
|
||||
}
|
||||
|
||||
public function apps(Request $request)
|
||||
{
|
||||
abort_if(!config('pixelfed.oauth_enabled'), 404);
|
||||
|
@ -69,6 +70,13 @@ class ApiV1Controller extends Controller
|
|||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/v1/accounts/{id}
|
||||
*
|
||||
* @param integer $id
|
||||
*
|
||||
* @return \App\Transformer\Api\AccountTransformer
|
||||
*/
|
||||
public function accountById(Request $request, $id)
|
||||
{
|
||||
$profile = Profile::whereNull('status')->findOrFail($id);
|
||||
|
@ -78,6 +86,11 @@ class ApiV1Controller extends Controller
|
|||
return response()->json($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* PATCH /api/v1/accounts/update_credentials
|
||||
*
|
||||
* @return \App\Transformer\Api\AccountTransformer
|
||||
*/
|
||||
public function accountUpdateCredentials(Request, $request)
|
||||
{
|
||||
abort_if(!$request->user(), 403);
|
||||
|
@ -128,6 +141,30 @@ class ApiV1Controller extends Controller
|
|||
return response()->json($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/v1/accounts/{id}/followers
|
||||
*
|
||||
* @param integer $id
|
||||
*
|
||||
* @return \App\Transformer\Api\AccountTransformer
|
||||
*/
|
||||
public function accountFollowersById(Request $request, $id)
|
||||
{
|
||||
abort_if(!$request->user(), 403);
|
||||
$profile = Profile::whereNull('status')->findOrFail($id);
|
||||
|
||||
$settings = $profile->user->settings;
|
||||
if($settings->show_profile_followers == true) {
|
||||
$limit = $request->input('limit') ?? 40;
|
||||
$followers = $profile->followers()->paginate($limit);
|
||||
$resource = new Fractal\Resource\Collection($followers, 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);
|
||||
|
|
|
@ -82,7 +82,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
|
|||
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}/followers', 'PublicApiController@accountFollowers')->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');
|
||||
Route::post('avatar/update', 'ApiController@avatarUpdate')->middleware('auth:api');
|
||||
|
|
Loading…
Reference in a new issue