forked from mirror/pixelfed
Add /api/v1/statuses/{id}/unreblog endpoint
This commit is contained in:
parent
43cef28296
commit
3147fe5ca3
2 changed files with 28 additions and 1 deletions
|
@ -1607,7 +1607,33 @@ class ApiV1Controller extends Controller
|
||||||
SharePipeline::dispatch($share);
|
SharePipeline::dispatch($share);
|
||||||
}
|
}
|
||||||
|
|
||||||
$resource = new Fractal\Resource\Item($share, new StatusTransformer());
|
$resource = new Fractal\Resource\Item($status, new StatusTransformer());
|
||||||
|
$res = $this->fractal->createData($resource)->toArray();
|
||||||
|
return response()->json($res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* POST /api/v1/statuses/{id}/unreblog
|
||||||
|
*
|
||||||
|
* @param integer $id
|
||||||
|
*
|
||||||
|
* @return StatusTransformer
|
||||||
|
*/
|
||||||
|
public function statusUnshare(Request $request, $id)
|
||||||
|
{
|
||||||
|
abort_if(!$request->user(), 403);
|
||||||
|
|
||||||
|
$user = $request->user();
|
||||||
|
$status = Status::findOrFail($id);
|
||||||
|
|
||||||
|
Status::whereProfileId($user->profile_id)
|
||||||
|
->whereReblogOfId($status->id)
|
||||||
|
->delete();
|
||||||
|
$count = $status->reblogs_count;
|
||||||
|
$status->reblogs_count = $count > 0 ? $count - 1 : 0;
|
||||||
|
$status->save();
|
||||||
|
|
||||||
|
$resource = new Fractal\Resource\Item($status, new StatusTransformer());
|
||||||
$res = $this->fractal->createData($resource)->toArray();
|
$res = $this->fractal->createData($resource)->toArray();
|
||||||
return response()->json($res);
|
return response()->json($res);
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,6 +128,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
|
||||||
Route::post('statuses', 'Api\ApiV1Controller@statusCreate')->middleware('auth:api');
|
Route::post('statuses', 'Api\ApiV1Controller@statusCreate')->middleware('auth:api');
|
||||||
Route::delete('statuses/{id}', 'Api\ApiV1Controller@statusDelete')->middleware('auth:api');
|
Route::delete('statuses/{id}', 'Api\ApiV1Controller@statusDelete')->middleware('auth:api');
|
||||||
Route::post('statuses/{id}/reblog', 'Api\ApiV1Controller@statusShare')->middleware('auth:api');
|
Route::post('statuses/{id}/reblog', 'Api\ApiV1Controller@statusShare')->middleware('auth:api');
|
||||||
|
Route::post('statuses/{id}/unreblog', 'Api\ApiV1Controller@statusUnshare')->middleware('auth:api');
|
||||||
|
|
||||||
// Route::get('likes', 'ApiController@hydrateLikes');
|
// Route::get('likes', 'ApiController@hydrateLikes');
|
||||||
// Route::post('media', 'ApiController@uploadMedia')->middleware('auth:api');
|
// Route::post('media', 'ApiController@uploadMedia')->middleware('auth:api');
|
||||||
|
|
Loading…
Reference in a new issue