Skip to content

Commit

Permalink
🔥 remove deprecated api endpoints (#3084)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKrisKrisu authored Jan 1, 2025
2 parents 9077661 + 19dc2ab commit 1ce367e
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 79 deletions.
16 changes: 0 additions & 16 deletions app/Http/Controllers/API/v1/EventController.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,20 +271,4 @@ public function suggest(Request $request): JsonResponse {
}
return $this->sendError(error: __('messages.exception.general'), code: 500);
}

/**
* @OA\Get(
* path="/activeEvents",
* operationId="getActiveEvents",
* tags={"Events"},
* summary="DEPRECATED - USE /events - removed after 2024-08",
* description="DEPRECATED - USE /events - removed after 2024-08",
* @OA\Response(response=200, description="The events"),
* )
* @return AnonymousResourceCollection
* @deprecated Use /events instead - removed after 2024-08
*/
public function activeEvents(): AnonymousResourceCollection {
return EventResource::collection(Event::forTimestamp(now())->get());
}
}
50 changes: 0 additions & 50 deletions app/Http/Controllers/API/v1/FollowController.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,27 +210,6 @@ public function getFollowings(): AnonymousResourceCollection {
return UserResource::collection(FollowBackend::getFollowings(user: auth()->user()));
}

// TODO remove after 2024-10
public function removeFollower(Request $request): JsonResponse {
$validated = $request->validate(['userId' => ['required',]]);
try {
$follow = Follow::where('user_id', $validated['userId'])
->where('follow_id', auth()->user()->id)
->firstOrFail();

$removeResponse = FollowBackend::removeFollower(follow: $follow, user: auth()->user());
if ($removeResponse === true) {
return $this->sendResponse();
}
Log::error('APIv1/removeFollower: Could not remove follower', ['follow' => $follow, 'user' => auth()->user()]);
return $this->sendError('Unknown error', 500);
} catch (ModelNotFoundException) {
return $this->sendError('Follow not found');
} catch (AuthorizationException) {
return $this->sendError('Permission denied', 403);
}
}

/**
* @param Request $request
*
Expand Down Expand Up @@ -327,21 +306,6 @@ public function approveFollowRequestByUserId(int $userId): JsonResponse {
}
}

// TODO remove after 2024-10
public function approveFollowRequest(Request $request): JsonResponse {
$validated = $request->validate(['userId' => ['required',]]);

try {
FollowBackend::approveFollower(auth()->user()->id, $validated['userId']);
return $this->sendResponse();
} catch (ModelNotFoundException) {
return $this->sendError('Request not found');
} catch (Exception) {
Log::error('APIv1/approveFollowRequest: Could not approve follow request', ['user' => auth()->user(), 'userId' => $validated['userId']]);
return $this->sendError('Unknown error', 500);
}
}

/**
* @param Request $request
*
Expand Down Expand Up @@ -386,18 +350,4 @@ public function rejectFollowRequestByUserId(int $userId): JsonResponse {
return $this->sendError('Unknown error', 500);
}
}

// TODO remove after 2024-10
public function rejectFollowRequest(Request $request): JsonResponse {
$validated = $request->validate(['userId' => ['required',]]);
try {
FollowBackend::rejectFollower(auth()->user()->id, $validated['userId']);
return $this->sendResponse();
} catch (ModelNotFoundException) {
return $this->sendError('Request not found');
} catch (Exception) {
Log::error('APIv1/rejectFollowRequest: Could not reject follow request', ['user' => auth()->user(), 'userId' => $validated['userId']]);
return $this->sendError('Unknown error', 500);
}
}
}
11 changes: 0 additions & 11 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,6 @@
Route::post('/{userId}/follow', [FollowController::class, 'createFollow']);
Route::delete('/{userId}/follow', [FollowController::class, 'destroyFollow']);
});
Route::group(['middleware' => ['scope:write-followers']], static function() {
Route::delete('removeFollower', [FollowController::class, 'removeFollower']); // TODO remove after 2024-10
Route::delete('rejectFollowRequest', [FollowController::class, 'rejectFollowRequest']); // TODO remove after 2024-10
Route::put('approveFollowRequest', [FollowController::class, 'approveFollowRequest']); // TODO remove after 2024-10
});
Route::group(['middleware' => ['scope:write-blocks']], static function() {
Route::post('/{userId}/block', [UserController::class, 'createBlock']);
Route::delete('/{userId}/block', [UserController::class, 'destroyBlock']);
Expand Down Expand Up @@ -159,11 +154,6 @@
Route::delete('tokens', [TokenController::class, 'revokeAllTokens']); //TODO: undocumented endpoint - document when stable
Route::delete('token', [TokenController::class, 'revokeToken']); //TODO: undocumented endpoint - document when stable
});
Route::group(['middleware' => ['scope:read-settings-followers']], static function() {
Route::get('followers', [FollowController::class, 'getFollowers']); // TODO remove after 2024-10
Route::get('follow-requests', [FollowController::class, 'getFollowRequests']); // TODO remove after 2024-10
Route::get('followings', [FollowController::class, 'getFollowings']); // TODO remove after 2024-10
});
});
Route::group(['prefix' => 'webhooks'], static function() {
Route::get('/', [WebhookController::class, 'getWebhooks']);
Expand Down Expand Up @@ -216,7 +206,6 @@
Route::get('event/{slug}/details', [EventController::class, 'showDetails']);
Route::get('event/{slug}/statuses', [EventController::class, 'statuses']);
Route::get('events', [EventController::class, 'index']);
Route::get('activeEvents', [EventController::class, 'activeEvents']); //@deprecated: remove after 2024-08
Route::get('user/{username}', [UserController::class, 'show']);
Route::get('user/{username}/statuses', [UserController::class, 'statuses']);
});
Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/APIv1/FollowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function testCreateAndListFollow(): void {
]);

//User 1 shouldn't have followers...
$response = $this->get('/api/v1/settings/followers');
$response = $this->get('/api/v1/user/self/followers');
$response->assertOk();
$response->assertJsonStructure([
'data',
Expand All @@ -56,7 +56,7 @@ public function testCreateAndListFollow(): void {
$this->assertCount(0, $response->json('data'));

//...but user1 should have one following.
$response = $this->get('/api/v1/settings/followings');
$response = $this->get('/api/v1/user/self/followings');
$response->assertOk();
$this->assertCount(1, $response->json('data'));
}
Expand Down

0 comments on commit 1ce367e

Please sign in to comment.