use upstream spam detection

master
multiple creatures 2020-01-30 02:35:15 -06:00
parent ba0febd3c1
commit 389125d894
1 changed files with 0 additions and 24 deletions

View File

@ -489,11 +489,6 @@ class User < ApplicationRecord
super
end
def send_confirmation_instructions
return false if detect_spam!
super
end
def send_reset_password_instructions
return false if encrypted_password.blank? && (Devise.pam_authentication || Devise.ldap_authentication)
super
@ -557,25 +552,6 @@ class User < ApplicationRecord
end
end
def detect_spam!
return false if valid_invitation? || external? || Setting.registrations_mode == 'none'
janitor = janitor_account || Account.representative
intro = self.invite_request&.text
# normalize it
intro = intro.gsub(/[\u200b-\u200d\ufeff\u200e\u200f]/, '').strip.downcase unless intro.nil?
return false unless intro.blank? || intro.split.count < 5 || SPAM_TRIGGERS.match?(intro)
user_friendly_action_log(janitor, :reject_registration, self.account.username, "Registration was spam filtered.")
Form::AccountBatch.new(current_account: janitor, account_ids: account_id, action: 'reject').save
true
rescue ActiveRecord::RecordNotFound, ActiveRecord::RecordInvalid
false
end
def janitor_account
account_id = ENV.fetch('JANITOR_USER', '').to_i
return if account_id == 0