1
0
mirror of https://github.com/cydrobolt/polr.git synced 2024-11-09 11:42:28 +01:00

Avoid link counting for unlimited quota

This commit is contained in:
Iuri de Silvio 2017-12-20 20:14:51 -02:00 committed by GitHub
parent 2068eba42b
commit 25094345d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,11 +23,15 @@ class ApiHelper {
$api_quota = env('SETTING_ANON_API_QUOTA') ?: 5;
}
if ($api_quota == -1) {
return false;
}
$links_last_minute = Link::where('is_api', 1)
->where('creator', $username)
->where('created_at', '>=', $last_minute)
->count();
return ($api_quota > -1 && $links_last_minute >= $api_quota);
return $links_last_minute >= $api_quota;
}
}