From 2547fc90a8630aec7f31af8be0bebf5e6c68dca1 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Mon, 9 Jul 2012 12:43:55 +0100 Subject: Calls to API that are expected to return JSON are always expected to return something, even when there are no errors. --- app/controllers/api_controller.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'app/controllers/api_controller.rb') diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb index 2ba88eb1a..6117435db 100644 --- a/app/controllers/api_controller.rb +++ b/app/controllers/api_controller.rb @@ -151,8 +151,9 @@ class ApiController < ApplicationController mail = RequestMailer.create_external_response(request, body, sent_at, attachment_hashes) request.receive(mail, mail.encoded, true) end - - head :no_content + render :json => { + 'url' => make_url("request", request.url_title), + } end def body_request_events -- cgit v1.2.3 From 4490482cedf362390b25efe453232ac1b7dfce99 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Wed, 11 Jul 2012 08:38:08 +0100 Subject: In the API, when parsing posted responses, assume all multipart mail parts that are Tempfiles are attachments --- app/controllers/api_controller.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'app/controllers/api_controller.rb') 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 -- cgit v1.2.3 From d4a700da1760fc2ba09cf19613a995569e4965ea Mon Sep 17 00:00:00 2001 From: Robin Houston Date: Mon, 16 Jul 2012 18:05:39 +0100 Subject: Revert "In the API, when parsing posted responses, assume all multipart mail parts that are Tempfiles are attachments" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change makes the tests fail, I think, and doesn’t have (IMHO) a desperately strong rationale, so let’s try it without for now. This reverts commit 4490482cedf362390b25efe453232ac1b7dfce99. --- app/controllers/api_controller.rb | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'app/controllers/api_controller.rb') diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb index 3244a4c12..6117435db 100644 --- a/app/controllers/api_controller.rb +++ b/app/controllers/api_controller.rb @@ -71,18 +71,10 @@ 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 = _get_attachments_from_params(params) + attachments = params[:attachments] direction = json["direction"] body = json["body"] @@ -155,6 +147,7 @@ class ApiController < ApplicationController :filename => filename ) end + mail = RequestMailer.create_external_response(request, body, sent_at, attachment_hashes) request.receive(mail, mail.encoded, true) end -- cgit v1.2.3