forked from mirror/pixelfed
Add /api/v1/accounts/{id}/unmute endpoint
This commit is contained in:
parent
3e98dce4de
commit
41c96ddd6a
2 changed files with 39 additions and 4 deletions
|
@ -1030,24 +1030,24 @@ class ApiV1Controller extends Controller
|
|||
*
|
||||
* @param integer $id
|
||||
*
|
||||
* @return App\Transformer\Api\AccountTransformer
|
||||
* @return App\Transformer\Api\RelationshipTransformer
|
||||
*/
|
||||
public function accountMuteById(Request $request, $id)
|
||||
{
|
||||
abort_if(!$request->user(), 403);
|
||||
|
||||
$user = $request->user();
|
||||
$pid = $user->profile_id;
|
||||
|
||||
$account = Profile::findOrFail($id);
|
||||
|
||||
$filter = UserFilter::firstOrCreate([
|
||||
'user_id' => $user->profile_id,
|
||||
'user_id' => $pid,
|
||||
'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");
|
||||
|
@ -1057,6 +1057,40 @@ class ApiV1Controller extends Controller
|
|||
return response()->json($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/v1/accounts/{id}/unmute
|
||||
*
|
||||
* @param integer $id
|
||||
*
|
||||
* @return App\Transformer\Api\RelationshipTransformer
|
||||
*/
|
||||
public function accountUnmuteById(Request $request, $id)
|
||||
{
|
||||
abort_if(!$request->user(), 403);
|
||||
|
||||
$user = $request->user();
|
||||
$pid = $user->profile_id;
|
||||
|
||||
$account = Profile::findOrFail($id);
|
||||
|
||||
$filter = UserFilter::whereUserId($pid)
|
||||
->whereFilterableId($account->id)
|
||||
->whereFilterableType('App\Profile')
|
||||
->whereFilterType('mute')
|
||||
->first();
|
||||
|
||||
if($filter) {
|
||||
$filter->delete();
|
||||
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);
|
||||
|
|
|
@ -91,7 +91,6 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
|
|||
Route::post('accounts/{id}/pin', 'Api\ApiV1Controller@accountEndorsements')->middleware('auth:api');
|
||||
Route::post('accounts/{id}/unpin', 'Api\ApiV1Controller@accountEndorsements')->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');
|
||||
Route::get('domain_blocks', 'Api\ApiV1Controller@accountDomainBlocks')->middleware('auth:api');
|
||||
Route::post('domain_blocks', 'Api\ApiV1Controller@accountDomainBlocks')->middleware('auth:api');
|
||||
|
@ -114,6 +113,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
|
|||
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::post('accounts/{id}/unmute', 'Api\ApiV1Controller@accountUnmuteById')->middleware('auth:api');
|
||||
|
||||
// Route::get('likes', 'ApiController@hydrateLikes');
|
||||
// Route::post('media', 'ApiController@uploadMedia')->middleware('auth:api');
|
||||
|
@ -122,6 +122,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
|
|||
// Route::get('timelines/public', 'PublicApiController@publicTimelineApi');
|
||||
// Route::get('timelines/home', 'PublicApiController@homeTimelineApi')->middleware('auth:api');
|
||||
// Route::post('status', 'Api\ApiV1Controller@createStatus')->middleware('auth:api');
|
||||
Route::get('accounts/{id}', 'Api\ApiV1Controller@accountById');
|
||||
});
|
||||
Route::group(['prefix' => 'v2'], function() {
|
||||
Route::get('config', 'ApiController@siteConfiguration');
|
||||
|
|
Loading…
Reference in a new issue