mirror of
https://github.com/internetee/registry.git
synced 2025-05-30 01:20:04 +02:00
Added email pynicode support #2884
This commit is contained in:
parent
1b501dd053
commit
84d8b54c69
5 changed files with 48 additions and 13 deletions
|
@ -23,4 +23,10 @@ class ApplicationMailer < ActionMailer::Base
|
||||||
"BY MODEL OBJECT: id ##{model.try(:id)} deliver_emails returned false"
|
"BY MODEL OBJECT: id ##{model.try(:id)} deliver_emails returned false"
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def format(email)
|
||||||
|
local, host = email.split('@')
|
||||||
|
host = SimpleIDN.to_ascii(host)
|
||||||
|
"#{local}@#{host}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,7 +6,7 @@ class ContactMailer < ApplicationMailer
|
||||||
|
|
||||||
return if whitelist_blocked?(email)
|
return if whitelist_blocked?(email)
|
||||||
begin
|
begin
|
||||||
mail(to: email, subject: "#{I18n.t(:contact_email_update_subject)} [#{@contact.code}]")
|
mail(to: format(email), subject: "#{I18n.t(:contact_email_update_subject)} [#{@contact.code}]")
|
||||||
rescue EOFError,
|
rescue EOFError,
|
||||||
IOError,
|
IOError,
|
||||||
TimeoutError,
|
TimeoutError,
|
||||||
|
|
|
@ -19,7 +19,7 @@ class DomainMailer < ApplicationMailer
|
||||||
@verification_url = "#{confirm_path}/#{@domain.id}?token=#{@domain.registrant_verification_token}"
|
@verification_url = "#{confirm_path}/#{@domain.id}?token=#{@domain.registrant_verification_token}"
|
||||||
|
|
||||||
return if whitelist_blocked?(@old_registrant.email)
|
return if whitelist_blocked?(@old_registrant.email)
|
||||||
mail(to: @old_registrant.email,
|
mail(to: format(@old_registrant.email),
|
||||||
subject: "#{I18n.t(:pending_update_request_for_old_registrant_subject,
|
subject: "#{I18n.t(:pending_update_request_for_old_registrant_subject,
|
||||||
name: @domain.name)} [#{@domain.name}]")
|
name: @domain.name)} [#{@domain.name}]")
|
||||||
end
|
end
|
||||||
|
@ -42,7 +42,7 @@ class DomainMailer < ApplicationMailer
|
||||||
@old_registrant = Registrant.find(@domain.registrant_id_was)
|
@old_registrant = Registrant.find(@domain.registrant_id_was)
|
||||||
|
|
||||||
return if whitelist_blocked?(@new_registrant.email)
|
return if whitelist_blocked?(@new_registrant.email)
|
||||||
mail(to: @new_registrant.email,
|
mail(to: format(@new_registrant.email),
|
||||||
subject: "#{I18n.t(:pending_update_notification_for_new_registrant_subject,
|
subject: "#{I18n.t(:pending_update_notification_for_new_registrant_subject,
|
||||||
name: @domain.name)} [#{@domain.name}]")
|
name: @domain.name)} [#{@domain.name}]")
|
||||||
end
|
end
|
||||||
|
@ -52,7 +52,7 @@ class DomainMailer < ApplicationMailer
|
||||||
return if delivery_off?(@domain)
|
return if delivery_off?(@domain)
|
||||||
|
|
||||||
return if whitelist_blocked?(@domain.registrant_email)
|
return if whitelist_blocked?(@domain.registrant_email)
|
||||||
mail(to: @domain.registrant_email,
|
mail(to: format(@domain.registrant_email),
|
||||||
subject: "#{I18n.t(:registrant_updated_notification_for_new_registrant_subject,
|
subject: "#{I18n.t(:registrant_updated_notification_for_new_registrant_subject,
|
||||||
name: @domain.name)} [#{@domain.name}]")
|
name: @domain.name)} [#{@domain.name}]")
|
||||||
end
|
end
|
||||||
|
@ -64,7 +64,7 @@ class DomainMailer < ApplicationMailer
|
||||||
@old_registrant_email = domain.registrant_email # Nb! before applying pending updates
|
@old_registrant_email = domain.registrant_email # Nb! before applying pending updates
|
||||||
|
|
||||||
return if whitelist_blocked?(@old_registrant_email)
|
return if whitelist_blocked?(@old_registrant_email)
|
||||||
mail(to: @old_registrant_email,
|
mail(to: format(@old_registrant_email),
|
||||||
subject: "#{I18n.t(:registrant_updated_notification_for_old_registrant_subject,
|
subject: "#{I18n.t(:registrant_updated_notification_for_old_registrant_subject,
|
||||||
name: @domain.name)} [#{@domain.name}]")
|
name: @domain.name)} [#{@domain.name}]")
|
||||||
end
|
end
|
||||||
|
@ -77,7 +77,7 @@ class DomainMailer < ApplicationMailer
|
||||||
@new_registrant_name = @domain.pending_json['new_registrant_name']
|
@new_registrant_name = @domain.pending_json['new_registrant_name']
|
||||||
|
|
||||||
return if whitelist_blocked?(@new_registrant_email)
|
return if whitelist_blocked?(@new_registrant_email)
|
||||||
mail(to: @new_registrant_email,
|
mail(to: format(@new_registrant_email),
|
||||||
subject: "#{I18n.t(:pending_update_rejected_notification_for_new_registrant_subject,
|
subject: "#{I18n.t(:pending_update_rejected_notification_for_new_registrant_subject,
|
||||||
name: @domain.name)} [#{@domain.name}]")
|
name: @domain.name)} [#{@domain.name}]")
|
||||||
end
|
end
|
||||||
|
@ -94,7 +94,7 @@ class DomainMailer < ApplicationMailer
|
||||||
logger.info "EMAIL NOT DELIVERED: no registrant email [pending_update_expired_notification_for_new_registrant]"
|
logger.info "EMAIL NOT DELIVERED: no registrant email [pending_update_expired_notification_for_new_registrant]"
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
mail(to: @new_registrant_email,
|
mail(to: format(@new_registrant_email),
|
||||||
subject: "#{I18n.t(:pending_update_expired_notification_for_new_registrant_subject,
|
subject: "#{I18n.t(:pending_update_expired_notification_for_new_registrant_subject,
|
||||||
name: @domain.name)} [#{@domain.name}]")
|
name: @domain.name)} [#{@domain.name}]")
|
||||||
end
|
end
|
||||||
|
@ -119,7 +119,7 @@ class DomainMailer < ApplicationMailer
|
||||||
@verification_url = "#{confirm_path}/#{@domain.id}?token=#{@domain.registrant_verification_token}"
|
@verification_url = "#{confirm_path}/#{@domain.id}?token=#{@domain.registrant_verification_token}"
|
||||||
|
|
||||||
return if whitelist_blocked?(@old_registrant.email)
|
return if whitelist_blocked?(@old_registrant.email)
|
||||||
mail(to: @old_registrant.email,
|
mail(to: format(@old_registrant.email),
|
||||||
subject: "#{I18n.t(:domain_pending_deleted_subject,
|
subject: "#{I18n.t(:domain_pending_deleted_subject,
|
||||||
name: @domain.name)} [#{@domain.name}]")
|
name: @domain.name)} [#{@domain.name}]")
|
||||||
end
|
end
|
||||||
|
@ -139,7 +139,7 @@ class DomainMailer < ApplicationMailer
|
||||||
end
|
end
|
||||||
|
|
||||||
return if whitelist_blocked?(@domain.registrant.email)
|
return if whitelist_blocked?(@domain.registrant.email)
|
||||||
mail(to: @domain.registrant.email,
|
mail(to: format(@domain.registrant.email),
|
||||||
subject: "#{I18n.t(:pending_delete_rejected_notification_subject,
|
subject: "#{I18n.t(:pending_delete_rejected_notification_subject,
|
||||||
name: @domain.name)} [#{@domain.name}]")
|
name: @domain.name)} [#{@domain.name}]")
|
||||||
end
|
end
|
||||||
|
@ -149,7 +149,7 @@ class DomainMailer < ApplicationMailer
|
||||||
# no delivery off control, driggered by cron, no epp request
|
# no delivery off control, driggered by cron, no epp request
|
||||||
|
|
||||||
return if whitelist_blocked?(@domain.registrant.email)
|
return if whitelist_blocked?(@domain.registrant.email)
|
||||||
mail(to: @domain.registrant.email,
|
mail(to: format(@domain.registrant.email),
|
||||||
subject: "#{I18n.t(:pending_delete_expired_notification_subject,
|
subject: "#{I18n.t(:pending_delete_expired_notification_subject,
|
||||||
name: @domain.name)} [#{@domain.name}]")
|
name: @domain.name)} [#{@domain.name}]")
|
||||||
end
|
end
|
||||||
|
@ -158,7 +158,7 @@ class DomainMailer < ApplicationMailer
|
||||||
@domain = domain
|
@domain = domain
|
||||||
|
|
||||||
return if whitelist_blocked?(@domain.registrant.email)
|
return if whitelist_blocked?(@domain.registrant.email)
|
||||||
mail(to: @domain.registrant.email,
|
mail(to: format(@domain.registrant.email),
|
||||||
subject: "#{I18n.t(:delete_confirmation_subject,
|
subject: "#{I18n.t(:delete_confirmation_subject,
|
||||||
name: @domain.name)} [#{@domain.name}]")
|
name: @domain.name)} [#{@domain.name}]")
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,6 +4,6 @@ class InvoiceMailer < ApplicationMailer
|
||||||
|
|
||||||
@invoice = invoice
|
@invoice = invoice
|
||||||
attachments[invoice.pdf_name] = pdf
|
attachments[invoice.pdf_name] = pdf
|
||||||
mail(to: invoice.billing_email, subject: invoice)
|
mail(to: format(invoice.billing_email), subject: invoice)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe ContactMailer do
|
describe ContactMailer do
|
||||||
|
before :all do
|
||||||
|
Fabricate(:zonefile_setting, origin: 'ee')
|
||||||
|
end
|
||||||
|
|
||||||
describe 'email changed notification when delivery turned off' do
|
describe 'email changed notification when delivery turned off' do
|
||||||
before :all do
|
before :all do
|
||||||
@contact = Fabricate(:contact, email: 'test@example.ee')
|
@contact = Fabricate(:contact, email: 'test@example.ee')
|
||||||
|
@ -26,7 +30,6 @@ describe ContactMailer do
|
||||||
|
|
||||||
describe 'email changed notification' do
|
describe 'email changed notification' do
|
||||||
before :all do
|
before :all do
|
||||||
Fabricate(:zonefile_setting, origin: 'ee')
|
|
||||||
@domain = Fabricate(:domain)
|
@domain = Fabricate(:domain)
|
||||||
@contact = @domain.registrant
|
@contact = @domain.registrant
|
||||||
@contact.reload # until figured out why registrant_domains not loaded
|
@contact.reload # until figured out why registrant_domains not loaded
|
||||||
|
@ -50,4 +53,30 @@ describe ContactMailer do
|
||||||
@mail.body.encoded.should =~ /Kontaktandmed:/
|
@mail.body.encoded.should =~ /Kontaktandmed:/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'email with pynicode' do
|
||||||
|
before :all do
|
||||||
|
@domain = Fabricate(:domain)
|
||||||
|
@contact = @domain.registrant
|
||||||
|
@contact.reload # until figured out why registrant_domains not loaded
|
||||||
|
@contact.deliver_emails = true
|
||||||
|
@mail = ContactMailer.email_updated('info@ääöü.org', @contact)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should render email subject' do
|
||||||
|
@mail.subject.should =~ /Teie domeenide kontakt epostiaadress on muutunud/
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should have sender email' do
|
||||||
|
@mail.from.should == ["noreply@internet.ee"]
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should send to info email' do
|
||||||
|
@mail.to.should == ['info@xn--4caa8cya.org']
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should render body' do
|
||||||
|
@mail.body.encoded.should =~ /Kontaktandmed:/
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue