diff options
author | multiple creatures <dev@multiple-creature.party> | 2019-11-06 00:08:06 -0600 |
---|---|---|
committer | multiple creatures <dev@multiple-creature.party> | 2019-11-06 00:08:06 -0600 |
commit | 0db4b0b9d550b22f531cc427ddc2dcd68b0a9ae1 (patch) | |
tree | b614ab137163b66c268fa101b3eb743937bc9b4b /app/workers/registration_janitor_worker.rb | |
parent | af9b9777af9601bb2de857e6e4fea0b07d699108 (diff) |
perform spam detection at registration time
Diffstat (limited to 'app/workers/registration_janitor_worker.rb')
-rw-r--r-- | app/workers/registration_janitor_worker.rb | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/app/workers/registration_janitor_worker.rb b/app/workers/registration_janitor_worker.rb deleted file mode 100644 index c3250f993..000000000 --- a/app/workers/registration_janitor_worker.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -class RegistrationJanitorWorker - include Sidekiq::Worker - include LogHelper - - def perform(user_id) - user = User.find(user_id) - janitor = janitor_account || Account.representative - - spam_triggers = ENV.fetch('REGISTRATION_SPAM_TRIGGERS', '').split('|').map { |phrase| Regexp.escape(phrase.strip) } - spam_triggers = spam_triggers.empty? ? /(?!)/ : /\b#{Regexp.union(spam_triggers)}\b/i - - intro = user.invite_request&.text - # normalize it - intro = intro.gsub(/[\u200b-\u200d\ufeff\u200e\u200f]/, '').strip.downcase unless intro.nil? - - return user.notify_staff_about_pending_account! unless intro.blank? || intro.split.count < 5 || spam_triggers.match?(intro) - - user_friendly_action_log(janitor, :reject_registration, user.account.username, "Registration was spam filtered.") - Form::AccountBatch.new(current_account: janitor, account_ids: user.account.id, action: 'reject').save - rescue ActiveRecord::RecordNotFound, ActiveRecord::RecordInvalid - true - end - - private - - def janitor_account - account_id = ENV.fetch('JANITOR_USER', '').to_i - return if account_id == 0 - Account.find_by(id: account_id) - end -end |