diff --git a/package.json b/package.json index ac23434..09ba639 100644 --- a/package.json +++ b/package.json @@ -3,26 +3,26 @@ "version": "0.1.0", "author": "Steve Sokol", "devDependencies": { - "grunt": "~0.4.1", - "grunt-contrib-jshint": "~0.6.3", - "grunt-contrib-watch": "~0.5.3", + "grunt": "^1.0.3", "grunt-contrib-compass": "~0.6.0", "grunt-contrib-concat": "~0.5.1", - "util": "~0.10.3", - "grunt-execute": "~0.2.2" + "grunt-contrib-jshint": "^1.1.0", + "grunt-contrib-watch": "^1.1.0", + "grunt-execute": "~0.2.2", + "util": "~0.10.3" }, "dependencies": { - "md5": "~2.0.0", - "redis": "~2.2.5", - "hiredis": "~0.4.1", + "ari-client": "^1.1.1", + "bluebird": "~2.10.2", + "download": "^7.0.0", + "express": "^4.16.3", "flite": "~0.1.2", - "node-fetch": "~1.3.3", - "xmldoc": "~0.3.2", - "download": "~4.4.1", "form-data": "~1.0.0-rc3", - "bluebird": "~2.10.2", - "ari-client": "~0.3.0", + "hiredis": "~0.4.1", + "md5": "~2.0.0", + "node-fetch": "~1.3.3", "node-uuid": "~1.4.3", - "express": "~4.13.3" + "redis": "~2.2.5", + "xmldoc": "~0.3.2" } } diff --git a/src/aria_call.js b/src/aria_call.js index c30ec58..0d75637 100644 --- a/src/aria_call.js +++ b/src/aria_call.js @@ -47,8 +47,6 @@ var makeAction = function(xml, parent) { // make subsequent requests, optionally passing back data var fetchTwiml = function(method, twimlURL, call, data) { - console.log("Fetching Twiml From: " + twimlURL); - var options = { method: method || "POST", body: data || null @@ -59,6 +57,8 @@ var fetchTwiml = function(method, twimlURL, call, data) { twimlURL = url.resolve(call.baseUrl, twimlURL); } + console.log("Fetching Twiml From:%s Options:%s", twimlURL, util.inspect(options)); + fetch(twimlURL, options) .then(function(res) { return res.text(); @@ -165,8 +165,9 @@ function AriaCall(client, channel, url, twiml, done) { }); // fetch the Twiml for this call + // + url += "&CallSid=" + this.sid; fetchTwiml("GET", url, that, null); - } diff --git a/src/twiml_play.js b/src/twiml_play.js index 2519405..5bd36ec 100644 --- a/src/twiml_play.js +++ b/src/twiml_play.js @@ -119,24 +119,18 @@ twimlActions.Play = function(command, callback) { // generate a hash which we will use as the filename var hashName = md5(fileURL.href); - var fileName = hashName + path.extname(fileURL.href); + var options = { + filename : hashName + path.extname(fileURL.href) + }; - // create a downloader object and fetch the file - var dl = new download({ - mode: "755" + // download file + download(fileURL.href, ariaConfig.audioPath, options).then(() => { + console.log("Retrieved %s -> %s%s", fileURL.href, ariaConfig.audioPath, options.filename); + play(hashName, exit); + }).catch((err) => { + console.log("Channel " + channel.id + " - ERROR: Unable to download requested file."); + console.error(err); }); - dl.get(fileURL.href) - .dest(ariaConfig.audioPath) - .rename(fileName) - .run(function(err, files) { - if (err) { - console.log("Channel " + channel.id + " - ERROR: Unable to download requested file."); - console.error(err); - exit(); - } else { - play(hashName, exit); - } - }); };