Update ApiV1Controller, add preferences endpoint

This commit is contained in:
Daniel Supernault 2022-03-24 22:32:16 -06:00
parent df22f2e4b0
commit c3e56b8722
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
2 changed files with 24 additions and 0 deletions

View file

@ -2695,4 +2695,26 @@ class ApiV1Controller extends Controller
return $this->json($ids);
}
/**
* GET /api/v1/preferences
*
*
* @return array
*/
public function getPreferences(Request $request)
{
abort_if(!$request->user(), 403);
$pid = $request->user()->profile_id;
$account = AccountService::get($pid);
return $this->json([
'posting:default:visibility' => $account['locked'] ? 'private' : 'public',
'posting:default:sensitive' => false,
'posting:default:language' => null,
'reading:expand:media' => 'default',
'reading:expand:spoilers' => false
]);
}
}

View file

@ -83,6 +83,8 @@ Route::group(['prefix' => 'api'], function() use($middleware) {
Route::get('timelines/public', 'Api\ApiV1Controller@timelinePublic')->middleware($middleware);
Route::get('timelines/tag/{hashtag}', 'Api\ApiV1Controller@timelineHashtag');
Route::get('discover/posts', 'Api\ApiV1Controller@discoverPosts')->middleware($middleware);
Route::get('preferences', 'Api\ApiV1Controller@getPreferences')->middleware($middleware);
});
Route::group(['prefix' => 'v2'], function() use($middleware) {