mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 07:53:49 +08:00
FEATURE: Warn a user when they have few likes remaining
This commit is contained in:
@ -67,6 +67,15 @@ class RateLimiter
|
||||
$redis.lpop(@key)
|
||||
end
|
||||
|
||||
def remaining
|
||||
return @max if @user && @user.staff?
|
||||
|
||||
arr = $redis.lrange(@key, 0, @max) || []
|
||||
t0 = Time.now.to_i
|
||||
arr.reject! {|a| (t0 - a.to_i) > @secs}
|
||||
@max - arr.size
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def seconds_to_wait
|
||||
|
Reference in New Issue
Block a user