Complete creation of interactors

This commit is contained in:
Alex Sherman 2020-11-10 13:50:38 +05:00
parent 4b980a07f5
commit 03754b542b
7 changed files with 78 additions and 17 deletions

View file

@ -6,8 +6,8 @@ class Domain
def call
return unless context.domain.discarded?
raise StandardError,
'Force delete procedure cannot be scheduled while a domain is discarded'
message = 'Force delete procedure cannot be scheduled while a domain is discarded'
context.fail!( message: message )
end
end
end

View file

@ -0,0 +1,31 @@
class Domain
module ForceDelete
class NotifyByEmail
include Interactor
def call
return unless notify_by_email?
if context.type == :fast_track
send_email
context.domain.update(contact_notification_sent_date: Time.zone.today)
else
context.domain.update(template_name: context.domain.notification_template)
end
end
private
def notify_by_email?
ActiveRecord::Type::Boolean.new.cast(params[:notify_by_email])
end
def send_email
DomainDeleteMailer.forced(domain: context.domain,
registrar: context.domain.registrar,
registrant: context.domain.registrant,
template_name: context.domain.notification_template).deliver_now
end
end
end
end

View file

@ -0,0 +1,16 @@
class Domain
module ForceDelete
class NotifyRegistrar
include Interactor
def call
domain = context.domain
domain.registrar.notifications.create!(text: t('force_delete_set_on_domain',
domain_name: domain.name,
outzone_date: domain.outzone_date,
purge_date: domain.purge_date))
end
end
end
end

View file

@ -3,10 +3,14 @@ class Domain
class PrepareDomain
include Interactor
STATUSES_TO_SET = [DomainStatus::FORCE_DELETE,
DomainStatus::SERVER_RENEW_PROHIBITED,
DomainStatus::SERVER_TRANSFER_PROHIBITED].freeze
def call
domain = context.domain
domain.statuses_before_force_delete = domain.statuses
domain.statuses |= domain.class.STATUSES_TO_SET
domain.statuses |= STATUSES_TO_SET
domain.save(validate: false)
end
end

View file

@ -16,7 +16,10 @@ class Domain
end
def force_delete_fast_track
domain.force_delete_date = force_delete_fast_track_start_date + 1.day
domain.force_delete_date = Time.zone.today +
Setting.expire_warning_period.days +
Setting.redemption_grace_period.days +
1.day
domain.force_delete_start = Time.zone.today + 1.day
end