mirror of
https://github.com/internetee/registry.git
synced 2025-08-04 08:52:04 +02:00
parent
962e98317d
commit
a6de3761c5
57 changed files with 238 additions and 203 deletions
18
app/mailers/delete_domain_mailer.rb
Normal file
18
app/mailers/delete_domain_mailer.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
class DeleteDomainMailer < ApplicationMailer
|
||||
include Que::Mailer
|
||||
|
||||
def pending(domain:, old_registrant:)
|
||||
@domain = DomainPresenter.new(domain: domain, view: view_context)
|
||||
@registrar = RegistrarPresenter.new(registrar: domain.registrar, view: view_context)
|
||||
@verification_url = verification_url(domain)
|
||||
|
||||
subject = default_i18n_subject(domain_name: domain.name)
|
||||
mail(to: old_registrant.email, subject: subject)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def verification_url(domain)
|
||||
registrant_domain_delete_confirm_url(domain, token: domain.registrant_verification_token)
|
||||
end
|
||||
end
|
|
@ -1,21 +1,6 @@
|
|||
class DomainMailer < ApplicationMailer
|
||||
include Que::Mailer
|
||||
|
||||
def pending_update_request_for_old_registrant(domain:, registrant:)
|
||||
@domain = DomainPresenter.new(domain: domain, view: view_context)
|
||||
@registrar = RegistrarPresenter.new(registrar: domain.registrar, view: view_context)
|
||||
@registrant = RegistrantPresenter.new(registrant: registrant, view: view_context)
|
||||
@verification_url = registrant_domain_update_confirm_url(domain, token: domain.registrant_verification_token)
|
||||
|
||||
subject = default_i18n_subject(domain_name: domain.name)
|
||||
mail(to: registrant.email, subject: subject)
|
||||
end
|
||||
|
||||
def pending_update_notification_for_new_registrant(params)
|
||||
compose_from(params)
|
||||
end
|
||||
|
||||
|
||||
def registrant_updated_notification_for_new_registrant(domain_id, old_registrant_id, new_registrant_id, should_deliver)
|
||||
@domain = Domain.find_by(id: domain_id)
|
||||
return unless @domain
|
||||
|
@ -45,23 +30,6 @@ class DomainMailer < ApplicationMailer
|
|||
name: @domain.name)} [#{@domain.name}]")
|
||||
end
|
||||
|
||||
def pending_update_rejected_notification_for_new_registrant(params)
|
||||
compose_from(params)
|
||||
end
|
||||
|
||||
def pending_update_expired_notification_for_new_registrant(params)
|
||||
compose_from(params)
|
||||
end
|
||||
|
||||
def pending_deleted(domain:, registrant:)
|
||||
@domain = DomainPresenter.new(domain: domain, view: view_context)
|
||||
@registrar = RegistrarPresenter.new(registrar: domain.registrar, view: view_context)
|
||||
@verification_url = registrant_domain_delete_confirm_url(domain, token: domain.registrant_verification_token)
|
||||
|
||||
subject = default_i18n_subject(domain_name: domain.name)
|
||||
mail(to: registrant.email, subject: subject)
|
||||
end
|
||||
|
||||
def pending_delete_rejected_notification(domain_id, should_deliver)
|
||||
@domain = Domain.find_by(id: domain_id)
|
||||
return unless @domain
|
||||
|
|
45
app/mailers/registrant_change_mailer.rb
Normal file
45
app/mailers/registrant_change_mailer.rb
Normal file
|
@ -0,0 +1,45 @@
|
|||
class RegistrantChangeMailer < ApplicationMailer
|
||||
include Que::Mailer
|
||||
|
||||
def confirmation(domain:, registrant:)
|
||||
@domain = DomainPresenter.new(domain: domain, view: view_context)
|
||||
@registrar = RegistrarPresenter.new(registrar: domain.registrar, view: view_context)
|
||||
@registrant = RegistrantPresenter.new(registrant: registrant, view: view_context)
|
||||
@verification_url = confirm_url(domain)
|
||||
|
||||
subject = default_i18n_subject(domain_name: domain.name)
|
||||
mail(to: registrant.email, subject: subject)
|
||||
end
|
||||
|
||||
def pending_update_notification_for_new_registrant(params)
|
||||
compose_from(params)
|
||||
end
|
||||
|
||||
def registrant_updated_notification_for_old_registrant(domain_id, old_registrant_id, new_registrant_id, should_deliver)
|
||||
@domain = Domain.find_by(id: domain_id)
|
||||
return unless @domain
|
||||
return if delivery_off?(@domain, should_deliver)
|
||||
|
||||
@old_registrant = Registrant.find(old_registrant_id)
|
||||
@new_registrant = Registrant.find(new_registrant_id)
|
||||
|
||||
return if whitelist_blocked?(@old_registrant.email)
|
||||
mail(to: format(@old_registrant.email),
|
||||
subject: "#{I18n.t(:registrant_updated_notification_for_old_registrant_subject,
|
||||
name: @domain.name)} [#{@domain.name}]")
|
||||
end
|
||||
|
||||
def pending_update_rejected_notification_for_new_registrant(params)
|
||||
compose_from(params)
|
||||
end
|
||||
|
||||
def pending_update_expired_notification_for_new_registrant(params)
|
||||
compose_from(params)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def confirm_url(domain)
|
||||
registrant_domain_update_confirm_url(domain, token: domain.registrant_verification_token)
|
||||
end
|
||||
end
|
|
@ -379,6 +379,9 @@ class Domain < ActiveRecord::Base
|
|||
new_registrant_email = registrant.email
|
||||
new_registrant_name = registrant.name
|
||||
|
||||
current_registrant = Registrant.find(registrant_id_was)
|
||||
RegistrantChangeMailer.confirmation(domain: self, current_registrant: current_registrant).deliver
|
||||
|
||||
send_mail :pending_update_request_for_old_registrant
|
||||
send_mail :pending_update_notification_for_new_registrant
|
||||
|
||||
|
@ -441,8 +444,8 @@ class Domain < ActiveRecord::Base
|
|||
pending_delete_confirmation!
|
||||
save(validate: false) # should check if this did succeed
|
||||
|
||||
previous_registrant = Registrant.find(registrant_id_was)
|
||||
DomainMailer.pending_deleted(domain: self, registrant: previous_registrant).deliver
|
||||
old_registrant = Registrant.find(registrant_id_was)
|
||||
DeleteDomainMailer.pending(domain: self, old_registrant: old_registrant).deliver
|
||||
end
|
||||
|
||||
def cancel_pending_delete
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
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}
|
||||
|
@ -15,13 +15,13 @@ class DomainMailModel
|
|||
end
|
||||
|
||||
def pending_update_notification_for_new_registrant
|
||||
registrant # new registrant at this point
|
||||
registrant # new registrant at this point
|
||||
subject(:pending_update_notification_for_new_registrant_subject)
|
||||
domain_info
|
||||
compose
|
||||
end
|
||||
|
||||
|
||||
|
||||
def pending_update_rejected_notification_for_new_registrant
|
||||
registrant_pending
|
||||
subject(:pending_update_rejected_notification_for_new_registrant_subject)
|
||||
|
@ -37,13 +37,6 @@ class DomainMailModel
|
|||
compose
|
||||
end
|
||||
|
||||
def pending_deleted
|
||||
registrant
|
||||
subject(:domain_pending_deleted_subject)
|
||||
confirm_delete
|
||||
compose
|
||||
end
|
||||
|
||||
def pending_delete_rejected_notification
|
||||
registrant
|
||||
subject(:pending_delete_rejected_notification_subject)
|
||||
|
@ -69,11 +62,11 @@ class DomainMailModel
|
|||
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
|
||||
|
@ -83,7 +76,7 @@ class DomainMailModel
|
|||
@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) })
|
||||
|
@ -106,26 +99,22 @@ class DomainMailModel
|
|||
def confirm_update
|
||||
verification_url('domain_update_confirms')
|
||||
end
|
||||
|
||||
def confirm_delete
|
||||
verification_url('domain_delete_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,
|
||||
|
@ -143,7 +132,7 @@ class DomainMailModel
|
|||
warn_missing item
|
||||
nil
|
||||
end
|
||||
|
||||
|
||||
def warn_missing(item)
|
||||
warn_not_delivered "#{item.to_s} is missing for #{@domain.name}"
|
||||
end
|
||||
|
@ -154,6 +143,6 @@ class DomainMailModel
|
|||
# Rails.logger.warn message
|
||||
nil
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ Tere
|
|||
<br><br>
|
||||
Registrisse laekus taotlus domeeni <%= @domain.name %> kustutamiseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole:
|
||||
|
||||
<%= render 'mailers/domain_mailer/registrar/registrar.et.html', registrar: @registrar %>
|
||||
<%= render 'mailers/shared/registrar/registrar.et.html', registrar: @registrar %>
|
||||
|
||||
<br><br>
|
||||
Muudatuse kinnitamiseks külastage palun allolevat lehekülge, kontrollige uuesti üle muudatuse andmed ning vajutage nuppu kinnitan.
|
||||
|
@ -19,7 +19,7 @@ Hi,
|
|||
<br><br>
|
||||
Application for deletion of your domain <%= @domain.name %> has been filed. Please make sure that the application is correct. Incase of problems please contact your registrar:
|
||||
|
||||
<%= render 'mailers/domain_mailer/registrar/registrar.en.html', registrar: @registrar %>
|
||||
<%= render 'mailers/shared/registrar/registrar.en.html', registrar: @registrar %>
|
||||
|
||||
<br><br>
|
||||
To confirm the update please visit this website, once again review the data and press approve:<br>
|
|
@ -2,7 +2,7 @@ Tere
|
|||
|
||||
Registrisse laekus taotlus domeeni <%= @domain.name %> kustutamiseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole:
|
||||
|
||||
<%= render 'mailers/domain_mailer/registrar/registrar.et.text', registrar: @registrar %>
|
||||
<%= render 'mailers/shared/registrar/registrar.et.text', registrar: @registrar %>
|
||||
|
||||
Muudatuse kinnitamiseks külastage palun allolevat lehekülge, kontrollige uuesti üle muudatuse andmed ning vajutage nuppu kinnitan.
|
||||
|
||||
|
@ -18,7 +18,7 @@ Hi,
|
|||
|
||||
Application for deletion of your domain <%= @domain.name %> has been filed. Please make sure that the application is correct. In case of problems please contact your registrar:
|
||||
|
||||
<%= render 'mailers/domain_mailer/registrar/registrar.en.text', registrar: @registrar %>
|
||||
<%= render 'mailers/shared/registrar/registrar.en.text', registrar: @registrar %>
|
||||
|
||||
To confirm the update please visit this website, once again review the data and press approve:
|
||||
<%= @verification_url %>
|
|
@ -16,7 +16,7 @@ Hi,
|
|||
<br><br>
|
||||
Domain registrant change request has been expired for the domain <%= @domain.name %>.
|
||||
<br><br>
|
||||
Please contact to your registrar if you have any questions:
|
||||
Please contact to your registrar if you have any questions:
|
||||
|
||||
<%= render 'registrar.en.html', registrar: @registrar %>
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue