2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-02-09 10:33:07 -05:00
|
|
|
require "rate_limiter"
|
|
|
|
class EditRateLimiter < RateLimiter
|
|
|
|
def initialize(user)
|
2021-05-19 05:57:21 -04:00
|
|
|
limit = SiteSetting.max_edits_per_day
|
|
|
|
|
|
|
|
if user.trust_level >= 2
|
|
|
|
multiplier = SiteSetting.get("tl#{user.trust_level}_additional_edits_per_day_multiplier").to_f
|
|
|
|
multiplier = 1.0 if multiplier < 1.0
|
|
|
|
limit = (limit * multiplier).to_i
|
|
|
|
end
|
|
|
|
|
|
|
|
super(user, "edit-post", limit, 1.day.to_i)
|
2015-09-24 13:52:32 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def build_key(type)
|
|
|
|
"#{super(type)}:#{Date.today}"
|
2013-02-09 10:33:07 -05:00
|
|
|
end
|
|
|
|
end
|