mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 14:31:26 +00:00
Add missing bookmark api endpoints
This commit is contained in:
parent
d398230b27
commit
c74cd0bdf0
2 changed files with 55 additions and 0 deletions
|
@ -1901,6 +1901,59 @@ class ApiV1Controller extends Controller
|
||||||
return response()->json($res, 200, [], JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
|
return response()->json($res, 200, [], JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* POST /api/v1/statuses/{id}/bookmark
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return StatusTransformer
|
||||||
|
*/
|
||||||
|
public function bookmarkStatus(Request $request, $id)
|
||||||
|
{
|
||||||
|
abort_if(!$request->user(), 403);
|
||||||
|
|
||||||
|
$status = Status::whereNull('uri')
|
||||||
|
->whereScope('public')
|
||||||
|
->findOrFail($id);
|
||||||
|
|
||||||
|
Bookmark::firstOrCreate([
|
||||||
|
'status_id' => $status->id,
|
||||||
|
'profile_id' => $request->user()->profile_id
|
||||||
|
]);
|
||||||
|
$resource = new Fractal\Resource\Item($status, new StatusTransformer());
|
||||||
|
$res = $this->fractal->createData($resource)->toArray();
|
||||||
|
return response()->json($res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* POST /api/v1/statuses/{id}/unbookmark
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return StatusTransformer
|
||||||
|
*/
|
||||||
|
public function unbookmarkStatus(Request $request, $id)
|
||||||
|
{
|
||||||
|
abort_if(!$request->user(), 403);
|
||||||
|
|
||||||
|
$status = Status::whereNull('uri')
|
||||||
|
->whereScope('public')
|
||||||
|
->findOrFail($id);
|
||||||
|
|
||||||
|
Bookmark::firstOrCreate([
|
||||||
|
'status_id' => $status->id,
|
||||||
|
'profile_id' => $request->user()->profile_id
|
||||||
|
]);
|
||||||
|
$bookmark = Bookmark::whereStatusId($status->id)
|
||||||
|
->whereProfileId($request->user()->profile_id)
|
||||||
|
->firstOrFail();
|
||||||
|
$bookmark->delete();
|
||||||
|
|
||||||
|
$resource = new Fractal\Resource\Item($status, new StatusTransformer());
|
||||||
|
$res = $this->fractal->createData($resource)->toArray();
|
||||||
|
return response()->json($res);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GET /api/v2/search
|
* GET /api/v2/search
|
||||||
*
|
*
|
||||||
|
|
|
@ -60,6 +60,8 @@ Route::group(['prefix' => 'api'], function() use($middleware) {
|
||||||
Route::get('statuses/{id}/favourited_by', 'Api\ApiV1Controller@statusFavouritedBy')->middleware($middleware);
|
Route::get('statuses/{id}/favourited_by', 'Api\ApiV1Controller@statusFavouritedBy')->middleware($middleware);
|
||||||
Route::post('statuses/{id}/reblog', 'Api\ApiV1Controller@statusShare')->middleware($middleware);
|
Route::post('statuses/{id}/reblog', 'Api\ApiV1Controller@statusShare')->middleware($middleware);
|
||||||
Route::post('statuses/{id}/unreblog', 'Api\ApiV1Controller@statusUnshare')->middleware($middleware);
|
Route::post('statuses/{id}/unreblog', 'Api\ApiV1Controller@statusUnshare')->middleware($middleware);
|
||||||
|
Route::post('statuses/{id}/bookmark', 'Api\ApiV1Controller@bookmarkStatus')->middleware($middleware);
|
||||||
|
Route::post('statuses/{id}/unbookmark', 'Api\ApiV1Controller@unbookmarkStatus')->middleware($middleware);
|
||||||
Route::delete('statuses/{id}', 'Api\ApiV1Controller@statusDelete')->middleware($middleware);
|
Route::delete('statuses/{id}', 'Api\ApiV1Controller@statusDelete')->middleware($middleware);
|
||||||
Route::get('statuses/{id}', 'Api\ApiV1Controller@statusById')->middleware($middleware);
|
Route::get('statuses/{id}', 'Api\ApiV1Controller@statusById')->middleware($middleware);
|
||||||
Route::post('statuses', 'Api\ApiV1Controller@statusCreate')->middleware($middleware)->middleware('throttle:maxPostsPerHour,60')->middleware('throttle:maxPostsPerDay,1440');
|
Route::post('statuses', 'Api\ApiV1Controller@statusCreate')->middleware($middleware)->middleware('throttle:maxPostsPerHour,60')->middleware('throttle:maxPostsPerDay,1440');
|
||||||
|
|
Loading…
Reference in a new issue