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)
|
def run(domain_id)
|
||||||
domain = Domain.find(domain_id)
|
domain = Domain.find(domain_id)
|
||||||
|
|
||||||
::PaperTrail.request.whodunnit = "job - #{self.class.name}"
|
DomainDeleteInteraction::Delete.run(domain: domain)
|
||||||
WhoisRecord.where(domain_id: domain.id).destroy_all
|
# ::PaperTrail.request.whodunnit = "job - #{self.class.name}"
|
||||||
|
# WhoisRecord.where(domain_id: domain.id).destroy_all
|
||||||
domain.destroy
|
#
|
||||||
bye_bye = domain.versions.last
|
# domain.destroy
|
||||||
domain.registrar.notifications.create!(
|
# bye_bye = domain.versions.last
|
||||||
text: "#{I18n.t(:domain_deleted)}: #{domain.name}",
|
# domain.registrar.notifications.create!(
|
||||||
attached_obj_id: bye_bye.id,
|
# text: "#{I18n.t(:domain_deleted)}: #{domain.name}",
|
||||||
attached_obj_type: bye_bye.class.to_s
|
# attached_obj_id: bye_bye.id,
|
||||||
)
|
# attached_obj_type: bye_bye.class.to_s
|
||||||
|
# )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue