diff --git a/app/Http/Controllers/Api/ApiV1Controller.php b/app/Http/Controllers/Api/ApiV1Controller.php index 888f61add..b7929f34c 100644 --- a/app/Http/Controllers/Api/ApiV1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Controller.php @@ -1061,7 +1061,7 @@ class ApiV1Controller extends Controller abort_if( Like::whereProfileId($user->profile_id) ->where('created_at', '>', now()->subDay()) - ->count() >= 100, + ->count() >= Like::MAX_PER_DAY, 429 ); diff --git a/app/Http/Controllers/LikeController.php b/app/Http/Controllers/LikeController.php index 8a56ae0e8..c17b61663 100644 --- a/app/Http/Controllers/LikeController.php +++ b/app/Http/Controllers/LikeController.php @@ -33,6 +33,12 @@ class LikeController extends Controller $like = Like::whereProfileId($profile->id)->whereStatusId($status->id)->firstOrFail(); UnlikePipeline::dispatch($like); } else { + abort_if( + Like::whereProfileId($user->profile_id) + ->where('created_at', '>', now()->subDay()) + ->count() >= Like::MAX_PER_DAY, + 429 + ); $count = $status->likes_count > 4 ? $status->likes_count : $status->likes()->count(); $like = Like::firstOrCreate([ 'profile_id' => $user->profile_id, diff --git a/app/Like.php b/app/Like.php index 8b45b60cb..678ce953f 100644 --- a/app/Like.php +++ b/app/Like.php @@ -9,6 +9,8 @@ class Like extends Model { use SoftDeletes; + const MAX_PER_DAY = 200; + /** * The attributes that should be mutated to dates. *