Mode all the actions to Interactions folder

This commit is contained in:
Alex Sherman 2021-02-08 17:44:15 +05:00 committed by Karl Erik Õunapuu
parent d7f01f24a2
commit fdef27c45e
No known key found for this signature in database
GPG key ID: C9DD647298A34764
18 changed files with 20 additions and 20 deletions

View file

@ -0,0 +1,61 @@
module Actions
class DomainDelete
attr_reader :domain
attr_reader :params
attr_reader :user
def initialize(domain, params, user)
@domain = domain
@params = params
@user = user
end
def call
return false unless @domain.can_be_deleted?
verify_not_discarded
maybe_attach_legal_doc
return false if domain.errors.any?
return false if domain.errors[:epp_errors].any?
destroy
end
def maybe_attach_legal_doc
::Actions::BaseAction.attach_legal_doc_to_new(domain, params[:legal_document], domain: true)
end
def verify_not_discarded
return unless domain.discarded?
domain.add_epp_error('2304', nil, nil, 'Object status prohibits operation')
end
def verify?
return false unless Setting.request_confirmation_on_domain_deletion_enabled
return false if params[:delete][:verified] == true
true
end
def ask_delete_verification
domain.registrant_verification_asked!(params, user.id)
domain.pending_delete!
domain.manage_automatic_statuses
end
def destroy
if verify?
ask_delete_verification
else
domain.set_pending_delete!
end
return false if domain.errors.any?
return false if domain.errors[:epp_errors].any?
true
end
end
end