From 3ba444ee09abceac73a0507130035a4bf099ffc4 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 28 Feb 2013 03:13:31 -0500 Subject: update fax tiff file --- app/controllers/trigger_controller.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'app/controllers/trigger_controller.rb') diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb index 64a5f91..6cc9fa7 100644 --- a/app/controllers/trigger_controller.rb +++ b/app/controllers/trigger_controller.rb @@ -89,7 +89,6 @@ class TriggerController < ApplicationController rescue => e logger.error "PDF fax file could not be deleted: #{pdf_file} => #{e.inspect}" end - fax_document.tiff = nil fax_document.save fax_document.render_thumbnails else -- cgit v1.2.3 From fbbbb9dfe10ad8b25d075e00f4a149086b7c27a5 Mon Sep 17 00:00:00 2001 From: spag Date: Tue, 5 Mar 2013 08:30:52 +0100 Subject: send fax notification --- app/controllers/trigger_controller.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'app/controllers/trigger_controller.rb') diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb index 6cc9fa7..8e70ef2 100644 --- a/app/controllers/trigger_controller.rb +++ b/app/controllers/trigger_controller.rb @@ -84,6 +84,7 @@ class TriggerController < ApplicationController fax_document.state = 'successful' if fax_document.save + Notifications.new_fax(fax_document).deliver begin File.delete(pdf_file) rescue => e -- cgit v1.2.3 From a710d0d8033c84b72e1a6395adfbd6beebf80730 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 6 Mar 2013 06:38:08 -0500 Subject: collect errors --- app/controllers/trigger_controller.rb | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'app/controllers/trigger_controller.rb') diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb index 8e70ef2..5e836c4 100644 --- a/app/controllers/trigger_controller.rb +++ b/app/controllers/trigger_controller.rb @@ -62,12 +62,14 @@ class TriggerController < ApplicationController def fax if !params[:fax_account_id].blank? fax_account = FaxAccount.where(:id => params[:fax_account_id].to_i).first + errors = Array.new() if fax_account fax_account.fax_documents.where(:state => 'received').each do |fax_document| pdf_file = fax_document.tiff_to_pdf if !pdf_file + errors << "#{fax_document.tiff} cound not be converted" fax_document.state = 'unsuccessful' fax_document.save next @@ -89,15 +91,21 @@ class TriggerController < ApplicationController File.delete(pdf_file) rescue => e logger.error "PDF fax file could not be deleted: #{pdf_file} => #{e.inspect}" + errors << "#{pdf_file} cound not be deleted" end fax_document.save fax_document.render_thumbnails else + errors << "#{fax_document.id} cound not be saved" fax_document.state = 'unsuccessful' fax_document.save end end - + else + errors << "fax_account=#{params[:fax_account_id]} not found" + end + + if errors.count == 0 render( :status => 200, :layout => false, @@ -105,11 +113,11 @@ class TriggerController < ApplicationController :text => "", ) else - render( - :status => 404, + render( + :status => 501, :layout => false, :content_type => 'text/plain', - :text => "", + :text => "", ) end end -- cgit v1.2.3