Add /api/v1/follow_requests endpoint

This commit is contained in:
Daniel Supernault 2019-09-25 21:51:51 -06:00
parent b3d82edd0f
commit 9726913622
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
2 changed files with 23 additions and 0 deletions

View file

@ -746,6 +746,28 @@ class ApiV1Controller extends Controller
return response()->json([]);
}
/**
* GET /api/v1/follow_requests
*
* Return array of Accounts that have sent follow requests
*
* @return \App\Transformer\Api\AccountTransformer
*/
public function accountFollowRequests(Request $request)
{
abort_if(!$request->user(), 403);
$user = $request->user();
$followRequests = FollowRequest::whereFollowingId($user->profile->id)->pluck('follower_id');
$profiles = Profile::find($followRequests);
$resource = new Fractal\Resource\Collection($profiles, new AccountTransformer());
$res = $this->fractal->createData($resource)->toArray();
return response()->json($res);
}
public function statusById(Request $request, $id)
{
$status = Status::whereVisibility('public')->findOrFail($id);

View file

@ -103,6 +103,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
Route::post('statuses/{id}/favourite', 'Api\ApiV1Controller@statusFavouriteById')->middleware('auth:api');
Route::post('statuses/{id}/unfavourite', 'Api\ApiV1Controller@statusUnfavouriteById')->middleware('auth:api');
Route::get('filters', 'Api\ApiV1Controller@accountFilters')->middleware('auth:api');
Route::get('follow_requests', 'Api\ApiV1Controller@accountFollowRequests')->middleware('auth:api');
Route::get('likes', 'ApiController@hydrateLikes');
Route::post('media', 'ApiController@uploadMedia')->middleware('auth:api');