added dns validation job

This commit is contained in:
oleghasjanov 2025-08-07 11:26:32 +03:00
parent 53510cad43
commit aa6e2e99ec
2 changed files with 14 additions and 4 deletions

View file

@ -0,0 +1,8 @@
class DNSValidationJob < ApplicationJob
queue_as :default
def perform(domain_id)
domain = Domain.find(domain_id)
DNSValidator.validate(domain: domain, name: domain.name)
end
end

View file

@ -6,8 +6,10 @@ class DNSValidator
attr_reader :domain, :results attr_reader :domain, :results
def initialize(domain) def initialize(domain:, name:)
@domain = domain @domain = domain.present? ? domain : Domain.find_by_name(name)
raise "Domain not found" if @domain.blank?
@results = { @results = {
nameservers: {}, nameservers: {},
dns_records: {}, dns_records: {},
@ -18,8 +20,8 @@ class DNSValidator
} }
end end
def self.validate(domain) def self.validate(domain:, name:)
new(domain).validate new(domain: domain, name: name).validate
end end
def validate def validate