Add /api/v1/statuses/{id}/card endpoint

This commit is contained in:
Daniel Supernault 2019-09-26 23:19:57 -06:00
parent db3b873a50
commit 9225120835
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
3 changed files with 56 additions and 12 deletions

View file

@ -927,7 +927,7 @@ class ApiV1Controller extends Controller
* POST /api/v1/media
*
*
* @return App\Transformer\Api\MediaTransformer
* @return MediaTransformer
*/
public function mediaUpload(Request $request)
{
@ -1011,7 +1011,7 @@ class ApiV1Controller extends Controller
*
* @param integer $id
*
* @return App\Transformer\Api\MediaTransformer
* @return MediaTransformer
*/
public function mediaUpdate(Request $request, $id)
{
@ -1041,7 +1041,7 @@ class ApiV1Controller extends Controller
* GET /api/v1/mutes
*
*
* @return App\Transformer\Api\AccountTransformer
* @return AccountTransformer
*/
public function accountMutes(Request $request)
{
@ -1072,7 +1072,7 @@ class ApiV1Controller extends Controller
*
* @param integer $id
*
* @return App\Transformer\Api\RelationshipTransformer
* @return RelationshipTransformer
*/
public function accountMuteById(Request $request, $id)
{
@ -1104,7 +1104,7 @@ class ApiV1Controller extends Controller
*
* @param integer $id
*
* @return App\Transformer\Api\RelationshipTransformer
* @return RelationshipTransformer
*/
public function accountUnmuteById(Request $request, $id)
{
@ -1137,7 +1137,7 @@ class ApiV1Controller extends Controller
* GET /api/v1/notifications
*
*
* @return App\Transformer\Api\NotificationTransformer
* @return NotificationTransformer
*/
public function accountNotifications(Request $request)
{
@ -1177,7 +1177,7 @@ class ApiV1Controller extends Controller
* GET /api/v1/timelines/home
*
*
* @return App\Transformer\Api\StatusTransformer
* @return StatusTransformer
*/
public function timelineHome(Request $request)
{
@ -1279,7 +1279,7 @@ class ApiV1Controller extends Controller
* GET /api/v1/timelines/public
*
*
* @return App\Transformer\Api\StatusTransformer
* @return StatusTransformer
*/
public function timelinePublic(Request $request)
{
@ -1354,8 +1354,17 @@ class ApiV1Controller extends Controller
return response()->json($res);
}
/**
* GET /api/v1/statuses/{id}
*
* @param integer $id
*
* @return StatusTransformer
*/
public function statusById(Request $request, $id)
{
abort_if(!$request->user(), 403);
$status = Status::whereVisibility('public')->findOrFail($id);
$resource = new Fractal\Resource\Item($status, new StatusTransformer());
$res = $this->fractal->createData($resource)->toArray();
@ -1363,9 +1372,42 @@ class ApiV1Controller extends Controller
return response()->json($res);
}
public function context(Request $request)
/**
* GET /api/v1/statuses/{id}/context
*
* @param integer $id
*
* @return StatusTransformer
*/
public function statusContext(Request $request, $id)
{
// todo
abort_if(!$request->user(), 403);
$status = Status::whereVisibility('public')->findOrFail($id);
// Return empty response since we don't handle threading like this
$res = [
'ancestors' => [],
'descendants' => []
];
return response()->json($res);
}
/**
* GET /api/v1/statuses/{id}/card
*
* @param integer $id
*
* @return StatusTransformer
*/
public function statusCard(Request $request, $id)
{
abort_if(!$request->user(), 403);
$status = Status::whereVisibility('public')->findOrFail($id);
// Return empty response since we don't handle threading like this
$res = [
'ancestors' => [],
'descendants' => []

View file

@ -9,7 +9,5 @@ Route::group(['prefix' => 'api'], function() {
Route::group(['prefix' => 'v1'], function() {
Route::post('apps', 'Api\ApiV1Controller@apps');
Route::get('instance', 'Api\ApiV1Controller@instance');
Route::get('statuses/{id}', 'Api\ApiV1Controller@statusById');
Route::get('statuses/{id}/context', 'Api\ApiV1Controller@context');
});
});

View file

@ -116,6 +116,10 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
Route::post('accounts/{id}/unmute', 'Api\ApiV1Controller@accountUnmuteById')->middleware('auth:api');
Route::get('notifications', 'Api\ApiV1Controller@accountNotifications')->middleware('auth:api');
Route::get('statuses/{id}', 'Api\ApiV1Controller@statusById')->middleware('auth:api');
Route::get('statuses/{id}/context', 'Api\ApiV1Controller@statusContext')->middleware('auth:api');
Route::get('statuses/{id}/card', 'Api\ApiV1Controller@statusCard')->middleware('auth:api');
Route::get('timelines/home', 'Api\ApiV1Controller@timelineHome')->middleware('auth:api');
Route::get('conversations', 'Api\ApiV1Controller@conversations')->middleware('auth:api');
Route::get('timelines/public', 'Api\ApiV1Controller@timelinePublic');