diff options
author | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-03-07 11:37:03 +0100 |
---|---|---|
committer | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-03-07 11:37:03 +0100 |
commit | 11f186a118285fbc87a536af26730780a9ad01f5 (patch) | |
tree | fe6363b036f60f238916d070b3d0cb0625dd53c8 /app/controllers/trigger_controller.rb | |
parent | 2b94b16ee1201d15b3b9d66e142df311141a47db (diff) | |
parent | 3e19646f46c772e10ed3d7a45e8c974ab23f625b (diff) |
Merge branch 'develop'5.1.1
Diffstat (limited to 'app/controllers/trigger_controller.rb')
-rw-r--r-- | app/controllers/trigger_controller.rb | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb index 64a5f91..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 @@ -84,20 +86,26 @@ class TriggerController < ApplicationController fax_document.state = 'successful' if fax_document.save + Notifications.new_fax(fax_document).deliver begin 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.tiff = nil 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 => "<!-- OK -->", ) else - render( - :status => 404, + render( + :status => 501, :layout => false, :content_type => 'text/plain', - :text => "<!-- Account not found -->", + :text => "<!-- ERRORS: #{errors.join(', ')} -->", ) end end |