Update ApiV1Controller, add apps/verify_credentials endpoint

This commit is contained in:
Daniel Supernault 2022-03-23 18:11:06 -06:00
parent ad475c1f60
commit c4d38c201f
No known key found for this signature in database
GPG Key ID: 0DEF1C662C9033F7
2 changed files with 17 additions and 0 deletions

View File

@ -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);

View File

@ -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);