mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 03:10:46 -06:00
Rate limit printing
This commit is contained in:
parent
70c68f0a7c
commit
6faedfa716
@ -3,6 +3,7 @@ require_dependency 'promotion'
|
||||
require_dependency 'url_helper'
|
||||
require_dependency 'topics_bulk_action'
|
||||
require_dependency 'discourse_event'
|
||||
require_dependency 'rate_limiter'
|
||||
|
||||
class TopicsController < ApplicationController
|
||||
before_filter :ensure_logged_in, only: [:timings,
|
||||
@ -68,6 +69,14 @@ class TopicsController < ApplicationController
|
||||
return redirect_to_correct_topic(topic, opts[:post_number]) if topic && topic.visible
|
||||
end
|
||||
|
||||
if opts[:print]
|
||||
begin
|
||||
RateLimiter.new(current_user, "print-topic-per-hour", 10, 1.hour).performed!
|
||||
rescue RateLimiter::LimitExceeded
|
||||
render_json_error(I18n.t("rate_limiter.slow_down"))
|
||||
end
|
||||
end
|
||||
|
||||
begin
|
||||
@topic_view = TopicView.new(params[:id] || params[:topic_id], current_user, opts)
|
||||
rescue Discourse::NotFound
|
||||
|
Loading…
Reference in New Issue
Block a user