A platform for community discussion. Free, open, simple.
FEATURE: Staged user moderation (#5721)
jose-hmsb87205831bf3
diff --git a/config/locales/server.en.yml b/config/locales/server.en.ymlindex ab60927d016..caddf1ab807 100644--- a/config/locales/server.en.yml+++ b/config/locales/server.en.yml@@ -1596,6 +1596,7 @@ en:approve_post_count: "The amount of posts from a new or basic user that must be approved"approve_unless_trust_level: "Posts for users below this trust level must be approved"approve_new_topics_unless_trust_level: "New topics for users below this trust level must be approved"+ approve_unless_staged: "New topics and posts for staged users must be approved"notify_about_queued_posts_after: "If there are posts that have been waiting to be reviewed for more than this many hours, send a notification to all moderators. Set to 0 to disable these notifications."auto_close_messages_post_count: "Maximum number of posts allowed in a message before it is automatically closed (0 to disable)"auto_close_topics_post_count: "Maximum number of posts allowed in a topic before it is automatically closed (0 to disable)"diff --git a/config/site_settings.yml b/config/site_settings.ymlindex 3c94c326eae..2521003002f 100644--- a/config/site_settings.yml+++ b/config/site_settings.yml@@ -646,6 +646,8 @@ posting:approve_new_topics_unless_trust_level:default: 0enum: 'TrustLevelSetting'+ approve_unless_staged:+ default: falsenotify_about_queued_posts_after:default: 24auto_close_messages_post_count: 500diff --git a/lib/new_post_manager.rb b/lib/new_post_manager.rbindex 8eb03d32b6e..b6965bc221e 100644--- a/lib/new_post_manager.rb+++ b/lib/new_post_manager.rb@@ -68,7 +68,7 @@ class NewPostManagerenddef self.exempt_user?(user)- user.staff? || user.staged+ user.staff?enddef self.post_needs_approval?(manager)@@ -81,7 +81,8 @@ class NewPostManager(manager.args[:title].present? && user.trust_level < SiteSetting.approve_new_topics_unless_trust_level.to_i) ||is_fast_typer?(manager) ||matches_auto_silence_regex?(manager) ||- WordWatcher.new("#{manager.args[:title]} #{manager.args[:raw]}").requires_approval?+ WordWatcher.new("#{manager.args[:title]} #{manager.args[:raw]}").requires_approval? ||+ (SiteSetting.approve_unless_staged && user.staged)enddef self.default_handler(manager)@@ -123,6 +124,7 @@ class NewPostManagerSiteSetting.approve_post_count > 0 ||SiteSetting.approve_unless_trust_level.to_i > 0 ||SiteSetting.approve_new_topics_unless_trust_level.to_i > 0 ||+ SiteSetting.approve_unless_staged ||WordWatcher.words_for_action_exists?(:require_approval) ||handlers.size > 1enddiff --git a/spec/components/new_post_manager_spec.rb b/spec/components/new_post_manager_spec.rbindex 65aee5054f0..22218a67dc5 100644--- a/spec/components/new_post_manager_spec.rb+++ b/spec/components/new_post_manager_spec.rb@@ -115,6 +115,18 @@ describe NewPostManager doendend+ context 'with staged moderation setting enabled' do+ before do+ SiteSetting.approve_unless_staged = true+ topic.user.staged = true+ end+ it "will return an enqueue result" do+ result = NewPostManager.default_handler(manager)+ expect(NewPostManager.queue_enabled?).to eq(true)+ expect(result.action).to eq(:enqueued)+ end+ end+context 'with a high trust level setting for new topics but post responds to existing topic' dobefore doSiteSetting.approve_new_topics_unless_trust_level = 4