Skip to content
Open
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
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
FROM --platform=linux/amd64 ruby:3.0.3-bullseye

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

# bullseye is EOL: its packages were moved from deb.debian.org/security.debian.org to archive.debian.org
RUN sed -i -e 's|http://deb.debian.org/debian|http://archive.debian.org/debian|g' \
-e 's|http://security.debian.org/debian-security|http://archive.debian.org/debian-security|g' \
/etc/apt/sources.list

RUN apt-get update > /dev/null && apt-get install -y --no-install-recommends > /dev/null \
build-essential=* \
imagemagick=* \
Expand Down
5 changes: 5 additions & 0 deletions Dockerfile.production
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ ENV RAILS_ENV="production" \
BUNDLE_DEPLOYMENT="1" \
BUNDLE_PATH="/usr/local/bundle"

# bullseye is EOL: its packages were moved from deb.debian.org/security.debian.org to archive.debian.org
RUN sed -i -e 's|http://deb.debian.org/debian|http://archive.debian.org/debian|g' \
-e 's|http://security.debian.org/debian-security|http://archive.debian.org/debian-security|g' \
/etc/apt/sources.list

# Throw-away build stage to reduce size of final image
FROM base AS build

Expand Down
5 changes: 5 additions & 0 deletions app/controllers/admin/contacts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ def filter_by_flags(contacts)
contacts = contacts.where("ident_country_code is null or ident_country_code=''")
end

case params[:death_registry]
when 'deceased' then contacts = contacts.where.not(death_date: nil)
when 'not_checked' then contacts = contacts.where(death_registry_checked_at: nil)
end

contacts
end

Expand Down
49 changes: 46 additions & 3 deletions app/controllers/admin/domains/force_delete_controller.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
module Admin
module Domains
class ForceDeleteController < BaseController
# The reason picks the email template; without it the template was
# guessed from the domain data, e.g. "the registrant has died" for any
# private registrant. "other" sends no email, as there is no letter for it.
REASONS = %w[private_person legal_person invalid_email invalid_phone other].freeze

def create
authorize! :manage, domain
return redirect_to edit_admin_domain_url(domain), alert: t('.reason_missing') unless reason_valid?
# CheckForceDeleteLift would lift it the next day
return redirect_to edit_admin_domain_url(domain), alert: t('.no_invalid_emails') if no_invalid_emails?

notice = t('.scheduled')

domain.transaction do
result = domain.schedule_force_delete(type: force_delete_type,
notify_by_email: notify_by_email?)
notify_by_email: notify_by_email?,
reason: template_reason,
email: invalid_emails)
notice = result.errors.messages[:domain].first unless result.valid?
end

Expand All @@ -17,18 +27,51 @@ def create

def destroy
authorize! :manage, domain
domain.cancel_force_delete
deceased_contacts = deceased_contacts_of_force_delete
if domain.template_name == 'deceased_person'
# Restores the force delete it replaced, if any
DeathRegistry::ForceDeletePriority.new(domain).stop
else
domain.cancel_force_delete
end
# Otherwise the death registry check would start it again the next day
deceased_contacts.each(&:clear_death_date!)
redirect_to edit_admin_domain_url(domain), notice: t('.cancelled')
end

private

def deceased_contacts_of_force_delete
case domain.template_name
when 'deceased_person' then [domain.registrant]
when 'deceased_admin_contact' then domain.admin_contacts.select(&:death_date)
else []
end
end

def domain
@domain ||= Domain.find(params[:domain_id])
end

def reason_valid?
REASONS.include?(params[:reason])
end

def template_reason
params[:reason] unless params[:reason] == 'other'
end

def no_invalid_emails?
params[:reason] == 'invalid_email' && invalid_emails.blank?
end

# Shown in the force delete status note and the registrar's poll message
def invalid_emails
domain.contact_emails_verification_failed.join(', ').presence if params[:reason] == 'invalid_email'
end

def notify_by_email?
ActiveRecord::Type::Boolean.new.cast(params[:notify_by_email])
template_reason.present? && ActiveRecord::Type::Boolean.new.cast(params[:notify_by_email])
end

def force_delete_type
Expand Down
19 changes: 19 additions & 0 deletions app/interactions/actions/contact_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def call
maybe_validate_ident
maybe_change_email
maybe_company_is_relevant
maybe_person_is_alive
commit
maybe_validate_phone_number
maybe_validate_contact
Expand Down Expand Up @@ -115,6 +116,24 @@ def maybe_company_is_relevant
@error = true
end

# A missing or stale death registry file must not block contact creation:
# the contact is created unchecked and the daily death registry check picks it up.
def maybe_person_is_alive
return true if @error
return true unless ENV['validate_deceased_contacts'] == 'true'
return true unless contact.ident_type == 'priv' && contact.ident_country_code == 'EE'

if DeathRegistry::Lookup.new.deceased?(contact.ident)
contact.add_epp_error('2003', nil, 'ident', I18n.t('errors.messages.ident_invalid'))
@error = true
else
contact.death_registry_checked_at = Time.zone.now
end
rescue DeathRegistry::FileUnavailable => e
Rails.logger.warn("Death registry check skipped for new contact: #{e.message}")
true
end

def maybe_attach_legal_doc
::Actions::BaseAction.attach_legal_doc_to_new(contact, legal_document, domain: false)
end
Expand Down
12 changes: 7 additions & 5 deletions app/interactions/domains/force_delete/notify_by_email.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@ def execute
return unless notify_by_email

domain.skip_whois_record_update = false
template_name = domain.notification_template(explicit: reason)

if type == :fast_track
send_email
domain.update(contact_notification_sent_date: Time.zone.today)
send_email(template_name)
domain.update(contact_notification_sent_date: Time.zone.today, template_name: template_name)
else
domain.update(template_name: domain.notification_template(explicit: reason))
domain.update(template_name: template_name)
end
end

def send_email
def send_email(template_name)
DomainDeleteMailer.forced(domain: domain,
registrar: domain.registrar,
registrant: domain.registrant,
template_name: domain.notification_template).deliver_now
template_name: template_name).deliver_now
end
end
end
Expand Down
24 changes: 24 additions & 0 deletions app/interactions/domains/force_delete/notify_registrar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ module Domains
module ForceDelete
class NotifyRegistrar < Base
def execute
return notify_deceased_person if reason == 'deceased_person'
return notify_deceased_admin_contact if reason == 'deceased_admin_contact'

email.present? ? notify_with_email : notify_without_email
end

Expand All @@ -17,6 +20,27 @@ def force_delete_start_date
end
end

def notify_deceased_person
domain.registrar.notifications.create!(
text: I18n.t('force_delete_deceased_person',
domain_name: domain.name,
ident: domain.registrant.ident,
force_delete_start_date: force_delete_start_date,
outzone_date: domain.outzone_date,
purge_date: domain.purge_date)
)
end

def notify_deceased_admin_contact
domain.registrar.notifications.create!(
text: I18n.t('force_delete_deceased_admin_contact',
domain_name: domain.name,
notes: notes,
force_delete_start_date: domain.force_delete_start&.strftime('%d.%m.%Y') || '-',
valid_to: domain.valid_to.strftime('%d.%m.%Y'))
)
end

def notify_without_email
template = if reason == 'invalid_company'
I18n.t('invalid_ident',
Expand Down
17 changes: 16 additions & 1 deletion app/interactions/domains/force_delete/set_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@ def force_delete_fast_track

def force_delete_soft
years = (domain.valid_to.to_date - Time.zone.today).to_i / 365
soft_forcedelete_dates(years) if years.positive?
if years.positive?
soft_forcedelete_dates(years)
elsif reason == 'deceased_admin_contact'
deceased_admin_contact_dates
end
end

private

def set_status_notes
domain.status_notes[DomainStatus::FORCE_DELETE] = "Company no: #{domain.registrant.ident} #{"+ #{notes}" if notes.present?}" if reason == 'invalid_company'
domain.status_notes[DomainStatus::FORCE_DELETE] = email if reason == 'invalid_email'
domain.status_notes[DomainStatus::FORCE_DELETE] = notes if %w[deceased_person deceased_admin_contact].include?(reason)
end

def soft_forcedelete_dates(years)
Expand All @@ -38,6 +43,16 @@ def soft_forcedelete_dates(years)
Setting.redemption_grace_period.days
end

# A domain expiring within a year gets no soft force delete dates, but the
# deceased admin contact email must name the deletion date. The process
# starts at expiry, or tomorrow if the domain has already expired.
def deceased_admin_contact_dates
domain.force_delete_start = [domain.valid_to, Time.zone.now.beginning_of_day + 1.day].max
domain.force_delete_date = domain.force_delete_start +
Setting.expire_warning_period.days +
Setting.redemption_grace_period.days
end

def redemption_grace_period_days
Setting.redemption_grace_period.days + 1.day
end
Expand Down
14 changes: 14 additions & 0 deletions app/jobs/check_force_delete_lift.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,24 @@ def perform
end

sync_force_delete_status_notes
lift_deceased_admin_contact_force_deletes
end

private

# Started by DeathRegistry::DeceasedDomainContacts when the last required
# admin contact of a domain died. The deceased contact itself is removed by
# DeathRegistryCheckJob once it is no longer required.
def lift_deceased_admin_contact_force_deletes
Domain.where("force_delete_data->'template_name' = ?", 'deceased_admin_contact')
.includes(:admin_contacts, :registrant).find_each do |domain|
living_admin_contacts = domain.admin_contacts.count { |contact| contact.death_date.nil? }
next if living_admin_contacts < domain.required_admin_contacts_count

domain.cancel_force_delete
end
end

def find_domains_to_lift_force_delete
Domain.where("'#{DomainStatus::FORCE_DELETE}' = ANY (statuses)").includes(:registrant, :contacts)
.select { |d| d.registrant.need_to_lift_force_delete? && d.contacts.all?(&:need_to_lift_force_delete?) }
Expand Down
Loading
Loading