mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-23 21:43:17 +00:00
Add /api/v1/accounts/{id}/mute endpoint
This commit is contained in:
parent
b280d183ad
commit
3e98dce4de
2 changed files with 34 additions and 1 deletions
|
@ -1025,6 +1025,38 @@ class ApiV1Controller extends Controller
|
|||
return response()->json($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/v1/accounts/{id}/mute
|
||||
*
|
||||
* @param integer $id
|
||||
*
|
||||
* @return App\Transformer\Api\AccountTransformer
|
||||
*/
|
||||
public function accountMuteById(Request $request, $id)
|
||||
{
|
||||
abort_if(!$request->user(), 403);
|
||||
|
||||
$user = $request->user();
|
||||
|
||||
$account = Profile::findOrFail($id);
|
||||
|
||||
$filter = UserFilter::firstOrCreate([
|
||||
'user_id' => $user->profile_id,
|
||||
'filterable_id' => $account->id,
|
||||
'filterable_type' => 'App\Profile',
|
||||
'filter_type' => 'mute',
|
||||
]);
|
||||
|
||||
$pid = $user->profile_id;
|
||||
Cache::forget("user:filter:list:$pid");
|
||||
Cache::forget("feature:discover:posts:$pid");
|
||||
Cache::forget("api:local:exp:rec:$pid");
|
||||
|
||||
$resource = new Fractal\Resource\Item($account, new RelationshipTransformer());
|
||||
$res = $this->fractal->createData($resource)->toArray();
|
||||
return response()->json($res);
|
||||
}
|
||||
|
||||
public function statusById(Request $request, $id)
|
||||
{
|
||||
$status = Status::whereVisibility('public')->findOrFail($id);
|
||||
|
|
|
@ -113,7 +113,8 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
|
|||
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::post('accounts/{id}/mute', 'Api\ApiV1Controller@accountMuteById')->middleware('auth:api');
|
||||
|
||||
// Route::get('likes', 'ApiController@hydrateLikes');
|
||||
// Route::post('media', 'ApiController@uploadMedia')->middleware('auth:api');
|
||||
// Route::delete('media', 'ApiController@deleteMedia')->middleware('auth:api');
|
||||
|
|
Loading…
Reference in a new issue