From a8453e7719ec78e5cc886aceef74f57d8e4cb063 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 6 Jun 2023 01:55:28 -0600 Subject: [PATCH 1/2] Update api routes, add DeprecatedEndpoint middleware --- app/Http/Middleware/DeprecatedEndpoint.php | 28 +++++++ routes/api.php | 93 +++++++++++++++++++++- 2 files changed, 117 insertions(+), 4 deletions(-) create mode 100644 app/Http/Middleware/DeprecatedEndpoint.php diff --git a/app/Http/Middleware/DeprecatedEndpoint.php b/app/Http/Middleware/DeprecatedEndpoint.php new file mode 100644 index 000000000..b6df30386 --- /dev/null +++ b/app/Http/Middleware/DeprecatedEndpoint.php @@ -0,0 +1,28 @@ +gt('Jan 01, 2024'), 404); + $response = $next($request); + $link = $response->headers->has('link') ? $response->headers->get('link') . ',; rel="deprecation"' : '; rel="deprecation"'; + $response->withHeaders([ + 'Deprecation' => 'Sat, 01 Jul 2023 00:00:00 GMT', + 'Sunset' => 'Mon, 01 Jan 2024 00:00:00 GMT', + 'Link' => $link + ]); + return $response; + } +} diff --git a/routes/api.php b/routes/api.php index ba883073e..253057d16 100644 --- a/routes/api.php +++ b/routes/api.php @@ -1,6 +1,7 @@ 'api'], function() use($middleware) { }); Route::group(['prefix' => 'v1.1'], function() use($middleware) { - Route::post('report', 'Api\ApiV1Dot1Controller@report')->middleware($middleware); + $reportMiddleware = $middleware; + $reportMiddleware[] = DeprecatedEndpoint::class; + Route::post('report', 'Api\ApiV1Dot1Controller@report')->middleware($reportMiddleware); Route::group(['prefix' => 'accounts'], function () use($middleware) { + $middleware[] = DeprecatedEndpoint::class; + Route::get('timelines/home', 'Api\ApiV1Controller@timelineHome')->middleware($middleware); Route::delete('avatar', 'Api\ApiV1Dot1Controller@deleteAvatar')->middleware($middleware); Route::get('{id}/posts', 'Api\ApiV1Dot1Controller@accountPosts')->middleware($middleware); Route::post('change-password', 'Api\ApiV1Dot1Controller@accountChangePassword')->middleware($middleware); @@ -117,12 +122,10 @@ Route::group(['prefix' => 'api'], function() use($middleware) { Route::get('two-factor', 'Api\ApiV1Dot1Controller@accountTwoFactor')->middleware($middleware); Route::get('emails-from-pixelfed', 'Api\ApiV1Dot1Controller@accountEmailsFromPixelfed')->middleware($middleware); Route::get('apps-and-applications', 'Api\ApiV1Dot1Controller@accountApps')->middleware($middleware); - - Route::get('app/settings', 'UserAppSettingsController@get')->middleware($middleware); - Route::post('app/settings', 'UserAppSettingsController@store')->middleware($middleware); }); Route::group(['prefix' => 'collections'], function () use($middleware) { + $middleware[] = DeprecatedEndpoint::class; Route::get('accounts/{id}', 'CollectionController@getUserCollections')->middleware($middleware); Route::get('items/{id}', 'CollectionController@getItems')->middleware($middleware); Route::get('view/{id}', 'CollectionController@getCollection')->middleware($middleware); @@ -133,6 +136,7 @@ Route::group(['prefix' => 'api'], function() use($middleware) { }); Route::group(['prefix' => 'direct'], function () use($middleware) { + $middleware[] = DeprecatedEndpoint::class; Route::get('thread', 'DirectMessageController@thread')->middleware($middleware); Route::post('thread/send', 'DirectMessageController@create')->middleware($middleware); Route::delete('thread/message', 'DirectMessageController@delete')->middleware($middleware); @@ -144,16 +148,19 @@ Route::group(['prefix' => 'api'], function() use($middleware) { }); Route::group(['prefix' => 'archive'], function () use($middleware) { + $middleware[] = DeprecatedEndpoint::class; Route::post('add/{id}', 'Api\ApiV1Dot1Controller@archive')->middleware($middleware); Route::post('remove/{id}', 'Api\ApiV1Dot1Controller@unarchive')->middleware($middleware); Route::get('list', 'Api\ApiV1Dot1Controller@archivedPosts')->middleware($middleware); }); Route::group(['prefix' => 'places'], function () use($middleware) { + $middleware[] = DeprecatedEndpoint::class; Route::get('posts/{id}/{slug}', 'Api\ApiV1Dot1Controller@placesById')->middleware($middleware); }); Route::group(['prefix' => 'stories'], function () use($middleware) { + $middleware[] = DeprecatedEndpoint::class; Route::get('carousel', 'Stories\StoryApiV1Controller@carousel')->middleware($middleware); Route::post('add', 'Stories\StoryApiV1Controller@add')->middleware($middleware); Route::post('publish', 'Stories\StoryApiV1Controller@publish')->middleware($middleware); @@ -163,17 +170,20 @@ Route::group(['prefix' => 'api'], function() use($middleware) { }); Route::group(['prefix' => 'compose'], function () use($middleware) { + $middleware[] = DeprecatedEndpoint::class; Route::get('search/location', 'ComposeController@searchLocation')->middleware($middleware); Route::get('settings', 'ComposeController@composeSettings')->middleware($middleware); }); Route::group(['prefix' => 'discover'], function () use($middleware) { + $middleware[] = DeprecatedEndpoint::class; Route::get('accounts/popular', 'Api\ApiV1Controller@discoverAccountsPopular')->middleware($middleware); Route::get('posts/trending', 'DiscoverController@trendingApi')->middleware($middleware); Route::get('posts/hashtags', 'DiscoverController@trendingHashtags')->middleware($middleware); }); Route::group(['prefix' => 'directory'], function () use($middleware) { + $middleware[] = DeprecatedEndpoint::class; Route::get('listing', 'PixelfedDirectoryController@get'); }); @@ -230,4 +240,79 @@ Route::group(['prefix' => 'api'], function() use($middleware) { Route::group(['prefix' => 'landing/v1'], function() use($middleware) { Route::get('directory', 'LandingController@getDirectoryApi'); }); + + Route::group(['prefix' => 'pixelfed'], function() use($middleware) { + Route::group(['prefix' => 'v1'], function() use($middleware) { + Route::post('report', 'Api\ApiV1Dot1Controller@report')->middleware($middleware); + + Route::group(['prefix' => 'accounts'], function () use($middleware) { + Route::get('timelines/home', 'Api\ApiV1Controller@timelineHome')->middleware($middleware); + Route::delete('avatar', 'Api\ApiV1Dot1Controller@deleteAvatar')->middleware($middleware); + Route::get('{id}/posts', 'Api\ApiV1Dot1Controller@accountPosts')->middleware($middleware); + Route::post('change-password', 'Api\ApiV1Dot1Controller@accountChangePassword')->middleware($middleware); + Route::get('login-activity', 'Api\ApiV1Dot1Controller@accountLoginActivity')->middleware($middleware); + Route::get('two-factor', 'Api\ApiV1Dot1Controller@accountTwoFactor')->middleware($middleware); + Route::get('emails-from-pixelfed', 'Api\ApiV1Dot1Controller@accountEmailsFromPixelfed')->middleware($middleware); + Route::get('apps-and-applications', 'Api\ApiV1Dot1Controller@accountApps')->middleware($middleware); + }); + + Route::group(['prefix' => 'archive'], function () use($middleware) { + Route::post('add/{id}', 'Api\ApiV1Dot1Controller@archive')->middleware($middleware); + Route::post('remove/{id}', 'Api\ApiV1Dot1Controller@unarchive')->middleware($middleware); + Route::get('list', 'Api\ApiV1Dot1Controller@archivedPosts')->middleware($middleware); + }); + + Route::group(['prefix' => 'collections'], function () use($middleware) { + Route::get('accounts/{id}', 'CollectionController@getUserCollections')->middleware($middleware); + Route::get('items/{id}', 'CollectionController@getItems')->middleware($middleware); + Route::get('view/{id}', 'CollectionController@getCollection')->middleware($middleware); + Route::post('add', 'CollectionController@storeId')->middleware($middleware); + Route::post('update/{id}', 'CollectionController@store')->middleware($middleware); + Route::delete('delete/{id}', 'CollectionController@delete')->middleware($middleware); + Route::post('remove', 'CollectionController@deleteId')->middleware($middleware); + }); + + Route::group(['prefix' => 'compose'], function () use($middleware) { + Route::get('search/location', 'ComposeController@searchLocation')->middleware($middleware); + Route::get('settings', 'ComposeController@composeSettings')->middleware($middleware); + }); + + Route::group(['prefix' => 'direct'], function () use($middleware) { + Route::get('thread', 'DirectMessageController@thread')->middleware($middleware); + Route::post('thread/send', 'DirectMessageController@create')->middleware($middleware); + Route::delete('thread/message', 'DirectMessageController@delete')->middleware($middleware); + Route::post('thread/mute', 'DirectMessageController@mute')->middleware($middleware); + Route::post('thread/unmute', 'DirectMessageController@unmute')->middleware($middleware); + Route::post('thread/media', 'DirectMessageController@mediaUpload')->middleware($middleware); + Route::post('thread/read', 'DirectMessageController@read')->middleware($middleware); + Route::post('lookup', 'DirectMessageController@composeLookup')->middleware($middleware); + }); + + Route::group(['prefix' => 'discover'], function () use($middleware) { + Route::get('accounts/popular', 'Api\ApiV1Controller@discoverAccountsPopular')->middleware($middleware); + Route::get('posts/trending', 'DiscoverController@trendingApi')->middleware($middleware); + Route::get('posts/hashtags', 'DiscoverController@trendingHashtags')->middleware($middleware); + }); + + Route::group(['prefix' => 'directory'], function () use($middleware) { + Route::get('listing', 'PixelfedDirectoryController@get'); + }); + + Route::group(['prefix' => 'places'], function () use($middleware) { + Route::get('posts/{id}/{slug}', 'Api\ApiV1Dot1Controller@placesById')->middleware($middleware); + }); + + Route::get('app/settings', 'UserAppSettingsController@get')->middleware($middleware); + Route::post('app/settings', 'UserAppSettingsController@store')->middleware($middleware); + + Route::group(['prefix' => 'stories'], function () use($middleware) { + Route::get('carousel', 'Stories\StoryApiV1Controller@carousel')->middleware($middleware); + Route::post('add', 'Stories\StoryApiV1Controller@add')->middleware($middleware); + Route::post('publish', 'Stories\StoryApiV1Controller@publish')->middleware($middleware); + Route::post('seen', 'Stories\StoryApiV1Controller@viewed')->middleware($middleware); + Route::post('self-expire/{id}', 'Stories\StoryApiV1Controller@delete')->middleware($middleware); + Route::post('comment', 'Stories\StoryApiV1Controller@comment')->middleware($middleware); + }); + }); + }); }); From 8cc91babd7e867ceeabaa3e4ff077ecbf0a36f98 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 6 Jun 2023 01:56:51 -0600 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d6b874a26..02ca01467 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Update Notifications.vue component, fix filtering logic to prevent endless spinner ([3df9b53f](https://github.com/pixelfed/pixelfed/commit/3df9b53f)) - Update Direct Messages, fix api endpoint ([fe8728c0](https://github.com/pixelfed/pixelfed/commit/fe8728c0)) - Update nginx config ([fbdc6358](https://github.com/pixelfed/pixelfed/commit/fbdc6358)) +- Update api routes, add DeprecatedEndpoint middleware. For more info, visit [pixelfed.org/kb/10404](https://pixelfed.org/kb/10404) ([a8453e77](https://github.com/pixelfed/pixelfed/commit/a8453e77)) - ([](https://github.com/pixelfed/pixelfed/commit/)) ## [v0.11.8 (2023-05-29)](https://github.com/pixelfed/pixelfed/compare/v0.11.7...v0.11.8)