Update remove_from_followers api endpoint

pull/5907/head^2
Daniel Supernault 4 months ago
parent 92482c24cd
commit 5a3a1cf76c
No known key found for this signature in database
GPG Key ID: 23740873EE6F76A1

@ -4563,41 +4563,45 @@ class ApiV1Controller extends Controller
);
}
public function accountRemoveFollowById(Request $request, $target_id)
public function accountRemoveFollowById(Request $request, $id)
{
abort_if(! $request->user(), 403);
$pid = $request->user()->profile_id;
$pid = $request->user()->profile_id;
if (intval($pid) === intval($target_id)) {
if ($pid === $id) {
return $this->json(['error' => 'Request invalid! target_id is same user id.'], 500);
}
Follower::whereProfileId($target_id)
$exists = Follower::whereProfileId($id)
->whereFollowingId($pid)
->delete();
->first();
abort_unless($exists, 404);
$exists->delete();
RelationshipService::refresh($pid, $target_id);
RelationshipService::refresh($pid, $id);
RelationshipService::refresh($pid, $id);
UnfollowPipeline::dispatch($pid, $pid)->onQueue('high');
UnfollowPipeline::dispatch($id, $pid)->onQueue('high');
RelationshipService::refresh($pid, $target_id);
Cache::forget('profile:following:'.$target_id);
Cache::forget('profile:followers:'.$target_id);
Cache::forget('profile:following:'.$id);
Cache::forget('profile:followers:'.$id);
Cache::forget('profile:following:'.$pid);
Cache::forget('profile:followers:'.$pid);
Cache::forget('api:local:exp:rec:'.$pid);
Cache::forget('user:account:id:'.$target_id);
Cache::forget('user:account:id:'.$id);
Cache::forget('user:account:id:'.$pid);
Cache::forget('profile:follower_count:'.$target_id);
Cache::forget('profile:follower_count:'.$id);
Cache::forget('profile:follower_count:'.$pid);
Cache::forget('profile:following_count:'.$target_id);
Cache::forget('profile:following_count:'.$id);
Cache::forget('profile:following_count:'.$pid);
AccountService::del($pid);
AccountService::del($target_id);
AccountService::del($id);
return $this->json([]);
$res = RelationshipService::get($id, $pid);
return $this->json($res);
}
/**
* GET /api/v1/statuses/{id}/pin

@ -155,7 +155,7 @@
});
break;
case 'removeFollow':
axios.post('/api/v1/accounts/' + id + '/removeFollow').then(res => {
axios.post('/api/pixelfed/v1/accounts/' + id + '/remove_from_followers').then(res => {
swal(
'{{__('settings.relationships.unfollow_successful')}}',
'{{__('settings.relationships.you_have_successfully_unfollowed_that_user')}}',

@ -108,7 +108,7 @@ Route::group(['prefix' => 'api'], function () use ($middleware) {
Route::post('accounts/{id}/unfollow', 'Api\ApiV1Controller@accountUnfollowById')->middleware($middleware);
Route::post('accounts/{id}/block', 'Api\ApiV1Controller@accountBlockById')->middleware($middleware);
Route::post('accounts/{id}/unblock', 'Api\ApiV1Controller@accountUnblockById')->middleware($middleware);
Route::post('accounts/{id}/removeFollow', 'Api\ApiV1Controller@accountRemoveFollowById')->middleware($middleware);
Route::post('accounts/{id}/remove_from_followers', 'Api\ApiV1Controller@accountRemoveFollowById')->middleware($middleware);
Route::post('accounts/{id}/pin', 'Api\ApiV1Controller@accountEndorsements')->middleware($middleware);
Route::post('accounts/{id}/unpin', 'Api\ApiV1Controller@accountEndorsements')->middleware($middleware);
Route::post('accounts/{id}/mute', 'Api\ApiV1Controller@accountMuteById')->middleware($middleware);

@ -68,7 +68,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
Route::get('accounts/{id}/statuses', 'PublicApiController@accountStatuses');
Route::post('accounts/{id}/block', 'Api\ApiV1Controller@accountBlockById');
Route::post('accounts/{id}/unblock', 'Api\ApiV1Controller@accountUnblockById');
Route::post('accounts/{id}/removeFollow', 'Api\ApiV1Controller@accountRemoveFollowById');
Route::post('accounts/{id}/remove_from_followers', 'Api\ApiV1Controller@accountRemoveFollowById');
Route::get('statuses/{id}', 'PublicApiController@getStatus');
Route::post('statuses/{id}/pin', 'PublicApiController@statusPin');
Route::post('statuses/{id}/unpin', 'PublicApiController@statusUnpin');

Loading…
Cancel
Save