mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 15:06:26 +08:00
Site Settings for post approval
This commit is contained in:
parent
0c233e4e25
commit
af1571a58f
|
@ -1139,6 +1139,9 @@ en:
|
||||||
emoji_set: "How would you like your emoji?"
|
emoji_set: "How would you like your emoji?"
|
||||||
enforce_square_emoji: "Force a square aspect ratio to all emojis."
|
enforce_square_emoji: "Force a square aspect ratio to all emojis."
|
||||||
|
|
||||||
|
approve_post_count: "The amount of posts from a new user that must be approved"
|
||||||
|
approve_unless_trust_level: "Posts for users below this trust level must be approved"
|
||||||
|
|
||||||
errors:
|
errors:
|
||||||
invalid_email: "Invalid email address."
|
invalid_email: "Invalid email address."
|
||||||
invalid_username: "There's no user with that username."
|
invalid_username: "There's no user with that username."
|
||||||
|
|
|
@ -441,6 +441,11 @@ posting:
|
||||||
enum: 'EmojiSetSiteSetting'
|
enum: 'EmojiSetSiteSetting'
|
||||||
enforce_square_emoji:
|
enforce_square_emoji:
|
||||||
default: true
|
default: true
|
||||||
|
approve_post_count:
|
||||||
|
default: 0
|
||||||
|
approve_unless_trust_level:
|
||||||
|
default: 0
|
||||||
|
enum: 'TrustLevelSetting'
|
||||||
|
|
||||||
email:
|
email:
|
||||||
email_time_window_mins:
|
email_time_window_mins:
|
||||||
|
|
|
@ -19,6 +19,15 @@ class NewPostManager
|
||||||
handlers << block
|
handlers << block
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.default_handler(manager)
|
||||||
|
if (manager.user.post_count < SiteSetting.approve_post_count) ||
|
||||||
|
(manager.user.trust_level < SiteSetting.approve_unless_trust_level)
|
||||||
|
return manager.enqueue('default')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
add_handler {|manager| default_handler(manager) }
|
||||||
|
|
||||||
def initialize(user, args)
|
def initialize(user, args)
|
||||||
@user = user
|
@user = user
|
||||||
@args = args.delete_if {|_, v| v.nil?}
|
@args = args.delete_if {|_, v| v.nil?}
|
||||||
|
|
|
@ -17,6 +17,42 @@ describe NewPostManager do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "default handler" do
|
||||||
|
let(:manager) { NewPostManager.new(topic.user, raw: 'this is new post content', topic_id: topic.id) }
|
||||||
|
|
||||||
|
context 'with the settings zeroed out' do
|
||||||
|
before do
|
||||||
|
SiteSetting.approve_post_count = 0
|
||||||
|
SiteSetting.approve_unless_trust_level = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
it "doesn't return a result action" do
|
||||||
|
result = NewPostManager.default_handler(manager)
|
||||||
|
expect(result).to eq(nil)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with a high approval post count' do
|
||||||
|
before do
|
||||||
|
SiteSetting.approve_post_count = 100
|
||||||
|
end
|
||||||
|
it "will return an enqueue result" do
|
||||||
|
result = NewPostManager.default_handler(manager)
|
||||||
|
expect(result.action).to eq(:enqueued)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with a high trust level setting' do
|
||||||
|
before do
|
||||||
|
SiteSetting.approve_unless_trust_level = 4
|
||||||
|
end
|
||||||
|
it "will return an enqueue result" do
|
||||||
|
result = NewPostManager.default_handler(manager)
|
||||||
|
expect(result.action).to eq(:enqueued)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "extensibility" do
|
context "extensibility" do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
|
Loading…
Reference in New Issue
Block a user