From d339b5c251586a558934e2d7a817b419360387a1 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 11 Jun 2024 23:35:39 -0600 Subject: [PATCH] Update AccountService --- app/Http/Controllers/Api/ApiV1Controller.php | 5 ++--- app/Services/AccountService.php | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/Api/ApiV1Controller.php b/app/Http/Controllers/Api/ApiV1Controller.php index f42fa4f3f..83451b74b 100644 --- a/app/Http/Controllers/Api/ApiV1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Controller.php @@ -3403,10 +3403,9 @@ class ApiV1Controller extends Controller $limitKey = 'compose:rate-limit:store:'.$user->id; $limitTtl = now()->addMinutes(15); $limitReached = Cache::remember($limitKey, $limitTtl, function () use ($user) { + $minId = SnowflakeService::byDate(now()->subDays(1)); $dailyLimit = Status::whereProfileId($user->profile_id) - ->whereNull('in_reply_to_id') - ->whereNull('reblog_of_id') - ->where('created_at', '>', now()->subDays(1)) + ->where('id', '>', $minId) ->count(); return $dailyLimit >= 1000; diff --git a/app/Services/AccountService.php b/app/Services/AccountService.php index 8490ad0ab..c22226030 100644 --- a/app/Services/AccountService.php +++ b/app/Services/AccountService.php @@ -202,15 +202,14 @@ class AccountService } $count = Status::whereProfileId($id) - ->whereNull('in_reply_to_id') - ->whereNull('reblog_of_id') + ->whereNull(['in_reply_to_id','reblog_of_id']) ->whereIn('scope', ['public', 'unlisted', 'private']) ->count(); $profile->status_count = $count; $profile->save(); - Cache::put($key, 1, 900); + Cache::put($key, 1, 259200); return true; }