mirror of
https://github.com/internetee/registry.git
synced 2025-08-05 01:11:43 +02:00
Merge branch '107821878-emails' into staging
This commit is contained in:
commit
89ed513f0f
9 changed files with 49 additions and 48 deletions
|
@ -8,7 +8,7 @@ class DomainDeleteConfirmJob < Que::Job
|
|||
domain.poll_message!(:poll_pending_delete_confirmed_by_registrant)
|
||||
domain.apply_pending_delete!
|
||||
when RegistrantVerification::REJECTED
|
||||
DomainMailer.pending_delete_rejected_notification(domain_id).deliver
|
||||
DomainMailer.pending_delete_rejected_notification(domain_id, deliver_emails).deliver
|
||||
domain.poll_message!(:poll_pending_delete_rejected_by_registrant)
|
||||
domain.cancel_pending_delete
|
||||
end
|
||||
|
|
|
@ -17,8 +17,8 @@ class ApplicationMailer < ActionMailer::Base
|
|||
end
|
||||
|
||||
# turn on delivery on specific (epp) request only, thus rake tasks does not deliver anything
|
||||
def delivery_off?(model)
|
||||
return false if model.deliver_emails == true
|
||||
def delivery_off?(model, deliver_email= false)
|
||||
return false if deliver_emails == true
|
||||
logger.info "EMAIL SENDING WAS NOT ACTIVATED " \
|
||||
"BY MODEL OBJECT: id ##{model.try(:id)} deliver_emails returned false"
|
||||
true
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
class ContactMailer < ApplicationMailer
|
||||
include Que::Mailer
|
||||
|
||||
def email_updated(email, contact_id)
|
||||
def email_updated(email, contact_id, should_deliver)
|
||||
@contact = Contact.find_by(id: contact_id)
|
||||
return unless email || @contact
|
||||
return if delivery_off?(contact)
|
||||
return if delivery_off?(contact, should_deliver)
|
||||
return if whitelist_blocked?(email)
|
||||
|
||||
begin
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
class DomainMailer < ApplicationMailer
|
||||
include Que::Mailer
|
||||
|
||||
def pending_update_request_for_old_registrant(domain_id)
|
||||
def pending_update_request_for_old_registrant(domain_id, should_deliver)
|
||||
@domain = Domain.find_by(id: domain_id)
|
||||
return unless @domain
|
||||
return if delivery_off?(@domain)
|
||||
return if delivery_off?(@domain, should_deliver)
|
||||
|
||||
if @domain.registrant_verification_token.blank?
|
||||
logger.warn "EMAIL NOT DELIVERED: registrant_verification_token is missing for #{@domain.name}"
|
||||
|
@ -27,10 +27,10 @@ class DomainMailer < ApplicationMailer
|
|||
name: @domain.name)} [#{@domain.name}]")
|
||||
end
|
||||
|
||||
def pending_update_notification_for_new_registrant(domain_id)
|
||||
def pending_update_notification_for_new_registrant(domain_id, should_deliver)
|
||||
@domain = Domain.find_by(id: domain_id)
|
||||
return unless @domain
|
||||
return if delivery_off?(@domain)
|
||||
return if delivery_off?(@domain, should_deliver)
|
||||
|
||||
if @domain.registrant_verification_token.blank?
|
||||
logger.warn "EMAIL NOT DELIVERED: registrant_verification_token is missing for #{@domain.name}"
|
||||
|
@ -51,10 +51,10 @@ class DomainMailer < ApplicationMailer
|
|||
name: @domain.name)} [#{@domain.name}]")
|
||||
end
|
||||
|
||||
def registrant_updated_notification_for_new_registrant(domain_id)
|
||||
def registrant_updated_notification_for_new_registrant(domain_id, should_deliver)
|
||||
@domain = Domain.find_by(id: domain_id)
|
||||
return unless @domain
|
||||
return if delivery_off?(@domain)
|
||||
return if delivery_off?(@domain, should_deliver)
|
||||
|
||||
return if whitelist_blocked?(@domain.registrant_email)
|
||||
mail(to: format(@domain.registrant_email),
|
||||
|
@ -62,10 +62,10 @@ class DomainMailer < ApplicationMailer
|
|||
name: @domain.name)} [#{@domain.name}]")
|
||||
end
|
||||
|
||||
def registrant_updated_notification_for_old_registrant(domain_id)
|
||||
def registrant_updated_notification_for_old_registrant(domain_id, should_deliver)
|
||||
domain = Domain.find_by(id: domain_id)
|
||||
return unless domain
|
||||
return if delivery_off?(@domain)
|
||||
return if delivery_off?(@domain, should_deliver)
|
||||
|
||||
@old_registrant_email = domain.registrant_email # Nb! before applying pending updates
|
||||
|
||||
|
@ -107,10 +107,10 @@ class DomainMailer < ApplicationMailer
|
|||
name: @domain.name)} [#{@domain.name}]")
|
||||
end
|
||||
|
||||
def pending_deleted(domain_id)
|
||||
def pending_deleted(domain_id, should_deliver)
|
||||
@domain = Domain.find_by(id: domain_id)
|
||||
return unless @domain
|
||||
return if delivery_off?(@domain)
|
||||
return if delivery_off?(@domain, should_deliver)
|
||||
|
||||
if @domain.registrant_verification_token.blank?
|
||||
logger.warn "EMAIL NOT DELIVERED: registrant_verification_token is missing for #{@domain.name}"
|
||||
|
@ -133,10 +133,10 @@ class DomainMailer < ApplicationMailer
|
|||
name: @domain.name)} [#{@domain.name}]")
|
||||
end
|
||||
|
||||
def pending_delete_rejected_notification(domain_id)
|
||||
def pending_delete_rejected_notification(domain_id, should_deliver)
|
||||
@domain = Domain.find_by(id: domain_id)
|
||||
return unless @domain
|
||||
return if delivery_off?(@domain)
|
||||
return if delivery_off?(@domain, should_deliver)
|
||||
# no delivery off control, driggered by que, no epp request
|
||||
|
||||
if @domain.registrant_verification_token.blank?
|
||||
|
@ -155,10 +155,10 @@ class DomainMailer < ApplicationMailer
|
|||
name: @domain.name)} [#{@domain.name}]")
|
||||
end
|
||||
|
||||
def pending_delete_expired_notification(domain_id)
|
||||
def pending_delete_expired_notification(domain_id, should_deliver)
|
||||
@domain = Domain.find_by(id: domain_id)
|
||||
return unless @domain
|
||||
return if delivery_off?(@domain)
|
||||
return if delivery_off?(@domain, should_deliver)
|
||||
# no delivery off control, driggered by cron, no epp request
|
||||
|
||||
return if whitelist_blocked?(@domain.registrant.email)
|
||||
|
@ -167,10 +167,10 @@ class DomainMailer < ApplicationMailer
|
|||
name: @domain.name)} [#{@domain.name}]")
|
||||
end
|
||||
|
||||
def delete_confirmation(domain_id)
|
||||
def delete_confirmation(domain_id, should_deliver)
|
||||
@domain = Domain.find_by(id: domain_id)
|
||||
return unless @domain
|
||||
return if delivery_off?(@domain)
|
||||
return if delivery_off?(@domain, should_deliver)
|
||||
|
||||
return if whitelist_blocked?(@domain.registrant.email)
|
||||
mail(to: format(@domain.registrant.email),
|
||||
|
@ -178,9 +178,9 @@ class DomainMailer < ApplicationMailer
|
|||
name: @domain.name)} [#{@domain.name}]")
|
||||
end
|
||||
|
||||
def force_delete(domain_id)
|
||||
def force_delete(domain_id, should_deliver)
|
||||
@domain = Domain.find_by(id: domain_id)
|
||||
return if delivery_off?(@domain)
|
||||
return if delivery_off?(@domain, should_deliver)
|
||||
emails = ([@domain.registrant.email] + @domain.admin_contacts.map { |x| format(x.email) }).uniq
|
||||
return if whitelist_blocked?(emails)
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ class Contact < ActiveRecord::Base
|
|||
emails << domains.map(&:registrant_email) if domains.present?
|
||||
emails = emails.flatten.uniq
|
||||
emails.each do |e|
|
||||
ContactMailer.email_updated(e, id).deliver
|
||||
ContactMailer.email_updated(e, id, deliver_emails).deliver
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -241,7 +241,7 @@ class Domain < ActiveRecord::Base
|
|||
DomainMailer.pending_update_expired_notification_for_new_registrant(id).deliver
|
||||
end
|
||||
if domain.pending_delete? || domain.pending_delete_confirmation?
|
||||
DomainMailer.pending_delete_expired_notification(id).deliver
|
||||
DomainMailer.pending_delete_expired_notification(id, deliver_emails).deliver
|
||||
end
|
||||
domain.clean_pendings!
|
||||
unless Rails.env.test?
|
||||
|
@ -449,8 +449,8 @@ class Domain < ActiveRecord::Base
|
|||
new_registrant_email = registrant.email
|
||||
new_registrant_name = registrant.name
|
||||
|
||||
DomainMailer.pending_update_request_for_old_registrant(id).deliver
|
||||
DomainMailer.pending_update_notification_for_new_registrant(id).deliver
|
||||
DomainMailer.pending_update_request_for_old_registrant(id, deliver_emails).deliver
|
||||
DomainMailer.pending_update_notification_for_new_registrant(id, deliver_emails).deliver
|
||||
|
||||
reload # revert back to original
|
||||
|
||||
|
@ -510,7 +510,7 @@ class Domain < ActiveRecord::Base
|
|||
pending_delete_confirmation!
|
||||
save(validate: false) # should check if this did succeed
|
||||
|
||||
DomainMailer.pending_deleted(id).deliver
|
||||
DomainMailer.pending_deleted(id, deliver_emails).deliver
|
||||
end
|
||||
|
||||
def cancel_pending_delete
|
||||
|
@ -646,7 +646,7 @@ class Domain < ActiveRecord::Base
|
|||
registrar.messages.create!(
|
||||
body: I18n.t('force_delete_set_on_domain', domain: name)
|
||||
)
|
||||
DomainMailer.force_delete(id).deliver
|
||||
DomainMailer.force_delete(id, deliver_emails).deliver
|
||||
return true
|
||||
end
|
||||
false
|
||||
|
|
|
@ -500,7 +500,7 @@ class Epp::Domain < Domain
|
|||
# rubocop: enable Metrics/CyclomaticComplexity
|
||||
|
||||
def apply_pending_update!
|
||||
old_registrant_email = DomainMailer.registrant_updated_notification_for_old_registrant(id)
|
||||
old_registrant_email = DomainMailer.registrant_updated_notification_for_old_registrant(id, deliver_emails)
|
||||
preclean_pendings
|
||||
user = ApiUser.find(pending_json['current_user_id'])
|
||||
frame = Nokogiri::XML(pending_json['frame'])
|
||||
|
@ -510,7 +510,7 @@ class Epp::Domain < Domain
|
|||
return unless update(frame, user, false)
|
||||
clean_pendings!
|
||||
self.deliver_emails = true # turn on email delivery
|
||||
DomainMailer.registrant_updated_notification_for_new_registrant(id).deliver
|
||||
DomainMailer.registrant_updated_notification_for_new_registrant(id, deliver_emails).deliver
|
||||
old_registrant_email.deliver
|
||||
true
|
||||
end
|
||||
|
@ -519,9 +519,10 @@ class Epp::Domain < Domain
|
|||
preclean_pendings
|
||||
statuses.delete(DomainStatus::PENDING_DELETE_CONFIRMATION)
|
||||
statuses.delete(DomainStatus::PENDING_DELETE)
|
||||
DomainMailer.delete_confirmation(id).deliver
|
||||
clean_pendings!
|
||||
set_pending_delete!
|
||||
DomainMailer.delete_confirmation(id, deliver_emails).deliver
|
||||
|
||||
# TODO: confirm that this actually makes sense
|
||||
clean_pendings! if valid? && set_pending_delete!
|
||||
true
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue