EPP email change will send notification to registrant

This commit is contained in:
Priit Tark 2015-05-12 13:45:55 +03:00
parent 73637b1a28
commit 64fec42a69
14 changed files with 330 additions and 22 deletions

View file

@ -0,0 +1,13 @@
class ContactMailer < ApplicationMailer
def email_updated(contact)
unless Rails.env.production?
return unless TEST_EMAILS.include?(contact.email) || TEST_EMAILS.include?(contact.email_was)
end
# turn on delivery on specific request only, thus rake tasks does not deliver anything
return if contact.deliver_emails != true
@contact = contact
mail(to: [@contact.email, @contact.email_was], subject: I18n.t(:contact_email_update_subject))
end
end

View file

@ -1,12 +1,8 @@
class InvoiceMailer < ApplicationMailer
def invoice_email(invoice, pdf)
unless Rails.env.production?
test_emails = ['martin@gitlab.eu', 'priit@gitlab.eu']
return unless test_emails.include?(invoice.billing_email)
end
return if Rails.env.production? ? false : TEST_EMAILS.include?(invoice.billing_email)
@invoice = invoice
attachments[invoice.pdf_name] = pdf
mail(to: invoice.billing_email, subject: invoice)
end

View file

@ -29,6 +29,13 @@ class Contact < ActiveRecord::Base
before_validation :set_ident_country_code
before_validation :prefix_code
before_create :generate_auth_info
before_update :manage_emails
def manage_emails
return nil unless email_changed?
ContactMailer.email_updated(self).deliver_now
end
after_save :manage_statuses
def manage_statuses
ContactStatus.manage(statuses, self)
@ -48,6 +55,8 @@ class Contact < ActiveRecord::Base
BIRTHDAY # Birthday date
]
attr_accessor :deliver_emails
class << self
def search_by_query(query)
res = search(code_cont: query).result

View file

@ -16,6 +16,12 @@ class DomainContact < ActiveRecord::Base
}
end
def name
return 'Tech' if type == 'TechDomainContact'
return 'Admin' if type == 'AdminDomainContact'
''
end
validates :contact, presence: true
before_save :update_contact_code_cache

View file

@ -145,7 +145,7 @@ class Epp::Contact < Contact
at.merge!(self.class.ident_attrs(frame.css('ident').first))
legal_frame = frame.css('legalDocument').first
at[:legal_documents_attributes] = self.class.legal_document_attrs(legal_frame)
self.deliver_emails = true # turn on email delivery for epp
super(at)
end
end

View file

@ -0,0 +1,51 @@
Tere <%= @contact.name %>
<br><br>
Kontakti <%= @contact.name %> eposti aadress on muudetud<br>
endine aadress: <%= @contact.email_was %><br>
uus aadress: <%= @contact.email %>
<br><br>
Eposti aadressile saadetakse domeenidega seotud infot seal hulgas kinnitustaotluseid omaniku vahetuse ja domeeni kustutamise korral. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduga oma registripidaja poole. Teie registripidaja on <%= @contact.registrar.name %>
<br><br>
Muudatusega seotud domeenid:<br>
<% @contact.domain_contacts.each do |dc| %>
<%= dc.domain.name %> (<%= dc.name %>)<br>
<% end %>
<br>
Kontaktandmed:<br>
Nimi: <%= @contact.name %><br>
Isikukood: <%= @contact.ident %><br>
Epost: <%= @contact.email %><br>
Tel: <%= @contact.phone %><br>
Tänav: <%= @contact.street %><br>
Linn: <%= @contact.city %><br>
Riik: <%= @contact.country %>
<br><br>
Lugupidamisega
Eesti Interneti SA
<br><br>
<hr>
<br><br>
Hi <%= @contact.name %>
<br><br>
E-mail address of <% @contact.name %> has been changed<br>
previous address: <% @contact.email_was %><br>
new address: <% @contact.email %>
<br><br>
E-mail addresses are used to send important information regarding your registered domains including applications for approval of registrant change and domain deletion. Please make sure that the update and contact information are correct. Incase of problems please turn to your registrar. Your registrar is <%= @contact.registrar.name %>
<br><br>
Domains affected by this update:<br>
<% @contact.domain_contacts.each do |dc| %>
<%= dc.domain.name %> (<%= dc.name %>)<br>
<% end %>
<br>
Contact information:<br>
Name: <%= @contact.name %><br>
Identity Code: <%= @contact.ident %><br>
E-mail: <%= @contact.email %><br>
Tel: <%= @contact.phone %><br>
Street: <%= @contact.street %><br>
City: <%= @contact.city %><br>
Country: <%= @contact.country %>
<br><br>
Best Regards,
Eesti Interneti SA

View file

@ -0,0 +1,51 @@
Tere <%= @contact.name %>
Kontakti <%= @contact.name %> eposti aadress on muudetud
endine aadress: <%= @contact.email_was %>
uus aadress: <%= @contact.email %>
Eposti aadressile saadetakse domeenidega seotud infot seal hulgas kinnitustaotluseid omaniku vahetuse ja domeeni kustutamise korral. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduga oma registripidaja poole. Teie registripidaja on <%= @contact.registrar.name %>
Muudatusega seotud domeenid:
<% @contact.domain_contacts.each do |dc| %>
<%= dc.domain.name %> (<%= dc.name %>)
<% end %>
Kontaktandmed:
Nimi: <%= @contact.name %>
Isikukood: <%= @contact.ident %>
Epost: <%= @contact.email %>
Tel: <%= @contact.phone %>
Tänav: <%= @contact.street %>
Linn: <%= @contact.city %>
Riik: <%= @contact.country %>
Lugupidamisega
Eesti Interneti SA
----------------------------------------------------------------------------------
Hi <%= @contact.name %>
E-mail address of <% @contact.name %> has been changed
previous address: <% @contact.email_was %>
new address: <% @contact.email %>
E-mail addresses are used to send important information regarding your registered domains including applications for approval of registrant change and domain deletion. Please make sure that the update and contact information are correct. Incase of problems please turn to your registrar. Your registrar is <%= @contact.registrar.name %>
Domains affected by this update:
<% @contact.domain_contacts.each do |dc| %>
<%= dc.domain.name %> (<%= dc.name %>)
<% end %>
Contact information:
Name: <%= @contact.name %>
Identity Code: <%= @contact.ident %>
E-mail: <%= @contact.email %>
Tel: <%= @contact.phone %>
Street: <%= @contact.street %>
City: <%= @contact.city %>
Country: <%= @contact.country %>
Best Regards,
Eesti Interneti SA