From b818408f3e7f5b2c9a4a0983e26102af9e428073 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 31 Mar 2023 12:14:14 -0300 Subject: [PATCH] feat: indicarle a distributed press que elimine el sitio sutty/distributed-press-api-client#10 --- Gemfile | 2 +- Gemfile.lock | 2 +- app/models/deploy_distributed_press.rb | 11 ++++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 9d1b6d67..2ff1c68c 100644 --- a/Gemfile +++ b/Gemfile @@ -39,7 +39,7 @@ gem 'commonmarker' gem 'devise' gem 'devise-i18n' gem 'devise_invitable' -gem 'distributed-press-api-client', '~> 0.2.2' +gem 'distributed-press-api-client', '~> 0.2.3' gem 'njalla-api-client' gem 'email_address', git: 'https://github.com/fauno/email_address', branch: 'i18n' gem 'exception_notification' diff --git a/Gemfile.lock b/Gemfile.lock index c2c29531..30619795 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -622,7 +622,7 @@ DEPENDENCIES devise devise-i18n devise_invitable - distributed-press-api-client (~> 0.2.2) + distributed-press-api-client (~> 0.2.3) dotenv-rails down ed25519 diff --git a/app/models/deploy_distributed_press.rb b/app/models/deploy_distributed_press.rb index 64c66cfc..ca10218a 100644 --- a/app/models/deploy_distributed_press.rb +++ b/app/models/deploy_distributed_press.rb @@ -16,6 +16,7 @@ class DeployDistributedPress < Deploy store :values, accessors: %i[hostname remote_site_id remote_info], coder: JSON before_create :create_remote_site!, :create_njalla_records! + before_destroy :delete_remote_site! DEPENDENCIES = %i[deploy_local] @@ -120,9 +121,9 @@ class DeployDistributedPress < Deploy self.remote_site_id = created_site[:id] self.remote_info = created_site.to_h + nil rescue DistributedPress::V1::Error => e ExceptionNotifier.notify_exception(e, data: { site: site.name }) - ensure nil end @@ -156,6 +157,14 @@ class DeployDistributedPress < Deploy nil end + def delete_remote_site! + site_client.delete(publishing_site) + nil + rescue DistributedPress::V1::Error => e + ExceptionNotifier.notify_exception(e, data: { site: site.name }) + nil + end + # Actualizar registros en Njalla # # @return [Njalla::V1::Domain]