From e1db29f5232402dbcf94bb1cc947289e33a9de19 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 15 Jun 2018 15:37:47 +0300 Subject: [PATCH] Remove unused code --- app/mailers/domain_mailer.rb | 16 +---- app/models/domain.rb | 4 -- app/models/domain_mail_model.rb | 117 -------------------------------- 3 files changed, 1 insertion(+), 136 deletions(-) delete mode 100644 app/models/domain_mail_model.rb diff --git a/app/mailers/domain_mailer.rb b/app/mailers/domain_mailer.rb index f14f4b4a7..d92e79ac0 100644 --- a/app/mailers/domain_mailer.rb +++ b/app/mailers/domain_mailer.rb @@ -45,18 +45,4 @@ class DomainMailer < ApplicationMailer subject: "#{I18n.t(:delete_confirmation_subject, name: @domain.name)} [#{@domain.name}]") end - - private - # app/models/DomainMailModel provides the data for mail that can be composed_from - # which ensures that values of objects are captured when they are valid, not later when this method is executed - def compose_from(params) - @params = params - return if delivery_off?(params, params[:deliver_emails]) - return if whitelist_blocked?(params[:recipient]) - params[:errors].map do |error| - logger.warn error - return - end - mail(to: params[:recipient], subject: params[:subject]) - end -end +end \ No newline at end of file diff --git a/app/models/domain.rb b/app/models/domain.rb index 3fc3bf0d6..0f3afed90 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -581,10 +581,6 @@ class Domain < ActiveRecord::Base end end - def send_mail(action) - DomainMailer.send(action, DomainMailModel.new(self).send(action)).deliver - end - def admin_contact_names admin_contacts.names end diff --git a/app/models/domain_mail_model.rb b/app/models/domain_mail_model.rb deleted file mode 100644 index 3f92a3138..000000000 --- a/app/models/domain_mail_model.rb +++ /dev/null @@ -1,117 +0,0 @@ -class DomainMailModel - # Capture current values used in app/views/mailers/domain_mailer/* and app/mailers/domain_mailer will send later - - def initialize(domain) - @domain = domain - @params = {errors: [], deliver_emails: domain.deliver_emails, id: domain.id} - end - - def pending_delete_rejected_notification - registrant - subject(:pending_delete_rejected_notification_subject) - compose - end - - def pending_delete_expired_notification - registrant - subject(:pending_delete_expired_notification_subject) - compose - end - - def delete_confirmation - registrant - subject(:delete_confirmation_subject) - compose - end - - def force_delete - admins - subject(:force_delete_subject) - compose - end - - private - - def registrant_old - @params[:recipient] = format Registrant.find(@domain.registrant_id_was).email - end - - def registrant - @params[:recipient] = format @domain.registrant.email - end - - def registrant_pending - @params[:recipient] = format @domain.pending_json['new_registrant_email'] - @params[:new_registrant_name] = @domain.pending_json['new_registrant_name'] - @params[:old_registrant_name] = @domain.registrant.name - end - - # registrant and domain admin contacts - def admins - emails = ([@domain.registrant.email] + @domain.admin_contacts.map { |x| format(x.email) }) - @params[:recipient] = emails.uniq.map { |x| format(x) } - end - - # puny internet domain name, TODO: username - def format(email) - return warn_no_email if email.nil? - user, host = email.split('@') - host = SimpleIDN.to_ascii(host) - "#{user}@#{host}" - end - - def subject(subject) - @params[:name] = @domain.name - @params[:subject] = "#{I18n.t(subject, name: @domain.name)}, [#{@domain.name}]" - end - - def confirm_update - verification_url('domain_update_confirms') - end - - def compose - @params - end - - def verification_url(path) - token = verification_token or return - @params[:verification_url] = "#{ENV['registrant_url']}/registrant/#{path}/#{@domain.id}?token=#{token}" - end - - def verification_token - return warn_missing(:registrant_verification_token) if @domain.registrant_verification_token.blank? - return warn_missing(:registrant_verification_asked_at) if @domain.registrant_verification_asked_at.blank? - @domain.registrant_verification_token - end - - def domain_info - [:name, :registrar_name, - :registrant_name, :registrant_ident, :registrant_email, - :registrant_street,:registrant_city - ].each do |attr| - @params.store attr, @domain.send(attr) - end - @params.store :registrant_country, @domain.registrant_country.name - @params.store :registrant_priv, @domain.registrant.priv? - @params.store :old_registrant_name, Registrant.find(@domain.registrant_id_was).name - @params - end - - def warn_no_email(item = 'email') - warn_missing item - nil - end - - def warn_missing(item) - warn_not_delivered "#{item.to_s} is missing for #{@domain.name}" - end - - def warn_not_delivered(reason) - message = "EMAIL NOT DELIVERED: #{reason}" - @params[:errors] << message -# Rails.logger.warn message - nil - end - -end -