mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 06:21:27 +00:00
Add /api/v1/favourites endpoint
This commit is contained in:
parent
fa4e291ad9
commit
b9cc06daa5
2 changed files with 26 additions and 0 deletions
|
@ -649,6 +649,31 @@ class ApiV1Controller extends Controller
|
|||
return response()->json([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/v1/favourites
|
||||
*
|
||||
* Return empty array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function accountFavourites(Request $request)
|
||||
{
|
||||
abort_if(!$request->user(), 403);
|
||||
|
||||
$user = $request->user();
|
||||
|
||||
$limit = $request->input('limit') ?? 20;
|
||||
$favourites = Like::whereProfileId($user->profile_id)
|
||||
->latest()
|
||||
->simplePaginate($limit)
|
||||
->pluck('status_id');
|
||||
|
||||
$statuses = Status::findOrFail($favourites);
|
||||
$resource = new Fractal\Resource\Collection($statuses, new StatusTransformer());
|
||||
$res = $this->fractal->createData($resource)->toArray();
|
||||
return response()->json($res);
|
||||
}
|
||||
|
||||
public function statusById(Request $request, $id)
|
||||
{
|
||||
$status = Status::whereVisibility('public')->findOrFail($id);
|
||||
|
|
|
@ -99,6 +99,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
|
|||
Route::get('endorsements', 'Api\ApiV1Controller@accountEndorsements')->middleware('auth:api');
|
||||
Route::get('blocks', 'Api\ApiV1Controller@accountBlocks')->middleware('auth:api');
|
||||
Route::get('custom_emojis', 'Api\ApiV1Controller@customEmojis');
|
||||
Route::get('favourites', 'Api\ApiV1Controller@accountFavourites')->middleware('auth:api');
|
||||
Route::get('likes', 'ApiController@hydrateLikes');
|
||||
Route::post('media', 'ApiController@uploadMedia')->middleware('auth:api');
|
||||
Route::delete('media', 'ApiController@deleteMedia')->middleware('auth:api');
|
||||
|
|
Loading…
Reference in a new issue