mirror of
https://github.com/discourse/discourse.git
synced 2025-09-05 08:59:27 +08:00
FEATURE: Warn a user when they have few likes remaining
This commit is contained in:
parent
1fba835d4f
commit
5d4ee2ca1d
9 changed files with 75 additions and 17 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue