From b61a96c9dae2e1ab5d535aba0da3cfbb61c3a361 Mon Sep 17 00:00:00 2001 From: tedhuang Date: Tue, 19 Apr 2016 15:00:38 -0700 Subject: [PATCH 1/7] Added scope "public_content" required by api call to user_self_liked. Some error checking to prevent referencing undefined medias object. Bumped version of instagram-node dependency to 0.5.8. --- instagram/instagram.js | 14 ++++++++++---- instagram/package.json | 4 ++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/instagram/instagram.js b/instagram/instagram.js index 5e00f97d..bd8dda21 100644 --- a/instagram/instagram.js +++ b/instagram/instagram.js @@ -79,9 +79,10 @@ module.exports = function(RED) { node.ig.user_media_recent('self', { count : 1, min_id : null, max_id : null}, function(err, medias, pagination, remaining, limit) { if (err) { node.warn(RED._("instagram.warn.userphoto-fetch-fail", {err: err})); + return; } - if(medias.length > 0) { // if the user has uploaded something to Instagram already + if(typeof medias !== 'undefined' && medias.length > 0) { // if the user has uploaded something to Instagram already node.latestSelfContentID = medias[0].id; } @@ -97,9 +98,10 @@ module.exports = function(RED) { node.ig.user_self_liked({ count : 1, max_like_id : null}, function(err, medias, pagination, remaining, limit) { if (err) { node.warn(RED._("instagram.warn.likedphoto-fetch-fail", {err: err})); + return; } - if(medias.length > 0) { // if the user has liked something to Instagram already + if(typeof medias !== 'undefined' && medias.length > 0) { // if the user has liked something to Instagram already node.latestLikedID = medias[0].id; } @@ -120,8 +122,9 @@ module.exports = function(RED) { node.ig.user_media_recent('self', { count : 1, min_id : null, max_id : null}, function(err, medias, pagination, remaining, limit) { if (err) { node.warn(RED._("instagram.warn.userphoto-fetch-fail", {err: err})); + return; } - if(medias.length > 0) { // if the user has uploaded something to Instagram already + if(typeof medias !== 'undefined' && medias.length > 0) { // if the user has uploaded something to Instagram already if(medias[0].type === IMAGE) { if(medias[0].location) { if(medias[0].location.latitude) { @@ -172,8 +175,9 @@ module.exports = function(RED) { node.ig.user_self_liked({ count : 1, max_like_id : null}, function(err, medias, pagination, remaining, limit) { if (err) { node.warn(RED._("instagram.warn.likedphoto-fetch-fail", {err: err})); + return; } - if(medias.length > 0) { // if the user has liked something to Instagram already + if(typeof medias !== 'undefined' && medias.length > 0) { // if the user has liked something to Instagram already if(medias[0].type === IMAGE) { if(medias[0].location) { if(medias[0].location.latitude) { @@ -235,6 +239,7 @@ module.exports = function(RED) { if (err) { node.warn(RED._("instagram.warn.latest-media-fetch-failed", {err: err})); + return; } if(medias) { @@ -401,6 +406,7 @@ module.exports = function(RED) { client_id: credentials.client_id, redirect_uri: credentials.redirect_uri, response_type: "code", + scope: "public_content", state: node_id + ":" + credentials.csrfToken } })); diff --git a/instagram/package.json b/instagram/package.json index 4c5b7d2c..2d90f791 100644 --- a/instagram/package.json +++ b/instagram/package.json @@ -1,10 +1,10 @@ { "name" : "node-red-node-instagram", - "version" : "0.1.0", + "version" : "0.1.1", "description" : "Node-RED nodes that get photos from Instagram", "dependencies" : { "request":"~2.40.0", - "instagram-node":"0.5.1" + "instagram-node":"0.5.8" }, "repository" : { "type":"git", From e73e31fcd28e8231c6166df8f339b85c3a3cf594 Mon Sep 17 00:00:00 2001 From: tedhuang Date: Tue, 19 Apr 2016 15:45:19 -0700 Subject: [PATCH 2/7] removed extra new line in package.json --- instagram/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instagram/package.json b/instagram/package.json index 2d90f791..67597b3c 100644 --- a/instagram/package.json +++ b/instagram/package.json @@ -22,4 +22,4 @@ "email": "zoltan.balogh@uk.ibm.com", "url": "http://nodered.org" } -} +} \ No newline at end of file From cdba7c3b6e28f79ed71082cca8fb6056c261efe9 Mon Sep 17 00:00:00 2001 From: tedhuang Date: Tue, 19 Apr 2016 15:56:18 -0700 Subject: [PATCH 3/7] updated repository url in package json --- instagram/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instagram/package.json b/instagram/package.json index 67597b3c..e7ace66f 100644 --- a/instagram/package.json +++ b/instagram/package.json @@ -8,7 +8,7 @@ }, "repository" : { "type":"git", - "url":"https://github.com/node-red/node-red-web-nodes/tree/master/instagram" + "url":"https://github.com/SenseTecnic/node-red-web-nodes/tree/master/instagram" }, "license": "Apache-2.0", "keywords": [ "node-red", "instagram", "photo" ], From 52aaf9da22446661ab0f28aa47a254c8d5892a3e Mon Sep 17 00:00:00 2001 From: Ted Huang Date: Wed, 18 May 2016 12:19:50 -0700 Subject: [PATCH 4/7] forecast.io node: adding trim on lat, lon and apikey strings and error handling on non json api response --- forecast/forecastio.js | 12 ++++++++---- forecast/locales/en-US/forecastio.json | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/forecast/forecastio.js b/forecast/forecastio.js index ab4863cc..a43c6fa3 100644 --- a/forecast/forecastio.js +++ b/forecast/forecastio.js @@ -20,14 +20,14 @@ module.exports = function(RED) { function assignmentFunction(node, date, time, lat, lon, forecastioConfig, callback) { if (forecastioConfig && forecastioConfig.credentials && forecastioConfig.credentials.client_key) { - node.apikey = forecastioConfig.credentials.client_key; + node.apikey = forecastioConfig.credentials.client_key.trim(); } else { return callback(RED._("forecastio.error.no-credentials")); } if (90 >= lat && 180 >= lon && lat >= -90 && lon >= -180) { - node.lat = lat; - node.lon = lon; + node.lat = lat.trim(); + node.lon = lon.trim(); } else { return callback(RED._("forecastio.error.invalid-lat_lon")); } @@ -85,7 +85,11 @@ module.exports = function(RED) { if (weather === "Forbidden") { return callback(RED._("forecastio.error.incorrect-apikey")); } else { - var jsun = JSON.parse(weather); + try { + var jsun = JSON.parse(weather); + } catch (err) { + return callback(RED._("forecastio.error.api-response", { response: weather })); + } msg.data = jsun; msg.payload.weather = jsun.daily.data[when].icon; msg.payload.detail = jsun.daily.data[when].summary; diff --git a/forecast/locales/en-US/forecastio.json b/forecast/locales/en-US/forecastio.json index 9587fd9c..f2ea25aa 100644 --- a/forecast/locales/en-US/forecastio.json +++ b/forecast/locales/en-US/forecastio.json @@ -33,7 +33,8 @@ "invalid-time": "Invalid time provided", "invalid-date": "Invalid date provided", "incorrect-apikey": "Incorrect API key provided", - "invalid-url": "invalid url" + "invalid-url": "invalid url", + "api-response": "Error parsing response from API: __response__" }, "message": { "weather-forecast": "Weather Forecast Information", From d8ca8f23c0495e52c4b988b9f05880ad8feab351 Mon Sep 17 00:00:00 2001 From: Ted Huang Date: Wed, 18 May 2016 14:08:44 -0700 Subject: [PATCH 5/7] bump version to 0.1.5 for forecastio --- forecast/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/forecast/package.json b/forecast/package.json index 9e4b1492..ae6b304f 100644 --- a/forecast/package.json +++ b/forecast/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-node-forecastio", - "version" : "0.1.4", + "version" : "0.1.5", "description" : "A Node-RED node that gets the weather forecast from Forecast.io", "dependencies" : { }, From 9d4b2e74f71148917879d4a163743e9f9eb7df52 Mon Sep 17 00:00:00 2001 From: Ted Huang Date: Wed, 18 May 2016 14:13:44 -0700 Subject: [PATCH 6/7] reverting repo url in package.json for instagram node --- instagram/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instagram/package.json b/instagram/package.json index e7ace66f..67597b3c 100644 --- a/instagram/package.json +++ b/instagram/package.json @@ -8,7 +8,7 @@ }, "repository" : { "type":"git", - "url":"https://github.com/SenseTecnic/node-red-web-nodes/tree/master/instagram" + "url":"https://github.com/node-red/node-red-web-nodes/tree/master/instagram" }, "license": "Apache-2.0", "keywords": [ "node-red", "instagram", "photo" ], From c9a8cf19a542cf1692e15e093762c52d1dbabe87 Mon Sep 17 00:00:00 2001 From: Ted Huang Date: Wed, 18 May 2016 14:58:07 -0700 Subject: [PATCH 7/7] fix for travis test - 'jsun' used out of scope --- forecast/forecastio.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/forecast/forecastio.js b/forecast/forecastio.js index a43c6fa3..01713696 100644 --- a/forecast/forecastio.js +++ b/forecast/forecastio.js @@ -85,8 +85,9 @@ module.exports = function(RED) { if (weather === "Forbidden") { return callback(RED._("forecastio.error.incorrect-apikey")); } else { + var jsun; try { - var jsun = JSON.parse(weather); + jsun = JSON.parse(weather); } catch (err) { return callback(RED._("forecastio.error.api-response", { response: weather })); }