Add /api/v1/mutes endpoint

This commit is contained in:
Daniel Supernault 2019-09-25 23:09:50 -06:00
parent fcf231f430
commit b280d183ad
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
2 changed files with 32 additions and 1 deletions

View file

@ -995,6 +995,36 @@ class ApiV1Controller extends Controller
return response()->json($res); 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) public function statusById(Request $request, $id)
{ {
$status = Status::whereVisibility('public')->findOrFail($id); $status = Status::whereVisibility('public')->findOrFail($id);

View file

@ -112,6 +112,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
Route::get('lists/{id}/accounts', 'Api\ApiV1Controller@accountListsById')->middleware('auth:api'); Route::get('lists/{id}/accounts', 'Api\ApiV1Controller@accountListsById')->middleware('auth:api');
Route::post('media', 'Api\ApiV1Controller@mediaUpload')->middleware('auth:api'); Route::post('media', 'Api\ApiV1Controller@mediaUpload')->middleware('auth:api');
Route::put('media/{id}', 'Api\ApiV1Controller@mediaUpdate')->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::get('likes', 'ApiController@hydrateLikes');
// Route::post('media', 'ApiController@uploadMedia')->middleware('auth:api'); // Route::post('media', 'ApiController@uploadMedia')->middleware('auth:api');