Skip to content

A platform for community discussion. Free, open, simple.

FIX: rate limiter text is confusing, should not say daily

Sam38f4acd55a3d
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 2ec9882e3a3..2d468017c2a 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -107,7 +107,7 @@ class ApplicationController < ActionController::Base
end
def render_rate_limit_error(e)
- render_json_error e.description, type: :rate_limit, status: 429
+ render_json_error e.description, type: :rate_limit, status: 429, extras: { wait_seconds: e&.available_in }
end
# If they hit the rate limiter
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index d5ef33a877f..27e31c7540f 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -538,7 +538,7 @@ en:
rate_limiter:
slow_down: "You have performed this action too many times, try again later."
- too_many_requests: "We have a daily limit on how many times that action can be taken. Please wait %{time_left} before trying again."
+ too_many_requests: "You have performed this action too many times. Please wait %{time_left} before trying again."
by_type:
first_day_replies_per_day: "You've reached the maximum number of replies a new user can create on their first day. Please wait %{time_left} before trying again."
first_day_topics_per_day: "You've reached the maximum number of topics a new user can create on their first day. Please wait %{time_left} before trying again."
diff --git a/spec/integration/rate_limiting_spec.rb b/spec/integration/rate_limiting_spec.rb
index b1cc23afce8..93ad7bc53a9 100644
--- a/spec/integration/rate_limiting_spec.rb
+++ b/spec/integration/rate_limiting_spec.rb
@@ -26,6 +26,7 @@ describe 'rate limiter integration' do
end
it 'can cleanly limit requests' do
+ freeze_time
#request.set_header("action_dispatch.show_exceptions", true)
admin = Fabricate(:admin)
@@ -46,5 +47,9 @@ describe 'rate limiter integration' do
}
expect(response.status).to eq(429)
+
+ data = JSON.parse(response.body)
+
+ expect(data["extras"]["wait_seconds"]).to eq(60)
end
end