FEATURE: add site settings rate_limit_new_user_create_topic and rate_limit_new_user_create_post to have different rate limits for topic and post creation for new users
This commit is contained in:
parent
6412958d1e
commit
4f6d5d9215
|
@ -796,6 +796,8 @@ en:
|
|||
|
||||
rate_limit_create_topic: "After creating a topic, users must wait (n) seconds before creating another topic."
|
||||
rate_limit_create_post: "After posting, users must wait (n) seconds before creating another post."
|
||||
rate_limit_new_user_create_topic: "After creating a topic, new users must wait (n) seconds before creating another topic."
|
||||
rate_limit_new_user_create_post: "After posting, new users must wait (n) seconds before creating another post."
|
||||
|
||||
max_likes_per_day: "Maximum number of likes per user per day."
|
||||
max_flags_per_day: "Maximum number of flags per user per day."
|
||||
|
|
|
@ -543,6 +543,8 @@ rate_limits:
|
|||
default: 5
|
||||
rate_limit_create_topic: 15
|
||||
rate_limit_create_post: 5
|
||||
rate_limit_new_user_create_topic: 60
|
||||
rate_limit_new_user_create_post: 30
|
||||
max_topics_per_day: 20
|
||||
max_private_messages_per_day: 20
|
||||
max_likes_per_day: 50
|
||||
|
|
|
@ -13,7 +13,11 @@ class RateLimiter
|
|||
return @rate_limiter if @rate_limiter.present?
|
||||
|
||||
limit_key = "create_#{self.class.name.underscore}"
|
||||
max_setting = SiteSetting.send("rate_limit_#{limit_key}")
|
||||
max_setting = if user.new_user? and SiteSetting.has_setting?("rate_limit_new_user_#{limit_key}")
|
||||
SiteSetting.send("rate_limit_new_user_#{limit_key}")
|
||||
else
|
||||
SiteSetting.send("rate_limit_#{limit_key}")
|
||||
end
|
||||
@rate_limiter = RateLimiter.new(user, limit_key, 1, max_setting)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue