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

Merge branch 'patch-1' of https://github.com/iurisilvio/polr into iurisilvio-api_quota_index

This commit is contained in:
Chaoyi Zha 2018-01-07 22:32:09 -05:00
commit 216f0c75c0

View File

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