From 943bf7b5bdafd2080736d8cdf4774ee6632d5b91 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 31 Mar 2023 14:38:04 -0300 Subject: [PATCH] fix: no pisar las datos de njalla con los de distributed press --- app/models/deploy_distributed_press.rb | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/app/models/deploy_distributed_press.rb b/app/models/deploy_distributed_press.rb index b77dfe19..081ceeb5 100644 --- a/app/models/deploy_distributed_press.rb +++ b/app/models/deploy_distributed_press.rb @@ -38,7 +38,7 @@ class DeployDistributedPress < Deploy raise DeployJob::DeployException, 'El sitio no se creĆ³ en Distributed Press' end - if create_njalla_records? && remote_info['njalla'].blank? + if create_njalla_records? && remote_info[:njalla].blank? raise DeployJob::DeployException, 'No se pudieron crear los registros necesarios en Njalla' end @@ -52,7 +52,8 @@ class DeployDistributedPress < Deploy end end - update remote_info: c.show(publishing_site).to_h + self.remote_info[:distributed_press] = c.show(publishing_site).to_h + save status = c.publish(publishing_site, deploy_local.destination) @@ -77,7 +78,7 @@ class DeployDistributedPress < Deploy # Devuelve las URLs de todos los protocolos def urls - remote_info[:links].values.map do |protocol| + remote_info.dig(:distributed_press, :links).values.map do |protocol| [ protocol[:link], protocol[:gateway] ] end.flatten.compact.select do |link| link.include? '://' @@ -124,7 +125,8 @@ class DeployDistributedPress < Deploy created_site = site_client.create(create_site) self.remote_site_id = created_site[:id] - self.remote_info = created_site.to_h + self.remote_info ||= {} + self.remote_info[:distributed_press] = created_site.to_h nil rescue DistributedPress::V1::Error => e ExceptionNotifier.notify_exception(e, data: { site: site.name }) @@ -141,15 +143,15 @@ class DeployDistributedPress < Deploy return unless create_njalla_records? self.remote_info ||= {} - self.remote_info['njalla'] ||= {} - self.remote_info['njalla']['a'] ||= njalla.add_record(name: site.name, type: 'CNAME', content: "#{Site.domain}.").to_h - self.remote_info['njalla']['cname'] ||= njalla.add_record(name: "www.#{site.name}", type: 'CNAME', content: "#{Site.domain}.").to_h - self.remote_info['njalla']['ns'] ||= njalla.add_record(name: "_dnslink.#{site.name}", type: 'NS', content: "#{publisher.hostname}.").to_h + self.remote_info[:njalla] ||= {} + self.remote_info[:njalla][:a] ||= njalla.add_record(name: site.name, type: 'CNAME', content: "#{Site.domain}.").to_h + self.remote_info[:njalla][:cname] ||= njalla.add_record(name: "www.#{site.name}", type: 'CNAME', content: "#{Site.domain}.").to_h + self.remote_info[:njalla][:ns] ||= njalla.add_record(name: "_dnslink.#{site.name}", type: 'NS', content: "#{publisher.hostname}.").to_h nil rescue HTTParty::Error => e ExceptionNotifier.notify_exception(e, data: { site: site.name }) - self.remote_info['njalla'] = nil + self.remote_info.delete :njalla ensure nil end