mirror of
https://github.com/internetee/registry.git
synced 2025-05-19 18:59:38 +02:00
commit
42225d3298
10 changed files with 46 additions and 32 deletions
|
@ -1,8 +1,10 @@
|
||||||
class ContactMailer < ApplicationMailer
|
class ContactMailer < ApplicationMailer
|
||||||
include Que::Mailer
|
include Que::Mailer
|
||||||
|
|
||||||
def email_updated(email, contact_id, should_deliver)
|
def email_updated(old_email, email, contact_id, should_deliver)
|
||||||
@contact = Contact.find_by(id: contact_id)
|
@contact = Contact.find_by(id: contact_id)
|
||||||
|
@old_email = old_email
|
||||||
|
|
||||||
return unless email || @contact
|
return unless email || @contact
|
||||||
return if delivery_off?(@contact, should_deliver)
|
return if delivery_off?(@contact, should_deliver)
|
||||||
return if whitelist_blocked?(email)
|
return if whitelist_blocked?(email)
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
class DomainMailer < ApplicationMailer
|
class DomainMailer < ApplicationMailer
|
||||||
include Que::Mailer
|
include Que::Mailer
|
||||||
|
|
||||||
def pending_update_request_for_old_registrant(domain_id, should_deliver)
|
def pending_update_request_for_old_registrant(domain_id, old_registrant_id, should_deliver)
|
||||||
@domain = Domain.find_by(id: domain_id)
|
@domain = Domain.find_by(id: domain_id)
|
||||||
|
@old_registrant = Registrant.find(old_registrant_id)
|
||||||
return unless @domain
|
return unless @domain
|
||||||
return if delivery_off?(@domain, should_deliver)
|
return if delivery_off?(@domain, should_deliver)
|
||||||
|
|
||||||
|
@ -16,8 +17,6 @@ class DomainMailer < ApplicationMailer
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@old_registrant = Registrant.find(@domain.registrant_id_was)
|
|
||||||
|
|
||||||
confirm_path = "#{ENV['registrant_url']}/registrant/domain_update_confirms"
|
confirm_path = "#{ENV['registrant_url']}/registrant/domain_update_confirms"
|
||||||
@verification_url = "#{confirm_path}/#{@domain.id}?token=#{@domain.registrant_verification_token}"
|
@verification_url = "#{confirm_path}/#{@domain.id}?token=#{@domain.registrant_verification_token}"
|
||||||
|
|
||||||
|
@ -27,8 +26,9 @@ class DomainMailer < ApplicationMailer
|
||||||
name: @domain.name)} [#{@domain.name}]")
|
name: @domain.name)} [#{@domain.name}]")
|
||||||
end
|
end
|
||||||
|
|
||||||
def pending_update_notification_for_new_registrant(domain_id, should_deliver)
|
def pending_update_notification_for_new_registrant(domain_id, old_registrant_id, should_deliver)
|
||||||
@domain = Domain.find_by(id: domain_id)
|
@domain = Domain.find_by(id: domain_id)
|
||||||
|
@old_registrant = Registrant.find(old_registrant_id)
|
||||||
return unless @domain
|
return unless @domain
|
||||||
return if delivery_off?(@domain, should_deliver)
|
return if delivery_off?(@domain, should_deliver)
|
||||||
|
|
||||||
|
@ -43,7 +43,6 @@ class DomainMailer < ApplicationMailer
|
||||||
end
|
end
|
||||||
|
|
||||||
@new_registrant = @domain.registrant # NB! new registrant at this point
|
@new_registrant = @domain.registrant # NB! new registrant at this point
|
||||||
@old_registrant = Registrant.find(@domain.registrant_id_was)
|
|
||||||
|
|
||||||
return if whitelist_blocked?(@new_registrant.email)
|
return if whitelist_blocked?(@new_registrant.email)
|
||||||
mail(to: format(@new_registrant.email),
|
mail(to: format(@new_registrant.email),
|
||||||
|
@ -107,8 +106,9 @@ class DomainMailer < ApplicationMailer
|
||||||
name: @domain.name)} [#{@domain.name}]")
|
name: @domain.name)} [#{@domain.name}]")
|
||||||
end
|
end
|
||||||
|
|
||||||
def pending_deleted(domain_id, should_deliver)
|
def pending_deleted(domain_id, old_registrant_id, should_deliver)
|
||||||
@domain = Domain.find_by(id: domain_id)
|
@domain = Domain.find_by(id: domain_id)
|
||||||
|
@old_registrant = Registrant.find(old_registrant_id)
|
||||||
return unless @domain
|
return unless @domain
|
||||||
return if delivery_off?(@domain, should_deliver)
|
return if delivery_off?(@domain, should_deliver)
|
||||||
|
|
||||||
|
@ -122,8 +122,6 @@ class DomainMailer < ApplicationMailer
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@old_registrant = Registrant.find(@domain.registrant_id_was)
|
|
||||||
|
|
||||||
confirm_path = "#{ENV['registrant_url']}/registrant/domain_delete_confirms"
|
confirm_path = "#{ENV['registrant_url']}/registrant/domain_delete_confirms"
|
||||||
@verification_url = "#{confirm_path}/#{@domain.id}?token=#{@domain.registrant_verification_token}"
|
@verification_url = "#{confirm_path}/#{@domain.id}?token=#{@domain.registrant_verification_token}"
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ class Contact < ActiveRecord::Base
|
||||||
validates :ident,
|
validates :ident,
|
||||||
format: { with: /\d{4}-\d{2}-\d{2}/, message: :invalid_birthday_format },
|
format: { with: /\d{4}-\d{2}-\d{2}/, message: :invalid_birthday_format },
|
||||||
if: proc { |c| c.ident_type == 'birthday' }
|
if: proc { |c| c.ident_type == 'birthday' }
|
||||||
validates :ident_country_code, presence: true, if: proc { |c| %w(org priv).include? c.ident_type }
|
validates :ident_country_code, presence: true, if: proc { |c| %w(org priv).include? c.ident_type }, on: :create
|
||||||
validates :code,
|
validates :code,
|
||||||
uniqueness: { message: :epp_id_taken },
|
uniqueness: { message: :epp_id_taken },
|
||||||
format: { with: /\A[\w\-\:]*\Z/i, message: :invalid },
|
format: { with: /\A[\w\-\:]*\Z/i, message: :invalid },
|
||||||
|
@ -51,7 +51,7 @@ class Contact < ActiveRecord::Base
|
||||||
emails << domains.map(&:registrant_email) if domains.present?
|
emails << domains.map(&:registrant_email) if domains.present?
|
||||||
emails = emails.flatten.uniq
|
emails = emails.flatten.uniq
|
||||||
emails.each do |e|
|
emails.each do |e|
|
||||||
ContactMailer.email_updated(e, id, deliver_emails).deliver
|
ContactMailer.email_updated(email_was, e, id, deliver_emails).deliver
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -438,6 +438,7 @@ class Domain < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def pending_update!
|
def pending_update!
|
||||||
|
old_registrant_id = registrant_id
|
||||||
return true if pending_update?
|
return true if pending_update?
|
||||||
self.epp_pending_update = true # for epp
|
self.epp_pending_update = true # for epp
|
||||||
|
|
||||||
|
@ -449,8 +450,8 @@ class Domain < ActiveRecord::Base
|
||||||
new_registrant_email = registrant.email
|
new_registrant_email = registrant.email
|
||||||
new_registrant_name = registrant.name
|
new_registrant_name = registrant.name
|
||||||
|
|
||||||
DomainMailer.pending_update_request_for_old_registrant(id, deliver_emails).deliver
|
DomainMailer.pending_update_request_for_old_registrant(id, old_registrant_id, deliver_emails).deliver
|
||||||
DomainMailer.pending_update_notification_for_new_registrant(id, deliver_emails).deliver
|
DomainMailer.pending_update_notification_for_new_registrant(id, old_registrant_id, deliver_emails).deliver
|
||||||
|
|
||||||
reload # revert back to original
|
reload # revert back to original
|
||||||
|
|
||||||
|
@ -510,7 +511,7 @@ class Domain < ActiveRecord::Base
|
||||||
pending_delete_confirmation!
|
pending_delete_confirmation!
|
||||||
save(validate: false) # should check if this did succeed
|
save(validate: false) # should check if this did succeed
|
||||||
|
|
||||||
DomainMailer.pending_deleted(id, deliver_emails).deliver
|
DomainMailer.pending_deleted(id, registrant_id_was, deliver_emails).deliver
|
||||||
end
|
end
|
||||||
|
|
||||||
def cancel_pending_delete
|
def cancel_pending_delete
|
||||||
|
|
|
@ -104,6 +104,7 @@ class Epp::Contact < Contact
|
||||||
res
|
res
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
delegate :ident_attr_valid?, to: :class
|
||||||
|
|
||||||
def epp_code_map # rubocop:disable Metrics/MethodLength
|
def epp_code_map # rubocop:disable Metrics/MethodLength
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
Tere <%= @contact.name %>
|
Tere <%= @contact.name %>
|
||||||
<br><br>
|
<br><br>
|
||||||
Kontakti <%= @contact.name %> eposti aadress on muudetud<br>
|
Kontakti <%= @contact.name %> eposti aadress on muudetud<br>
|
||||||
endine aadress: <%= @contact.email_was %><br>
|
endine aadress: <%= @old_email %><br>
|
||||||
uus aadress: <%= @contact.email %>
|
uus aadress: <%= @contact.email %>
|
||||||
<br><br>
|
<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 %>
|
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 %>
|
||||||
|
@ -30,7 +30,7 @@ Eesti Interneti SA
|
||||||
Hi <%= @contact.name %>
|
Hi <%= @contact.name %>
|
||||||
<br><br>
|
<br><br>
|
||||||
E-mail address of <%= @contact.name %> has been changed<br>
|
E-mail address of <%= @contact.name %> has been changed<br>
|
||||||
previous address: <%= @contact.email_was %><br>
|
previous address: <%= @old_email %><br>
|
||||||
new address: <%= @contact.email %>
|
new address: <%= @contact.email %>
|
||||||
<br><br>
|
<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 %>
|
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 %>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
Tere <%= @contact.name %>
|
Tere <%= @contact.name %>
|
||||||
|
|
||||||
Kontakti <%= @contact.name %> eposti aadress on muudetud
|
Kontakti <%= @contact.name %> eposti aadress on muudetud
|
||||||
endine aadress: <%= @contact.email_was %>
|
endine aadress: <%= @old_email %>
|
||||||
uus aadress: <%= @contact.email %>
|
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 %>
|
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 %>
|
||||||
|
@ -30,7 +30,7 @@ Eesti Interneti SA
|
||||||
Hi <%= @contact.name %>
|
Hi <%= @contact.name %>
|
||||||
|
|
||||||
E-mail address of <%= @contact.name %> has been changed
|
E-mail address of <%= @contact.name %> has been changed
|
||||||
previous address: <%= @contact.email_was %>
|
previous address: <%= @old_email %>
|
||||||
new address: <%= @contact.email %>
|
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 %>
|
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 %>
|
||||||
|
|
|
@ -45,12 +45,15 @@ class AddIdentAutofill < ActiveRecord::Migration
|
||||||
END LOOP;
|
END LOOP;
|
||||||
mod := (total % 11);
|
mod := (total % 11);
|
||||||
END IF;
|
END IF;
|
||||||
|
IF (mod = 10)
|
||||||
IF (mod < 10 AND substring(r.ident, 11, 1) = to_char(mod, 'FM999MI'))
|
THEN
|
||||||
|
mod := 0;
|
||||||
|
END IF;
|
||||||
|
IF (substring(r.ident, 11, 1) = to_char(mod, 'FM999MI'))
|
||||||
THEN
|
THEN
|
||||||
UPDATE contacts SET ident_country_code = 'EE' WHERE id = r.id;
|
UPDATE contacts SET ident_country_code = 'EE' WHERE id = r.id;
|
||||||
END IF;
|
END IF;
|
||||||
total = 0;
|
total := 0;
|
||||||
END IF;
|
END IF;
|
||||||
END LOOP;
|
END LOOP;
|
||||||
|
|
||||||
|
@ -66,7 +69,7 @@ class AddIdentAutofill < ActiveRecord::Migration
|
||||||
counter := (counter + 1);
|
counter := (counter + 1);
|
||||||
END LOOP;
|
END LOOP;
|
||||||
mod := total % 11;
|
mod := total % 11;
|
||||||
total = 0;
|
total := 0;
|
||||||
counter := 1;
|
counter := 1;
|
||||||
IF (mod >= 10)
|
IF (mod >= 10)
|
||||||
THEN
|
THEN
|
||||||
|
@ -78,7 +81,11 @@ class AddIdentAutofill < ActiveRecord::Migration
|
||||||
END LOOP;
|
END LOOP;
|
||||||
mod := (total % 11);
|
mod := (total % 11);
|
||||||
END IF;
|
END IF;
|
||||||
IF (mod < 10 AND (substring(r.ident, 8, 1) = to_char(mod, 'FM999MI')))
|
IF (mod = 10)
|
||||||
|
THEN
|
||||||
|
mod := 0;
|
||||||
|
END IF;
|
||||||
|
IF (substring(r.ident, 8, 1) = to_char(mod, 'FM999MI'))
|
||||||
THEN
|
THEN
|
||||||
UPDATE contacts SET ident_country_code = 'EE' WHERE id = r.id;
|
UPDATE contacts SET ident_country_code = 'EE' WHERE id = r.id;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
|
@ -250,7 +250,12 @@ namespace :import do
|
||||||
next if existing_contact_ids.include?(x.id)
|
next if existing_contact_ids.include?(x.id)
|
||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
|
if 4 == x.ssntype
|
||||||
|
name = x.organization.try(:strip).presence || x.name.try(:strip).presence
|
||||||
|
else
|
||||||
name = x.name.try(:strip).presence || x.organization.try(:strip).presence
|
name = x.name.try(:strip).presence || x.organization.try(:strip).presence
|
||||||
|
end
|
||||||
|
|
||||||
begin
|
begin
|
||||||
contacts << [
|
contacts << [
|
||||||
x.object_registry.name.try(:strip),
|
x.object_registry.name.try(:strip),
|
||||||
|
@ -262,7 +267,7 @@ namespace :import do
|
||||||
x.ssn.try(:strip),
|
x.ssn.try(:strip),
|
||||||
ident_type_map[x.ssntype],
|
ident_type_map[x.ssntype],
|
||||||
x.object.authinfopw.try(:strip),
|
x.object.authinfopw.try(:strip),
|
||||||
x.organization.try(:strip)? x.organization.try(:strip): name,
|
name,
|
||||||
Registrar.find_by(legacy_id: x.object.try(:clid)).try(:id),
|
Registrar.find_by(legacy_id: x.object.try(:clid)).try(:id),
|
||||||
x.object_registry.try(:registrar).try(:name),
|
x.object_registry.try(:registrar).try(:name),
|
||||||
x.object.try(:registrar).try(:name) ? x.object.try(:registrar).try(:name) : x.object_registry.try(:registrar).try(:name),
|
x.object.try(:registrar).try(:name) ? x.object.try(:registrar).try(:name) : x.object_registry.try(:registrar).try(:name),
|
||||||
|
|
|
@ -9,7 +9,7 @@ describe DomainMailer do
|
||||||
before :all do
|
before :all do
|
||||||
@registrant = Fabricate(:registrant, email: 'test@example.com')
|
@registrant = Fabricate(:registrant, email: 'test@example.com')
|
||||||
@domain = Fabricate(:domain, registrant: @registrant)
|
@domain = Fabricate(:domain, registrant: @registrant)
|
||||||
@mail = DomainMailer.pending_update_request_for_old_registrant(@domain.id, deliver_emails)
|
@mail = DomainMailer.pending_update_request_for_old_registrant(@domain.id, @registrant.id,deliver_emails)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not render email subject' do
|
it 'should not render email subject' do
|
||||||
|
@ -38,7 +38,7 @@ describe DomainMailer do
|
||||||
@domain.registrant_verification_token = '123'
|
@domain.registrant_verification_token = '123'
|
||||||
@domain.registrant_verification_asked_at = Time.zone.now
|
@domain.registrant_verification_asked_at = Time.zone.now
|
||||||
@domain.registrant = @new_registrant
|
@domain.registrant = @new_registrant
|
||||||
@mail = DomainMailer.pending_update_request_for_old_registrant(@domain.id, deliver_emails)
|
@mail = DomainMailer.pending_update_request_for_old_registrant(@domain.id, @registrant.id, deliver_emails)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should render email subject' do
|
it 'should render email subject' do
|
||||||
|
@ -71,7 +71,7 @@ describe DomainMailer do
|
||||||
@domain.registrant_verification_token = '123'
|
@domain.registrant_verification_token = '123'
|
||||||
@domain.registrant_verification_asked_at = Time.zone.now
|
@domain.registrant_verification_asked_at = Time.zone.now
|
||||||
@domain.registrant = @new_registrant
|
@domain.registrant = @new_registrant
|
||||||
@mail = DomainMailer.pending_update_notification_for_new_registrant(@domain.id, deliver_emails)
|
@mail = DomainMailer.pending_update_notification_for_new_registrant(@domain.id, @registrant.id, deliver_emails)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should render email subject' do
|
it 'should render email subject' do
|
||||||
|
@ -100,7 +100,7 @@ describe DomainMailer do
|
||||||
@domain.registrant_verification_token = '123'
|
@domain.registrant_verification_token = '123'
|
||||||
@domain.registrant_verification_asked_at = Time.zone.now
|
@domain.registrant_verification_asked_at = Time.zone.now
|
||||||
@domain.registrant = @new_registrant
|
@domain.registrant = @new_registrant
|
||||||
@mail = DomainMailer.pending_update_notification_for_new_registrant(@domain.id, deliver_emails)
|
@mail = DomainMailer.pending_update_notification_for_new_registrant(@domain.id, @registrant.id, deliver_emails)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should render email subject' do
|
it 'should render email subject' do
|
||||||
|
@ -202,7 +202,7 @@ describe DomainMailer do
|
||||||
before :all do
|
before :all do
|
||||||
@registrant = Fabricate(:registrant, email: 'test@example.com')
|
@registrant = Fabricate(:registrant, email: 'test@example.com')
|
||||||
@domain = Fabricate(:domain, registrant: @registrant)
|
@domain = Fabricate(:domain, registrant: @registrant)
|
||||||
@mail = DomainMailer.pending_deleted(@domain.id, deliver_emails)
|
@mail = DomainMailer.pending_deleted(@domain.id, @registrant.id, deliver_emails)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not render email subject' do
|
it 'should not render email subject' do
|
||||||
|
@ -229,7 +229,7 @@ describe DomainMailer do
|
||||||
@domain.deliver_emails = true
|
@domain.deliver_emails = true
|
||||||
@domain.registrant_verification_token = '123'
|
@domain.registrant_verification_token = '123'
|
||||||
@domain.registrant_verification_asked_at = Time.zone.now
|
@domain.registrant_verification_asked_at = Time.zone.now
|
||||||
@mail = DomainMailer.pending_deleted(@domain.id, deliver_emails)
|
@mail = DomainMailer.pending_deleted(@domain.id, @registrant.id, deliver_emails)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should render email subject' do
|
it 'should render email subject' do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue