Merge pull request #5172 from pixelfed/staging

Update AccountService
This commit is contained in:
daniel 2024-06-11 23:36:05 -06:00 committed by GitHub
commit f89da82dbc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 6 deletions

View File

@ -3403,10 +3403,9 @@ class ApiV1Controller extends Controller
$limitKey = 'compose:rate-limit:store:'.$user->id; $limitKey = 'compose:rate-limit:store:'.$user->id;
$limitTtl = now()->addMinutes(15); $limitTtl = now()->addMinutes(15);
$limitReached = Cache::remember($limitKey, $limitTtl, function () use ($user) { $limitReached = Cache::remember($limitKey, $limitTtl, function () use ($user) {
$minId = SnowflakeService::byDate(now()->subDays(1));
$dailyLimit = Status::whereProfileId($user->profile_id) $dailyLimit = Status::whereProfileId($user->profile_id)
->whereNull('in_reply_to_id') ->where('id', '>', $minId)
->whereNull('reblog_of_id')
->where('created_at', '>', now()->subDays(1))
->count(); ->count();
return $dailyLimit >= 1000; return $dailyLimit >= 1000;

View File

@ -202,15 +202,14 @@ class AccountService
} }
$count = Status::whereProfileId($id) $count = Status::whereProfileId($id)
->whereNull('in_reply_to_id') ->whereNull(['in_reply_to_id','reblog_of_id'])
->whereNull('reblog_of_id')
->whereIn('scope', ['public', 'unlisted', 'private']) ->whereIn('scope', ['public', 'unlisted', 'private'])
->count(); ->count();
$profile->status_count = $count; $profile->status_count = $count;
$profile->save(); $profile->save();
Cache::put($key, 1, 900); Cache::put($key, 1, 259200);
return true; return true;
} }