Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add invalid ident notification for company register status checks #2717

Merged
merged 3 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions ai/sop/update_company_status_rake.md

This file was deleted.

34 changes: 25 additions & 9 deletions app/interactions/domains/force_delete/notify_registrar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,38 @@ def execute
end

def notify_without_email
template = I18n.t('force_delete_set_on_domain',
domain_name: domain.name,
outzone_date: domain.outzone_date,
purge_date: domain.purge_date)
template = if reason == 'invalid_company'
I18n.t('invalid_ident',
ident: domain.registrant.ident,
domain_name: domain.name,
outzone_date: domain.outzone_date,
purge_date: domain.purge_date)
else
I18n.t('force_delete_set_on_domain',
domain_name: domain.name,
outzone_date: domain.outzone_date,
purge_date: domain.purge_date)
end

return if domain.registrar&.notifications&.last&.text&.include? template

domain.registrar.notifications.create!(text: template)
end

def notify_with_email
template = I18n.t('force_delete_auto_email',
domain_name: domain.name,
outzone_date: domain.outzone_date,
purge_date: domain.purge_date,
email: email)
template = if reason == 'invalid_company'
I18n.t('invalid_ident',
ident: domain.registrant.ident,
domain_name: domain.name,
outzone_date: domain.outzone_date,
purge_date: domain.purge_date)
else
I18n.t('force_delete_auto_email',
domain_name: domain.name,
outzone_date: domain.outzone_date,
purge_date: domain.purge_date,
email: email)
end

return if domain.registrar&.notifications&.last&.text&.include? template

Expand Down
1 change: 0 additions & 1 deletion app/interactions/domains/force_delete/post_set_process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def execute
# Allow deletion
statuses.delete(DomainStatus::CLIENT_DELETE_PROHIBITED)

puts "Try to save domain: #{domain.name} with statuses: #{statuses}"
domain.save(validate: false)
end
end
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,7 @@ en:
actions: Actions
contact_has_been_archived: 'Contact with code %{contact_code} has been archieved because it has been orphaned for longer than %{orphan_months} months.'
dns_policy_violation: "Data management policy violation: DNSKEY does not match or not found in the authoritative nameservers"
invalid_ident: 'Force delete set on domain %{domain_name}. Outzone date: %{outzone_date}. Purge date: %{purge_date}. Invalid ident %{ident}'

number:
currency:
Expand Down
2 changes: 2 additions & 0 deletions config/locales/et.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ et:
taken: 'on juba lisatud'
ipv6:
taken: 'on juba lisatud'

invalid_ident: 'Jõustatud kustutamine määratud domainile %{domain_name}. Väljaandmise kuupäev: %{outzone_date}. Kustutamise kuupäev: %{purge_date}. Vigane ident %{ident}'
2 changes: 1 addition & 1 deletion lib/tasks/company_status.rake
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace :company_status do

puts "*** Run 3 step. I process companies, update their information, and sort them into different files based on whether the companies are missing or removed from the business registry ***"

whitelisted_companies = JSON.parse(ENV['whitelist_companies']) # ["12345678", "87654321"]
whitelisted_companies = ENV['whitelist_companies'].present? ? JSON.parse(ENV['whitelist_companies']) : []

contacts_query = Contact.where(ident_type: 'org', ident_country_code: 'EE')

Expand Down
36 changes: 36 additions & 0 deletions test/jobs/company_register_status_job_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,42 @@ def object.simple_data(registration_number:)
CompanyRegister::Client.define_singleton_method(:new, original_new_method)
end

def test_companies_with_invalid_ident_should_receive_invalid_ident_notification
original_new_method = CompanyRegister::Client.method(:new)
CompanyRegister::Client.define_singleton_method(:new) do
object = original_new_method.call
def object.simple_data(registration_number:)
[Company.new('16752073', 'ACME Ltd', DELETED)]
end
object
end

@registrant_acme.update!(
company_register_status: Contact::DELETED,
checked_company_at: nil,
ident_type: 'org',
ident_country_code: 'EE',
ident: '16752073'
)

@registrant_acme.reload

CompanyRegisterStatusJob.perform_now(14, 0, 100)

@registrant_acme.reload

assert_equal Contact::DELETED, @registrant_acme.company_register_status

template = I18n.t('invalid_ident',
ident: @registrant_acme.ident,
domain_name: @registrant_acme.registrant_domains.first.name,
outzone_date: @registrant_acme.registrant_domains.first.outzone_date,
purge_date: @registrant_acme.registrant_domains.first.purge_date)
assert_equal @registrant_acme.registrant_domains.first.registrar.notifications.last.text, template

CompanyRegister::Client.define_singleton_method(:new, original_new_method)
end

def test_companies_with_force_delete_and_status_R_should_be_lifted
original_new_method = CompanyRegister::Client.method(:new)
CompanyRegister::Client.define_singleton_method(:new) do
Expand Down
2 changes: 0 additions & 2 deletions test_data 2.csv

This file was deleted.

2 changes: 0 additions & 2 deletions test_data.csv

This file was deleted.

Loading