diff --git a/app/controllers/api/v1/contact_controller.rb b/app/controllers/api/v1/contact_controller.rb index 8b592a5a..deacf4a7 100644 --- a/app/controllers/api/v1/contact_controller.rb +++ b/app/controllers/api/v1/contact_controller.rb @@ -20,7 +20,8 @@ module Api # El sitio nos dice a dónde tenemos que ir. ContactJob.perform_async site.id, params[:form], - contact_params.to_h.symbolize_keys + contact_params.to_h.symbolize_keys, + params[:redirect] redirect_to params[:redirect] || origin.to_s end diff --git a/app/jobs/contact_job.rb b/app/jobs/contact_job.rb index 63c45467..c15d7eee 100644 --- a/app/jobs/contact_job.rb +++ b/app/jobs/contact_job.rb @@ -5,13 +5,13 @@ class ContactJob < ApplicationJob # @param [Integer] # @param [String] # @param [Hash] - def perform(site_id, form_name, form) + def perform(site_id, form_name, form, origin = nil) # Retrocompabilidad al actualizar a 2.7.1 # @see ApplicationJob#site @params = { site_id: site_id } # Sanitizar los valores - form.keys.each do |key| + form.each_key do |key| form[key] = ActionController::Base.helpers.sanitize form[key] end @@ -24,7 +24,8 @@ class ContactJob < ApplicationJob ContactMailer.with(form_name: form_name, form: form, site_id: site_id, - usuaries_emails: u) + usuaries_emails: u, + origin: origin) .notify_usuaries.deliver_now end end diff --git a/app/views/contact_mailer/notify_usuaries.html.haml b/app/views/contact_mailer/notify_usuaries.html.haml index 792660b7..f3c3903b 100644 --- a/app/views/contact_mailer/notify_usuaries.html.haml +++ b/app/views/contact_mailer/notify_usuaries.html.haml @@ -1,3 +1,6 @@ +- if @params[:origin].present? + %p= @params[:origin] + - @params[:form].each do |field, value| %p %strong= @params[:form_definition].t(field) + ':' diff --git a/app/views/contact_mailer/notify_usuaries.text.haml b/app/views/contact_mailer/notify_usuaries.text.haml index 1c440de8..8165a2e5 100644 --- a/app/views/contact_mailer/notify_usuaries.text.haml +++ b/app/views/contact_mailer/notify_usuaries.text.haml @@ -1,3 +1,5 @@ +- @params[:origin] + - @params[:form].each do |field, value| = "#{@params[:form_definition].t(field)}: #{value}" \