diff options
author | Seb Bacon <seb.bacon@gmail.com> | 2012-07-11 08:38:08 +0100 |
---|---|---|
committer | Seb Bacon <seb.bacon@gmail.com> | 2012-07-11 08:38:08 +0100 |
commit | 4490482cedf362390b25efe453232ac1b7dfce99 (patch) | |
tree | 5833f1d90537a1c92b7b9fd33cc6b60cd4b188f3 /app/controllers/api_controller.rb | |
parent | 2f6af7486706e9a39b220cabea9a4a47839d59a6 (diff) |
In the API, when parsing posted responses, assume all multipart mail parts that are Tempfiles are attachments
Diffstat (limited to 'app/controllers/api_controller.rb')
-rw-r--r-- | app/controllers/api_controller.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb index 6117435db..3244a4c12 100644 --- a/app/controllers/api_controller.rb +++ b/app/controllers/api_controller.rb @@ -71,10 +71,18 @@ class ApiController < ApplicationController end + def _get_attachments_from_params(params) + attachments = [] + params.each_pair do |k, v| + attachments << v if v.is_a? Tempfile + end + return attachments + end + def add_correspondence request = InfoRequest.find(params[:id]) json = ActiveSupport::JSON.decode(params[:correspondence_json]) - attachments = params[:attachments] + attachments = _get_attachments_from_params(params) direction = json["direction"] body = json["body"] @@ -147,7 +155,6 @@ class ApiController < ApplicationController :filename => filename ) end - mail = RequestMailer.create_external_response(request, body, sent_at, attachment_hashes) request.receive(mail, mail.encoded, true) end |