diff --git a/app/Http/Controllers/Api/ApiV1Controller.php b/app/Http/Controllers/Api/ApiV1Controller.php index aa742c596..bbb58ac2e 100644 --- a/app/Http/Controllers/Api/ApiV1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Controller.php @@ -995,6 +995,36 @@ class ApiV1Controller extends Controller return response()->json($res); } + /** + * GET /api/v1/mutes + * + * + * @return App\Transformer\Api\AccountTransformer + */ + public function accountMutes(Request $request) + { + abort_if(!$request->user(), 403); + + $this->validate($request, [ + 'limit' => 'nullable|integer|min:1|max:40' + ]); + + $user = $request->user(); + $limit = $request->input('limit') ?? 40; + + $mutes = UserFilter::whereUserId($user->profile_id) + ->whereFilterableType('App\Profile') + ->whereFilterType('mute') + ->simplePaginate($limit) + ->pluck('filterable_id'); + + $accounts = Profile::find($mutes); + + $resource = new Fractal\Resource\Collection($accounts, new AccountTransformer()); + $res = $this->fractal->createData($resource)->toArray(); + return response()->json($res); + } + public function statusById(Request $request, $id) { $status = Status::whereVisibility('public')->findOrFail($id); diff --git a/routes/web.php b/routes/web.php index 3ad9f6c81..58592fc34 100644 --- a/routes/web.php +++ b/routes/web.php @@ -112,7 +112,8 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact Route::get('lists/{id}/accounts', 'Api\ApiV1Controller@accountListsById')->middleware('auth:api'); Route::post('media', 'Api\ApiV1Controller@mediaUpload')->middleware('auth:api'); Route::put('media/{id}', 'Api\ApiV1Controller@mediaUpdate')->middleware('auth:api'); - + Route::get('mutes', 'Api\ApiV1Controller@accountMutes')->middleware('auth:api'); + // Route::get('likes', 'ApiController@hydrateLikes'); // Route::post('media', 'ApiController@uploadMedia')->middleware('auth:api'); // Route::delete('media', 'ApiController@deleteMedia')->middleware('auth:api');