Merge pull request #2205 from internetee/2184-mail-validation-after-update

added trumail validator after update and implement simple email valid…
This commit is contained in:
Timo Võhmar 2021-12-14 13:37:54 +02:00 committed by GitHub
commit 3f253ba6cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 44 additions and 0 deletions

View file

@ -12,9 +12,26 @@ module Actions
maybe_remove_address
maybe_attach_legal_doc
validate_ident
maybe_change_email
commit
end
def maybe_change_email
return if Rails.env.test?
[:regex, :mx].each do |m|
r = Actions::SimpleMailValidator.run(email: contact.email, level: m)
unless r.success
contact.add_epp_error('2005', nil, r.errors, I18n.t(:parameter_value_syntax_error))
@error = true
return
end
end
true
end
def maybe_remove_address
return if Contact.address_processing?

View file

@ -15,9 +15,26 @@ module Actions
maybe_update_statuses
maybe_update_ident if ident.present?
maybe_attach_legal_doc
maybe_change_email
commit
end
def maybe_change_email
return if Rails.env.test?
[:regex, :mx].each do |m|
r = Actions::SimpleMailValidator.run(email: @new_attributes[:email], level: m)
unless r.success
contact.add_epp_error('2005', nil, r.errors, I18n.t(:parameter_value_syntax_error))
@error = true
return
end
end
true
end
def maybe_remove_address
return if Contact.address_processing?

View file

@ -0,0 +1,9 @@
module Actions
module SimpleMailValidator
extend self
def run(email:, level:)
Truemail.validate(email, with: level).result
end
end
end

View file

@ -371,6 +371,7 @@ en:
sim_error: 'SIM application error'
internal_error: 'Internal error'
client_side_status_editing_error: 'Parameter value policy error. Client-side object status management not supported'
parameter_value_syntax_error: 'Parameter value syntax error: '
# DEPP
activemodel: