mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-25 17:26:43 +00:00
Update LikeController
This commit is contained in:
parent
f033f84159
commit
7974ad39c9
1 changed files with 1 additions and 5 deletions
|
@ -20,14 +20,12 @@ class LikeController extends Controller
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
'item' => 'required|integer',
|
'item' => 'required|integer|min:1',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$profile = Auth::user()->profile;
|
$profile = Auth::user()->profile;
|
||||||
$status = Status::withCount('likes')->findOrFail($request->input('item'));
|
$status = Status::withCount('likes')->findOrFail($request->input('item'));
|
||||||
|
|
||||||
Cache::forget('transform:status:'.$status->url());
|
|
||||||
|
|
||||||
$count = $status->likes_count;
|
$count = $status->likes_count;
|
||||||
|
|
||||||
if ($status->likes()->whereProfileId($profile->id)->count() !== 0) {
|
if ($status->likes()->whereProfileId($profile->id)->count() !== 0) {
|
||||||
|
@ -48,8 +46,6 @@ class LikeController extends Controller
|
||||||
->take(1000)
|
->take(1000)
|
||||||
->pluck('status_id');
|
->pluck('status_id');
|
||||||
|
|
||||||
Cache::put('api:like-ids:user:'.$profile->id, $likes, now()->addMinutes(1440));
|
|
||||||
|
|
||||||
if ($request->ajax()) {
|
if ($request->ajax()) {
|
||||||
$response = ['code' => 200, 'msg' => 'Like saved', 'count' => $count];
|
$response = ['code' => 200, 'msg' => 'Like saved', 'count' => $count];
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue