FEATURE: Staged user moderation (#5721)

This commit is contained in:
jose-hms 2018-04-06 05:41:25 -04:00 committed by Gerhard Schlager
parent fa7ddf7238
commit b87205831b
4 changed files with 19 additions and 2 deletions

View File

@ -1596,6 +1596,7 @@ en:
approve_post_count: "The amount of posts from a new or basic user that must be approved" 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_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_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." 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_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)" auto_close_topics_post_count: "Maximum number of posts allowed in a topic before it is automatically closed (0 to disable)"

View File

@ -646,6 +646,8 @@ posting:
approve_new_topics_unless_trust_level: approve_new_topics_unless_trust_level:
default: 0 default: 0
enum: 'TrustLevelSetting' enum: 'TrustLevelSetting'
approve_unless_staged:
default: false
notify_about_queued_posts_after: notify_about_queued_posts_after:
default: 24 default: 24
auto_close_messages_post_count: 500 auto_close_messages_post_count: 500

View File

@ -68,7 +68,7 @@ class NewPostManager
end end
def self.exempt_user?(user) def self.exempt_user?(user)
user.staff? || user.staged user.staff?
end end
def self.post_needs_approval?(manager) def 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) || (manager.args[:title].present? && user.trust_level < SiteSetting.approve_new_topics_unless_trust_level.to_i) ||
is_fast_typer?(manager) || is_fast_typer?(manager) ||
matches_auto_silence_regex?(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)
end end
def self.default_handler(manager) def self.default_handler(manager)
@ -123,6 +124,7 @@ class NewPostManager
SiteSetting.approve_post_count > 0 || SiteSetting.approve_post_count > 0 ||
SiteSetting.approve_unless_trust_level.to_i > 0 || SiteSetting.approve_unless_trust_level.to_i > 0 ||
SiteSetting.approve_new_topics_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) || WordWatcher.words_for_action_exists?(:require_approval) ||
handlers.size > 1 handlers.size > 1
end end

View File

@ -115,6 +115,18 @@ describe NewPostManager do
end end
end end
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' do context 'with a high trust level setting for new topics but post responds to existing topic' do
before do before do
SiteSetting.approve_new_topics_unless_trust_level = 4 SiteSetting.approve_new_topics_unless_trust_level = 4