Skip to content

Commit

Permalink
Add /api/v1/mutes endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
dansup committed Sep 26, 2019
1 parent fcf231f commit b280d18
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
30 changes: 30 additions & 0 deletions app/Http/Controllers/Api/ApiV1Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,36 @@ public function mediaUpdate(Request $request, $id)
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);
Expand Down
3 changes: 2 additions & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@
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');
Expand Down

0 comments on commit b280d18

Please sign in to comment.