From c4d38c201f9d24da7336c05ae562ce3e866f4ae4 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 23 Mar 2022 18:11:06 -0600 Subject: [PATCH] Update ApiV1Controller, add apps/verify_credentials endpoint --- app/Http/Controllers/Api/ApiV1Controller.php | 15 +++++++++++++++ routes/api.php | 2 ++ 2 files changed, 17 insertions(+) diff --git a/app/Http/Controllers/Api/ApiV1Controller.php b/app/Http/Controllers/Api/ApiV1Controller.php index e9d8163a7..727c083f3 100644 --- a/app/Http/Controllers/Api/ApiV1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Controller.php @@ -96,6 +96,21 @@ class ApiV1Controller extends Controller return response()->json($res, $code, $headers, JSON_UNESCAPED_SLASHES); } + public function getApp(Request $request) + { + if(!$request->user()) { + return response('', 403); + } + $client = $request->user()->token()->client; + $res = [ + 'name' => $client->name, + 'website' => null, + 'vapid_key' => null + ]; + + return $this->json($res); + } + public function apps(Request $request) { abort_if(!config_cache('pixelfed.oauth_enabled'), 404); diff --git a/routes/api.php b/routes/api.php index fde9963de..159d74718 100644 --- a/routes/api.php +++ b/routes/api.php @@ -21,6 +21,7 @@ Route::group(['prefix' => 'api'], function() use($middleware) { Route::group(['prefix' => 'v1'], function() use($middleware) { Route::post('apps', 'Api\ApiV1Controller@apps'); + Route::get('apps/verify_credentials', 'Api\ApiV1Controller@getApp')->middleware($middleware); Route::get('instance', 'Api\ApiV1Controller@instance'); Route::get('bookmarks', 'Api\ApiV1Controller@bookmarks')->middleware($middleware); @@ -58,6 +59,7 @@ Route::group(['prefix' => 'api'], function() use($middleware) { Route::post('follow_requests/{id}/reject', 'Api\ApiV1Controller@accountFollowRequestReject')->middleware($middleware); Route::get('lists', 'Api\ApiV1Controller@accountLists')->middleware($middleware); Route::post('media', 'Api\ApiV1Controller@mediaUpload')->middleware($middleware); + Route::get('media/{id}', 'Api\ApiV1Controller@mediaGet')->middleware($middleware); Route::put('media/{id}', 'Api\ApiV1Controller@mediaUpdate')->middleware($middleware); Route::get('mutes', 'Api\ApiV1Controller@accountMutes')->middleware($middleware); Route::get('notifications', 'Api\ApiV1Controller@accountNotifications')->middleware($middleware);