mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 09:56:17 +08:00
Merge pull request #4447 from pmusaraj/approve_new_topics_setting
FEATURE: add "Approve new topics unless user level" setting
This commit is contained in:
commit
0f0b657182
|
@ -1348,6 +1348,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"
|
||||
notify_about_queued_posts_after: "If there are posts that have been waiting to be reviewed for more than this many hours, an email will be sent to the contact_email. Set to 0 to disable these emails."
|
||||
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)"
|
||||
|
|
|
@ -550,6 +550,9 @@ posting:
|
|||
approve_unless_trust_level:
|
||||
default: 0
|
||||
enum: 'TrustLevelSetting'
|
||||
approve_new_topics_unless_trust_level:
|
||||
default: 0
|
||||
enum: 'TrustLevelSetting'
|
||||
notify_about_queued_posts_after:
|
||||
default: 24
|
||||
min: 0
|
||||
|
|
|
@ -73,6 +73,7 @@ class NewPostManager
|
|||
|
||||
(user.trust_level <= TrustLevel.levels[:basic] && user.post_count < SiteSetting.approve_post_count) ||
|
||||
(user.trust_level < SiteSetting.approve_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) ||
|
||||
matches_auto_block_regex?(manager)
|
||||
end
|
||||
|
@ -114,6 +115,7 @@ class NewPostManager
|
|||
def self.queue_enabled?
|
||||
SiteSetting.approve_post_count > 0 ||
|
||||
SiteSetting.approve_unless_trust_level.to_i > 0 ||
|
||||
SiteSetting.approve_new_topics_unless_trust_level.to_i > 0 ||
|
||||
handlers.size > 1
|
||||
end
|
||||
|
||||
|
|
|
@ -115,6 +115,31 @@ describe NewPostManager do
|
|||
end
|
||||
end
|
||||
|
||||
context 'with a high trust level setting for new topics but post responds to existing topic' do
|
||||
before do
|
||||
SiteSetting.approve_new_topics_unless_trust_level = 4
|
||||
end
|
||||
it "doesn't return a result action" do
|
||||
result = NewPostManager.default_handler(manager)
|
||||
expect(result).to eq(nil)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "new topic handler" do
|
||||
let(:manager) { NewPostManager.new(topic.user, raw: 'this is new topic content', title: 'new topic title') }
|
||||
context 'with a high trust level setting for new topics' do
|
||||
before do
|
||||
SiteSetting.approve_new_topics_unless_trust_level = 4
|
||||
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
|
||||
|
||||
end
|
||||
|
||||
context "extensibility priority" do
|
||||
|
|
Loading…
Reference in New Issue
Block a user