Skip to content

Commit

Permalink
Merge branch 'patch-1' of https://github.com/iurisilvio/polr into iur…
Browse files Browse the repository at this point in the history
…isilvio-api_quota_index
  • Loading branch information
cydrobolt committed Jan 8, 2018
2 parents 9e4ad61 + 5b48ab3 commit 216f0c7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/Helpers/ApiHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ public static function checkUserApiQuota($username) {
$api_quota = env('SETTING_ANON_API_QUOTA') ?: 5;
}

if ($api_quota < 0) {
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;
}
}

0 comments on commit 216f0c7

Please sign in to comment.