From 7a71e1de8856f241e271d14ff3cf04c28544ed8a Mon Sep 17 00:00:00 2001 From: f Date: Fri, 12 Apr 2024 15:31:47 -0300 Subject: [PATCH] fix: no fallar si no hay sitio #16007 --- app/jobs/application_job.rb | 2 +- app/jobs/backtrace_job.rb | 1 + app/jobs/contact_job.rb | 2 ++ app/jobs/git_pull_job.rb | 2 ++ app/jobs/git_push_job.rb | 2 ++ 5 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb index 66345949..37ec0f76 100644 --- a/app/jobs/application_job.rb +++ b/app/jobs/application_job.rb @@ -8,6 +8,6 @@ class ApplicationJob < ActiveJob::Base # Si falla por cualquier cosa informar y descartar discard_on(Exception) do |error| - ExceptionNotifier.notify_exception(error, data: { site: site.name }) + ExceptionNotifier.notify_exception(error, data: { site: @site&.name }) end end diff --git a/app/jobs/backtrace_job.rb b/app/jobs/backtrace_job.rb index 830dc9b3..5e9a05cf 100644 --- a/app/jobs/backtrace_job.rb +++ b/app/jobs/backtrace_job.rb @@ -9,6 +9,7 @@ class BacktraceJob < ApplicationJob attr_reader :params def perform(site:, params:) + @site = site @params = params unless sources.empty? diff --git a/app/jobs/contact_job.rb b/app/jobs/contact_job.rb index 2ac80ce3..d4c2677f 100644 --- a/app/jobs/contact_job.rb +++ b/app/jobs/contact_job.rb @@ -6,6 +6,8 @@ class ContactJob < ApplicationJob # @param [String] # @param [Hash] def perform(site, form_name, form, origin = nil) + @site = site + # Sanitizar los valores form.each_key do |key| form[key] = ActionController::Base.helpers.sanitize form[key] diff --git a/app/jobs/git_pull_job.rb b/app/jobs/git_pull_job.rb index 58a4e6b1..72e20be0 100644 --- a/app/jobs/git_pull_job.rb +++ b/app/jobs/git_pull_job.rb @@ -7,6 +7,8 @@ class GitPullJob < ApplicationJob # @param :usuarie [Usuarie] # @return [nil] def perform(site, usuarie) + @site = site + return unless site.repository.origin return unless site.repository.fetch.positive? diff --git a/app/jobs/git_push_job.rb b/app/jobs/git_push_job.rb index d8c811ba..4df9f5aa 100644 --- a/app/jobs/git_push_job.rb +++ b/app/jobs/git_push_job.rb @@ -6,6 +6,8 @@ class GitPushJob < ApplicationJob # @param :site [Site] # @return [nil] def perform(site) + @site = site + site.repository.push if site.repository.origin end end