Skip to content

Commit

Permalink
Update ApiV1Controller, add preferences endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
dansup committed Mar 25, 2022
1 parent df22f2e commit c3e56b8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
22 changes: 22 additions & 0 deletions app/Http/Controllers/Api/ApiV1Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -2695,4 +2695,26 @@ public function discoverAccountsPopular(Request $request)

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
]);
}
}
2 changes: 2 additions & 0 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@
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) {
Expand Down

0 comments on commit c3e56b8

Please sign in to comment.