diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 91fc149a3..8ed987852 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -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." diff --git a/config/site_settings.yml b/config/site_settings.yml index 823c56d96..255baac5e 100644 --- a/config/site_settings.yml +++ b/config/site_settings.yml @@ -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 diff --git a/lib/rate_limiter/on_create_record.rb b/lib/rate_limiter/on_create_record.rb index be25f3e15..764aae73a 100644 --- a/lib/rate_limiter/on_create_record.rb +++ b/lib/rate_limiter/on_create_record.rb @@ -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