FEATURE: add slow_mode_prevents_editing setting..

FEATURE: add slow_mode_prevents_editing setting…

…as per Slow mode for a category - #16 by codinghorror - feature - Discourse Meta

diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index 319b772..61a2eef 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -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."
     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"
+    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_address: "Template for reply by email incoming email address, for example: %%{reply_key}@reply.example.com or replies+%%{reply_key}@example.com"
diff --git a/config/site_settings.yml b/config/site_settings.yml
index c9f957e..6f7bb4d 100644
--- a/config/site_settings.yml
+++ b/config/site_settings.yml
@@ -1731,6 +1731,7 @@ spam:
   cooldown_hours_until_reflag:
     default: 24
     min: 0
+  slow_mode_prevents_editing: true
 
   reviewable_claiming:
     client: true
diff --git a/lib/post_revisor.rb b/lib/post_revisor.rb
index cbd5f71..a96e658 100644
--- a/lib/post_revisor.rb
+++ b/lib/post_revisor.rb
@@ -156,7 +156,7 @@ class PostRevisor
     @revised_at = @opts[:revised_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"))
       return false
     end
diff --git a/spec/components/post_revisor_spec.rb b/spec/components/post_revisor_spec.rb
index 6832e9f..f8a76be 100644
--- a/spec/components/post_revisor_spec.rb
+++ b/spec/components/post_revisor_spec.rb
@@ -188,6 +188,16 @@ describe PostRevisor do
         expect(post.errors).to be_empty
       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
         admin = Fabricate(:admin)
         subject.revise!(admin, { raw: 'updated body' }, revised_at: post.updated_at + 10.minutes)

GitHub sha: 7d0d13c32e5b851d78b75bae26ac5271fb117400

This commit appears in #13534 which was approved by eviltrout. It was merged by eviltrout.