mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-09 16:24:51 +00:00
Add /api/v1/blocks endpoint
This commit is contained in:
parent
5a0c295ed1
commit
ac9f1bc04e
2 changed files with 35 additions and 1 deletions
|
@ -500,7 +500,39 @@ class ApiV1Controller extends Controller
|
|||
|
||||
$resource = new Fractal\Resource\Collection($profiles, new AccountTransformer());
|
||||
$res = $this->fractal->createData($resource)->toArray();
|
||||
return response()->json($res, 200, [], JSON_PRETTY_PRINT);
|
||||
return response()->json($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/v1/blocks
|
||||
*
|
||||
*
|
||||
*
|
||||
* @return \App\Transformer\Api\AccountTransformer
|
||||
*/
|
||||
public function accountBlocks(Request $request)
|
||||
{
|
||||
abort_if(!$request->user(), 403);
|
||||
|
||||
$this->validate($request, [
|
||||
'limit' => 'nullable|integer|min:1|max:40',
|
||||
'page' => 'nullable|integer|min:1|max:10'
|
||||
]);
|
||||
|
||||
$user = $request->user();
|
||||
$limit = $request->input('limit') ?? 40;
|
||||
|
||||
$blocked = UserFilter::select('filterable_id','filterable_type','filter_type','user_id')
|
||||
->whereUserId($user->profile_id)
|
||||
->whereFilterableType('App\Profile')
|
||||
->whereFilterType('block')
|
||||
->simplePaginate($limit)
|
||||
->pluck('filterable_id');
|
||||
|
||||
$profiles = Profile::findOrFail($blocked);
|
||||
$resource = new Fractal\Resource\Collection($profiles, new AccountTransformer());
|
||||
$res = $this->fractal->createData($resource)->toArray();
|
||||
return response()->json($res);
|
||||
}
|
||||
|
||||
public function statusById(Request $request, $id)
|
||||
|
|
|
@ -86,6 +86,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
|
|||
Route::get('accounts/{id}/followers', 'Api\ApiV1Controller@accountFollowersById')->middleware('auth:api');
|
||||
Route::post('accounts/{id}/follow', 'Api\ApiV1Controller@accountFollowById')->middleware('auth:api');
|
||||
Route::post('accounts/{id}/unfollow', 'Api\ApiV1Controller@accountUnfollowById')->middleware('auth:api');
|
||||
Route::get('blocks', 'Api\ApiV1Controller@accountBlocks')->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');
|
||||
|
@ -123,6 +124,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
|
|||
Route::get('accounts/{id}/followers', 'PublicApiController@accountFollowers');
|
||||
Route::get('accounts/{id}', 'PublicApiController@account');
|
||||
Route::post('avatar/update', 'ApiController@avatarUpdate');
|
||||
Route::get('blocks', 'Api\ApiV1Controller@accountBlocks');
|
||||
Route::get('likes', 'ApiController@hydrateLikes');
|
||||
Route::post('media', 'ApiController@uploadMedia');
|
||||
Route::delete('media', 'ApiController@deleteMedia');
|
||||
|
|
Loading…
Reference in a new issue