summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
9d47ad5)
Name is chosen to match the equivalent setting in the configuration
of the rate limits for edits.
Fixes #4427.
if moderator?
Settings.moderator_changeset_comments_per_hour
else
if moderator?
Settings.moderator_changeset_comments_per_hour
else
- previous_comments = changeset_comments.limit(200).count
- max_comments = previous_comments / 200.0 * Settings.max_changeset_comments_per_hour
+ previous_comments = changeset_comments.limit(Settings.comments_to_max_changeset_comments).count
+ max_comments = previous_comments / Settings.comments_to_max_changeset_comments.to_f * Settings.max_changeset_comments_per_hour
max_comments = max_comments.floor.clamp(Settings.initial_changeset_comments_per_hour, Settings.max_changeset_comments_per_hour)
max_comments /= 2**active_reports
max_comments.floor.clamp(Settings.min_changeset_comments_per_hour, Settings.max_changeset_comments_per_hour)
max_comments = max_comments.floor.clamp(Settings.initial_changeset_comments_per_hour, Settings.max_changeset_comments_per_hour)
max_comments /= 2**active_reports
max_comments.floor.clamp(Settings.min_changeset_comments_per_hour, Settings.max_changeset_comments_per_hour)
min_changeset_comments_per_hour: 1
initial_changeset_comments_per_hour: 6
max_changeset_comments_per_hour: 60
min_changeset_comments_per_hour: 1
initial_changeset_comments_per_hour: 6
max_changeset_comments_per_hour: 60
+comments_to_max_changeset_comments: 200
moderator_changeset_comments_per_hour: 36000
# Rate limit for changes
min_changes_per_hour: 100
moderator_changeset_comments_per_hour: 36000
# Rate limit for changes
min_changes_per_hour: 100
trace_icon_storage: "test"
# Lower some rate limits for testing
max_changeset_comments_per_hour: 10
trace_icon_storage: "test"
# Lower some rate limits for testing
max_changeset_comments_per_hour: 10
+comments_to_max_changeset_comments: 20
moderator_changeset_comments_per_hour: 15
# Private key for signing id_tokens
doorkeeper_signing_key: |
moderator_changeset_comments_per_hour: 15
# Private key for signing id_tokens
doorkeeper_signing_key: |
def test_create_comment_experienced_user_rate_limit
changeset = create(:changeset, :closed)
user = create(:user)
def test_create_comment_experienced_user_rate_limit
changeset = create(:changeset, :closed)
user = create(:user)
- create_list(:changeset_comment, 200, :author_id => user.id, :created_at => Time.now.utc - 1.day)
+ create_list(:changeset_comment, Settings.comments_to_max_changeset_comments, :author_id => user.id, :created_at => Time.now.utc - 1.day)
auth_header = bearer_authorization_header user
auth_header = bearer_authorization_header user