aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/api_controller.rb
diff options
context:
space:
mode:
authorSeb Bacon <seb.bacon@gmail.com>2012-07-17 10:02:26 +0100
committerSeb Bacon <seb.bacon@gmail.com>2012-07-17 10:02:26 +0100
commit49ff1a1c0304cd292d3eae80dc0b91b2f83727b9 (patch)
tree73c4acec7f3a521402e07794151b6b5cb7765629 /app/controllers/api_controller.rb
parent00d67fc7aeb839af3a5f02a242b4bb8c29b9383d (diff)
Revert "Revert "In the API, when parsing posted responses, assume all multipart mail parts that are Tempfiles are attachments""
This reverts commit d4a700da1760fc2ba09cf19613a995569e4965ea.
Diffstat (limited to 'app/controllers/api_controller.rb')
-rw-r--r--app/controllers/api_controller.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb
index 718c31e6f..a7853c787 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