mirror of
https://github.com/internetee/registry.git
synced 2025-08-05 01:11:43 +02:00
Move interactor to the Domains namespace
This commit is contained in:
parent
6f0b8b15a3
commit
42012863e2
9 changed files with 125 additions and 117 deletions
51
app/interactions/domains/update_confirm/base.rb
Normal file
51
app/interactions/domains/update_confirm/base.rb
Normal file
|
@ -0,0 +1,51 @@
|
|||
module Domains
|
||||
module UpdateConfirm
|
||||
class Base < ActiveInteraction::Base
|
||||
object :domain,
|
||||
class: Domain,
|
||||
description: 'Domain to confirm update'
|
||||
string :action
|
||||
string :initiator,
|
||||
default: nil
|
||||
|
||||
validates :domain, :action, presence: true
|
||||
validates :action, inclusion: { in: [RegistrantVerification::CONFIRMED,
|
||||
RegistrantVerification::REJECTED] }
|
||||
|
||||
def raise_errors!(domain)
|
||||
return unless domain.errors.any?
|
||||
|
||||
message = "domain #{domain.name} failed with errors #{domain.errors.full_messages}"
|
||||
throw message
|
||||
end
|
||||
|
||||
def notify_registrar(message_key)
|
||||
domain.registrar.notifications.create!(
|
||||
text: "#{I18n.t(message_key)}: #{domain.name}",
|
||||
attached_obj_id: domain.id,
|
||||
attached_obj_type: domain.class.to_s
|
||||
)
|
||||
end
|
||||
|
||||
def preclean_pendings
|
||||
domain.registrant_verification_token = nil
|
||||
domain.registrant_verification_asked_at = nil
|
||||
end
|
||||
|
||||
def clean_pendings!
|
||||
domain.registrant_verification_token = nil
|
||||
domain.registrant_verification_asked_at = nil
|
||||
domain.pending_json = {}
|
||||
clear_statuses
|
||||
end
|
||||
|
||||
def clear_statuses
|
||||
domain.statuses.delete(DomainStatus::PENDING_DELETE_CONFIRMATION)
|
||||
domain.statuses.delete(DomainStatus::PENDING_UPDATE)
|
||||
domain.statuses.delete(DomainStatus::PENDING_DELETE)
|
||||
domain.status_notes[DomainStatus::PENDING_UPDATE] = ''
|
||||
domain.status_notes[DomainStatus::PENDING_DELETE] = ''
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue