better tos issue reporting, and a threshold for being considered abusive in

comments
This commit is contained in:
Kyle Drake 2016-11-27 19:19:28 -06:00
parent 4dc613e27a
commit e554666fc5
4 changed files with 15 additions and 6 deletions

1
.gitignore vendored
View file

@ -24,3 +24,4 @@ files/disposable_email_blacklist.conf
files/letsencrypt.key files/letsencrypt.key
files/tor.txt files/tor.txt
.bundle .bundle
ext/black_box.rb

View file

@ -13,9 +13,10 @@ post '/event/:event_id/comment' do |event_id|
site = event.site site = event.site
if site.is_blocking?(current_site) || if(site.is_blocking?(current_site) ||
site.profile_comments_enabled == false || site.profile_comments_enabled == false ||
current_site.commenting_allowed? == false current_site.commenting_allowed? == false ||
(current_site.is_a_jerk? && event.site_id != current_site.id && !site.is_following?(current_site)))
return {result: 'error'}.to_json return {result: 'error'}.to_json
end end

View file

@ -129,11 +129,12 @@ post '/site/:username/comment' do |username|
site = Site[username: username] site = Site[username: username]
if(site.profile_comments_enabled == false || if site.profile_comments_enabled == false ||
params[:message].empty? || params[:message].empty? ||
site.is_blocking?(current_site) || site.is_blocking?(current_site) ||
current_site.is_blocking?(site) || current_site.is_blocking?(site) ||
current_site.commenting_allowed? == false) current_site.commenting_allowed? == false ||
(current_site.is_a_jerk? && site.id != current_site.id && !site.is_following?(current_site))
redirect request.referrer redirect request.referrer
end end

View file

@ -124,6 +124,8 @@ class Site < Sequel::Model
EMAIL_VALIDATION_CUTOFF_DATE = Time.parse('May 16, 2016') EMAIL_VALIDATION_CUTOFF_DATE = Time.parse('May 16, 2016')
DISPOSABLE_EMAIL_BLACKLIST_PATH = File.join(DIR_ROOT, 'files', 'disposable_email_blacklist.conf') DISPOSABLE_EMAIL_BLACKLIST_PATH = File.join(DIR_ROOT, 'files', 'disposable_email_blacklist.conf')
BLOCK_JERK_THRESHOLD = 3
def self.newsletter_sites def self.newsletter_sites
Site.select(:email). Site.select(:email).
exclude(email: 'nil').exclude(is_banned: true). exclude(email: 'nil').exclude(is_banned: true).
@ -522,6 +524,10 @@ class Site < Sequel::Model
false false
end end
def is_a_jerk?
blocks_dataset.count >= BLOCK_JERK_THRESHOLD
end
def blocking_site_ids def blocking_site_ids
@blocking_site_ids ||= blockings_dataset.select(:site_id).all.collect {|s| s.site_id} @blocking_site_ids ||= blockings_dataset.select(:site_id).all.collect {|s| s.site_id}
end end
@ -1468,8 +1474,8 @@ class Site < Sequel::Model
return false return false
end end
if pathname.extname.match HTML_REGEX if pathname.extname.match(HTML_REGEX) && defined?(BlackBox)
# SPAM and phishing checking code goes here BlackBox.tos_violation_check self, uploaded
end end
relative_path_dir = Pathname(relative_path).dirname relative_path_dir = Pathname(relative_path).dirname