From eaf887fa5cccfc07e9cc60a682cecf48e35922ae Mon Sep 17 00:00:00 2001 From: Ian Date: Sun, 20 Apr 2014 19:01:21 -0700 Subject: [PATCH] Include key in http response --- app.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app.js b/app.js index 5d5e460..212ba00 100644 --- a/app.js +++ b/app.js @@ -80,16 +80,22 @@ function textRequestHandler(req, res, number, region, key) { ip: ip }; - var doSendText = function() { + var doSendText = function(response_obj) { + response_obj = response_obj || {}; + // Time to actually send the message sendText(req.body.number, message, region, function(err) { if (err) { mpq.track('sendText failed', tracking_details); - res.send({success:false, message:'Communication with SMS gateway failed.'}); + res.send(_.extend(response_obj, + { + success:false, + message:'Communication with SMS gateway failed.' + })); } else { mpq.track('sendText success', tracking_details); - res.send({success:true}); + res.send(_.extend(response_obj, {success:true})); } }); }; @@ -101,7 +107,7 @@ function textRequestHandler(req, res, number, region, key) { mpq.track('sendText skipping verification', _.extend(tracking_details, { key: key, })); - doSendText(); + doSendText({used_key: key}); return; }