mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: don't enforce newuser_spam_host_threshold on private messages
This commit is contained in:
parent
c1228dab25
commit
15a74d6d3e
@ -303,6 +303,7 @@ class Post < ActiveRecord::Base
|
|||||||
# Prevent new users from posting the same hosts too many times.
|
# Prevent new users from posting the same hosts too many times.
|
||||||
def has_host_spam?
|
def has_host_spam?
|
||||||
return false if acting_user.present? && (acting_user.staged? || acting_user.has_trust_level?(TrustLevel[1]))
|
return false if acting_user.present? && (acting_user.staged? || acting_user.has_trust_level?(TrustLevel[1]))
|
||||||
|
return false if topic&.private_message?
|
||||||
|
|
||||||
total_hosts_usage.values.any? { |count| count >= SiteSetting.newuser_spam_host_threshold }
|
total_hosts_usage.values.any? { |count| count >= SiteSetting.newuser_spam_host_threshold }
|
||||||
end
|
end
|
||||||
|
@ -835,8 +835,10 @@ describe Post do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe "has_host_spam" do
|
describe "has_host_spam" do
|
||||||
|
let(:raw) { "hello from my site http://www.somesite.com http://#{GlobalSetting.hostname} http://#{RailsMultisite::ConnectionManagement.current_hostname}" }
|
||||||
|
|
||||||
it "correctly detects host spam" do
|
it "correctly detects host spam" do
|
||||||
post = Fabricate(:post, raw: "hello from my site http://www.somesite.com http://#{GlobalSetting.hostname} http://#{RailsMultisite::ConnectionManagement.current_hostname}")
|
post = Fabricate(:post, raw: raw)
|
||||||
|
|
||||||
expect(post.total_hosts_usage).to eq("www.somesite.com" => 1)
|
expect(post.total_hosts_usage).to eq("www.somesite.com" => 1)
|
||||||
post.acting_user.trust_level = 0
|
post.acting_user.trust_level = 0
|
||||||
@ -850,6 +852,20 @@ describe Post do
|
|||||||
SiteSetting.white_listed_spam_host_domains = "bla.com|boo.com | somesite.com "
|
SiteSetting.white_listed_spam_host_domains = "bla.com|boo.com | somesite.com "
|
||||||
expect(post.has_host_spam?).to eq(false)
|
expect(post.has_host_spam?).to eq(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "doesn't punish staged users" do
|
||||||
|
SiteSetting.newuser_spam_host_threshold = 1
|
||||||
|
user = Fabricate(:user, staged: true, trust_level: 0)
|
||||||
|
post = Fabricate(:post, raw: raw, user: user)
|
||||||
|
expect(post.has_host_spam?).to eq(false)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "ignores private messages" do
|
||||||
|
SiteSetting.newuser_spam_host_threshold = 1
|
||||||
|
user = Fabricate(:user, trust_level: 0)
|
||||||
|
post = Fabricate(:post, raw: raw, user: user, topic: Fabricate(:private_message_topic, user: user))
|
||||||
|
expect(post.has_host_spam?).to eq(false)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "has custom fields" do
|
it "has custom fields" do
|
||||||
|
Loading…
Reference in New Issue
Block a user