Support for a new site setting: newuser_spam_host_threshold. If a new user posts a link

to the same host enough tiles, they will not be able to post the same link again.

Additionally, the site will flag all their previous posts with links as spam and they will
be instantly hidden via the auto hide workflow.
This commit is contained in:
Robin Ward
2013-05-10 16:58:23 -04:00
parent 04b8cd5c95
commit d554a59102
19 changed files with 355 additions and 75 deletions

View File

@ -266,7 +266,7 @@ describe User do
describe "trust levels" do
# NOTE be sure to use build to avoid db calls
# NOTE be sure to use build to avoid db calls
let(:user) { Fabricate.build(:user, trust_level: TrustLevel.levels[:newuser]) }
it "sets to the default trust level setting" do
@ -770,6 +770,31 @@ describe User do
end
end
describe "flag_linked_posts_as_spam" do
let(:user) { Fabricate(:user) }
let!(:admin) { Fabricate(:admin) }
let!(:post) { PostCreator.new(user, title: "this topic contains spam", raw: "this post has a link: http://discourse.org").create }
let!(:another_post) { PostCreator.new(user, title: "this topic also contains spam", raw: "this post has a link: http://discourse.org/asdfa").create }
let!(:post_without_link) { PostCreator.new(user, title: "this topic shouldn't be spam", raw: "this post has no links in it.").create }
it "has flagged all the user's posts as spam" do
user.flag_linked_posts_as_spam
post.reload
post.spam_count.should == 1
another_post.reload
another_post.spam_count.should == 1
post_without_link.reload
post_without_link.spam_count.should == 0
# It doesn't raise an exception if called again
user.flag_linked_posts_as_spam
end
end
describe 'update_time_read!' do
let(:user) { Fabricate(:user) }