2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-02-09 23:33:07 +08:00
|
|
|
require "rate_limiter"
|
|
|
|
class EditRateLimiter < RateLimiter
|
|
|
|
def initialize(user)
|
2021-05-19 17:57:21 +08: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-25 01:52:32 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def build_key(type)
|
|
|
|
"#{super(type)}:#{Date.today}"
|
2013-02-09 23:33:07 +08:00
|
|
|
end
|
|
|
|
end
|