mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 04:03:57 -06:00
FIX: Don't expire ratelimits at midnight server time
This commit is contained in:
parent
ca915e8ad7
commit
3c035dce7c
@ -190,7 +190,7 @@ class Invite < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def limit_invites_per_day
|
||||
RateLimiter.new(invited_by, "invites-per-day:#{Date.today}", SiteSetting.max_invites_per_day, 1.day.to_i)
|
||||
RateLimiter.new(invited_by, "invites-per-day", SiteSetting.max_invites_per_day, 1.day.to_i)
|
||||
end
|
||||
|
||||
def self.base_directory
|
||||
|
@ -88,7 +88,7 @@ class Post < ActiveRecord::Base
|
||||
|
||||
def limit_posts_per_day
|
||||
if user.created_at > 1.day.ago && post_number > 1
|
||||
RateLimiter.new(user, "first-day-replies-per-day:#{Date.today}", SiteSetting.max_replies_in_first_day, 1.day.to_i)
|
||||
RateLimiter.new(user, "first-day-replies-per-day", SiteSetting.max_replies_in_first_day, 1.day.to_i)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -320,7 +320,7 @@ class PostAction < ActiveRecord::Base
|
||||
|
||||
%w(like flag bookmark).each do |type|
|
||||
if send("is_#{type}?")
|
||||
@rate_limiter = RateLimiter.new(user, "create_#{type}:#{Date.today}", SiteSetting.send("max_#{type}s_per_day"), 1.day.to_i)
|
||||
@rate_limiter = RateLimiter.new(user, "create_#{type}", SiteSetting.send("max_#{type}s_per_day"), 1.day.to_i)
|
||||
return @rate_limiter
|
||||
end
|
||||
end
|
||||
|
@ -812,7 +812,7 @@ class Topic < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def apply_per_day_rate_limit_for(key, method_name)
|
||||
RateLimiter.new(user, "#{key}-per-day:#{Date.today}", SiteSetting.send(method_name), 1.day.to_i)
|
||||
RateLimiter.new(user, "#{key}-per-day", SiteSetting.send(method_name), 1.day.to_i)
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user