mirror of
https://github.com/internetee/registry.git
synced 2025-07-21 18:26:06 +02:00
Move DomainDelete to interactor design pattern
This commit is contained in:
parent
42b9adbf44
commit
d406334926
4 changed files with 41 additions and 10 deletions
7
app/interactions/domain_delete_interaction/base.rb
Normal file
7
app/interactions/domain_delete_interaction/base.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
module DomainDeleteInteraction
|
||||
class Base < ActiveInteraction::Base
|
||||
object :domain,
|
||||
class: Domain,
|
||||
description: 'Domain to delete'
|
||||
end
|
||||
end
|
11
app/interactions/domain_delete_interaction/delete.rb
Normal file
11
app/interactions/domain_delete_interaction/delete.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
module DomainDeleteInteraction
|
||||
class Delete < :Base
|
||||
def execute
|
||||
::PaperTrail.request.whodunnit = "interaction - #{self.class.name}"
|
||||
WhoisRecord.where(domain_id: domain.id).destroy_all
|
||||
|
||||
domain.destroy
|
||||
compose(NotifyRegistrar, inputs)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,12 @@
|
|||
module DomainDeleteInteraction
|
||||
class NotifyRegistrar < Delete
|
||||
def execute
|
||||
bye_bye = domain.versions.last
|
||||
domain.registrar.notifications.create!(
|
||||
text: "#{I18n.t(:domain_deleted)}: #{domain.name}",
|
||||
attached_obj_id: bye_bye.id,
|
||||
attached_obj_type: bye_bye.class.to_s
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -3,15 +3,16 @@ class DomainDeleteJob < Que::Job
|
|||
def run(domain_id)
|
||||
domain = Domain.find(domain_id)
|
||||
|
||||
::PaperTrail.request.whodunnit = "job - #{self.class.name}"
|
||||
WhoisRecord.where(domain_id: domain.id).destroy_all
|
||||
|
||||
domain.destroy
|
||||
bye_bye = domain.versions.last
|
||||
domain.registrar.notifications.create!(
|
||||
text: "#{I18n.t(:domain_deleted)}: #{domain.name}",
|
||||
attached_obj_id: bye_bye.id,
|
||||
attached_obj_type: bye_bye.class.to_s
|
||||
)
|
||||
DomainDeleteInteraction::Delete.run(domain: domain)
|
||||
# ::PaperTrail.request.whodunnit = "job - #{self.class.name}"
|
||||
# WhoisRecord.where(domain_id: domain.id).destroy_all
|
||||
#
|
||||
# domain.destroy
|
||||
# bye_bye = domain.versions.last
|
||||
# domain.registrar.notifications.create!(
|
||||
# text: "#{I18n.t(:domain_deleted)}: #{domain.name}",
|
||||
# attached_obj_id: bye_bye.id,
|
||||
# attached_obj_type: bye_bye.class.to_s
|
||||
# )
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue