FEATURE: add slow_mode_prevents_editing setting..

..as per https://meta.discourse.org/t/slow-mode-for-a-category/179574/16
This commit is contained in:
mintsaxon 2021-06-27 02:09:53 +02:00 committed by Robin Ward
parent 04baca593b
commit 7d0d13c32e
4 changed files with 13 additions and 1 deletions

View File

@ -1980,6 +1980,7 @@ en:
reviewable_low_priority_threshold: "The priority filter hides reviewable items that don't meet this score unless the '(any)' filter is used." reviewable_low_priority_threshold: "The priority filter hides reviewable items that don't meet this score unless the '(any)' filter is used."
high_trust_flaggers_auto_hide_posts: "New user posts are automatically hidden after being flagged as spam by a TL3+ user" high_trust_flaggers_auto_hide_posts: "New user posts are automatically hidden after being flagged as spam by a TL3+ user"
cooldown_hours_until_reflag: "How much time users will have to wait until they are able to reflag a post" cooldown_hours_until_reflag: "How much time users will have to wait until they are able to reflag a post"
slow_mode_prevents_editing: "Does 'Slow Mode' prevent editing, after editing_grace_period?"
reply_by_email_enabled: "Enable replying to topics via email." reply_by_email_enabled: "Enable replying to topics via email."
reply_by_email_address: "Template for reply by email incoming email address, for example: %%{reply_key}@reply.example.com or replies+%%{reply_key}@example.com" reply_by_email_address: "Template for reply by email incoming email address, for example: %%{reply_key}@reply.example.com or replies+%%{reply_key}@example.com"

View File

@ -1731,6 +1731,7 @@ spam:
cooldown_hours_until_reflag: cooldown_hours_until_reflag:
default: 24 default: 24
min: 0 min: 0
slow_mode_prevents_editing: true
reviewable_claiming: reviewable_claiming:
client: true client: true

View File

@ -156,7 +156,7 @@ class PostRevisor
@revised_at = @opts[:revised_at] || Time.now @revised_at = @opts[:revised_at] || Time.now
@last_version_at = @post.last_version_at || Time.now @last_version_at = @post.last_version_at || Time.now
if guardian.affected_by_slow_mode?(@topic) && !ninja_edit? if guardian.affected_by_slow_mode?(@topic) && !ninja_edit? && SiteSetting.slow_mode_prevents_editing
@post.errors.add(:base, I18n.t("cannot_edit_on_slow_mode")) @post.errors.add(:base, I18n.t("cannot_edit_on_slow_mode"))
return false return false
end end

View File

@ -188,6 +188,16 @@ describe PostRevisor do
expect(post.errors).to be_empty expect(post.errors).to be_empty
end end
it 'edits are generally allowed' do
SiteSetting.slow_mode_prevents_editing = false
subject.revise!(post.user, { raw: 'updated body' }, revised_at: post.updated_at + 10.minutes)
post.reload
expect(post.errors).to be_empty
end
it 'staff is allowed to edit posts even if the topic is in slow mode' do it 'staff is allowed to edit posts even if the topic is in slow mode' do
admin = Fabricate(:admin) admin = Fabricate(:admin)
subject.revise!(admin, { raw: 'updated body' }, revised_at: post.updated_at + 10.minutes) subject.revise!(admin, { raw: 'updated body' }, revised_at: post.updated_at + 10.minutes)