Something went wrong with the authentication process. The following error was returned:
'+ - '
'+error.statusCode+': '+error.data+'
'+ - 'One known cause of this type of failure is if the clock is wrong on system running Node-RED.'; - res.send(resp) - } else { - credentials.oauth_token = oauth_token; - credentials.oauth_token_secret = oauth_token_secret; - res.redirect('https://twitter.com/oauth/authorize?oauth_token='+oauth_token) - RED.nodes.addCredentials(req.params.id,credentials); - } - }); - }); - - RED.httpAdmin.get('/twitter-credentials/:id/auth/callback', function(req, res, next){ - var credentials = RED.nodes.getCredentials(req.params.id); - credentials.oauth_verifier = req.query.oauth_verifier; - - oa.getOAuthAccessToken( - credentials.oauth_token, - credentials.token_secret, - credentials.oauth_verifier, - function(error, oauth_access_token, oauth_access_token_secret, results){ - if (error){ - RED.log.error(error); - res.send("something in twitter oauth broke."); - } else { - credentials = {}; - credentials.access_token = oauth_access_token; - credentials.access_token_secret = oauth_access_token_secret; - credentials.screen_name = "@"+results.screen_name; - RED.nodes.addCredentials(req.params.id,credentials); - res.send("
Authorised - you can close this window and return to Node-RED"); - } - } - ); - }); -} diff --git a/nodes/core/social/32-feedparse.html b/nodes/core/social/32-feedparse.html deleted file mode 100644 index 4e2925c87..000000000 --- a/nodes/core/social/32-feedparse.html +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - diff --git a/nodes/core/social/32-feedparse.js b/nodes/core/social/32-feedparse.js deleted file mode 100644 index 49ffe83f6..000000000 --- a/nodes/core/social/32-feedparse.js +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Copyright 2013,2014 IBM Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - **/ - -module.exports = function(RED) { - "use strict"; - var FeedParser = require("feedparser"); - var request = require("request"); - - function FeedParseNode(n) { - RED.nodes.createNode(this,n); - this.url = n.url; - this.interval = (parseInt(n.interval)||15) * 60000; - var node = this; - this.interval_id = null; - this.seen = {}; - if (this.url !== "") { - var getFeed = function() { - var req = request(node.url, {timeout: 10000, pool: false}); - //req.setMaxListeners(50); - //req.setHeader('user-agent', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36'); - req.setHeader('accept', 'text/html,application/xhtml+xml'); - - var feedparser = new FeedParser(); - - req.on('error', function(err) { node.error(err); }); - - req.on('response', function(res) { - if (res.statusCode != 200) { node.warn('error - Bad status code'); } - else { res.pipe(feedparser); } - }); - - feedparser.on('error', function(error) { node.error(error); }); - - feedparser.on('readable', function () { - var stream = this, article; - while (article = stream.read()) { - if (!(article.guid in node.seen) || ( node.seen[article.guid] !== 0 && node.seen[article.guid] != article.date.getTime())) { - node.seen[article.guid] = article.date?article.date.getTime():0; - var msg = { - topic: article.origlink || article.link, - payload: article.description, - article: article - }; - node.send(msg); - } - } - }); - - feedparser.on('meta', function (meta) {}); - feedparser.on('end', function () {}); - }; - this.interval_id = setInterval(function() { getFeed(); }, node.interval); - getFeed(); - } else { - this.error("Invalid url"); - } - - this.on("close", function() { - if (this.interval_id != null) { - clearInterval(this.interval_id); - } - }); - } - - RED.nodes.registerType("feedparse",FeedParseNode); -} diff --git a/nodes/core/social/61-email.html b/nodes/core/social/61-email.html deleted file mode 100644 index d2e70219c..000000000 --- a/nodes/core/social/61-email.html +++ /dev/null @@ -1,203 +0,0 @@ - - - - - - - - - - - - - - diff --git a/nodes/core/social/61-email.js b/nodes/core/social/61-email.js deleted file mode 100644 index 6d2145bf8..000000000 --- a/nodes/core/social/61-email.js +++ /dev/null @@ -1,283 +0,0 @@ -/** - * Copyright 2013,2014 IBM Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - **/ - -module.exports = function(RED) { - "use strict"; - var nodemailer = require("nodemailer"); - var Imap = require('imap'); - - //console.log(nodemailer.Transport.transports.SMTP.wellKnownHosts); - - try { - var globalkeys = RED.settings.email || require(process.env.NODE_RED_HOME+"/../emailkeys.js"); - } catch(err) { - } - - function EmailNode(n) { - RED.nodes.createNode(this,n); - this.topic = n.topic; - this.name = n.name; - this.outserver = n.server; - this.outport = n.port; - var flag = false; - if (this.credentials && this.credentials.hasOwnProperty("userid")) { - this.userid = this.credentials.userid; - } else { - if (globalkeys) { - this.userid = globalkeys.user; - flag = true; - } else { - this.error("No e-mail userid set"); - } - } - if (this.credentials && this.credentials.hasOwnProperty("password")) { - this.password = this.credentials.password; - } else { - if (globalkeys) { - this.password = globalkeys.pass; - flag = true; - } else { - this.error("No e-mail password set"); - } - } - if (flag) { - RED.nodes.addCredentials(n.id,{userid:this.userid, password:this.password, global:true}); - } - var node = this; - - var smtpTransport = nodemailer.createTransport({ - host: node.outserver, - port: node.outport, - secure: true, - auth: { - user: node.userid, - pass: node.password - } - }); - - this.on("input", function(msg) { - if (msg.hasOwnProperty("payload")) { - if (smtpTransport) { - node.status({fill:"blue",shape:"dot",text:"sending"}); - if (msg.to && node.name && (msg.to !== node.name)) { - node.warn("Warning: msg properties can no longer override set node properties. See bit.ly/nr-override-msg-props"); - } - var sendopts = { from: node.userid }; // sender address - sendopts.to = node.name || msg.to; // comma separated list of addressees - sendopts.subject = msg.topic || msg.title || "Message from Node-RED"; // subject line - if (Buffer.isBuffer(msg.payload)) { // if it's a buffer in the payload then auto create an attachment instead - if (!msg.filename) { - var fe = "bin"; - if ((msg.payload[0] === 0xFF)&&(msg.payload[1] === 0xD8)) { fe = "jpg"; } - if ((msg.payload[0] === 0x47)&&(msg.payload[1] === 0x49)) { fe = "gif"; } //46 - if ((msg.payload[0] === 0x42)&&(msg.payload[1] === 0x4D)) { fe = "bmp"; } - if ((msg.payload[0] === 0x89)&&(msg.payload[1] === 0x50)) { fe = "png"; } //4E - msg.filename = "attachment."+fe; - } - sendopts.attachments = [ { content: msg.payload, filename:(msg.filename.replace(/^.*[\\\/]/, '') || "file.bin") } ]; - if (msg.hasOwnProperty("headers") && msg.headers.hasOwnProperty("content-type")) { - sendopts.attachments[0].contentType = msg.headers["content-type"]; - } - // Create some body text.. - sendopts.text = "Your file from Node-RED is attached : "+(msg.filename.replace(/^.*[\\\/]/, '') || "file.bin")+ (msg.hasOwnProperty("description") ? "\n\n"+msg.description : ""); - } - else { - var payload = RED.util.ensureString(msg.payload); - sendopts.text = payload; // plaintext body - if (/<[a-z][\s\S]*>/i.test(payload)) { sendopts.html = payload; } // html body - if (msg.attachments) { sendopts.attachments = msg.attachments; } // add attachments - } - smtpTransport.sendMail(sendopts, function(error, info) { - if (error) { - node.error(error,msg); - node.status({fill:"red",shape:"ring",text:"send failed"}); - } else { - node.log("Message sent: " + info.response); - node.status({}); - } - }); - } - else { node.warn("No Email credentials found. See info panel."); } - } - else { node.warn("No payload to send"); } - }); - } - RED.nodes.registerType("e-mail",EmailNode,{ - credentials: { - userid: {type:"text"}, - password: {type: "password"}, - global: { type:"boolean"} - } - }); - - function EmailInNode(n) { - RED.nodes.createNode(this,n); - this.name = n.name; - this.repeat = n.repeat * 1000 || 300000; - this.inserver = n.server || globalkeys.server || "imap.gmail.com"; - this.inport = n.port || globalkeys.port || "993"; - this.box = n.box || "INBOX"; - var flag = false; - - if (this.credentials && this.credentials.hasOwnProperty("userid")) { - this.userid = this.credentials.userid; - } else { - if (globalkeys) { - this.userid = globalkeys.user; - flag = true; - } else { - this.error("No e-mail userid set"); - } - } - if (this.credentials && this.credentials.hasOwnProperty("password")) { - this.password = this.credentials.password; - } else { - if (globalkeys) { - this.password = globalkeys.pass; - flag = true; - } else { - this.error("No e-mail password set"); - } - } - if (flag) { - RED.nodes.addCredentials(n.id,{userid:this.userid, password:this.password, global:true}); - } - - var node = this; - this.interval_id = null; - var oldmail = {}; - - var imap = new Imap({ - user: node.userid, - password: node.password, - host: node.inserver, - port: node.inport, - tls: true, - tlsOptions: { rejectUnauthorized: false }, - connTimeout: node.repeat, - authTimeout: node.repeat - }); - - if (!isNaN(this.repeat) && this.repeat > 0) { - node.log("repeat = "+this.repeat); - this.interval_id = setInterval( function() { - node.emit("input",{}); - }, this.repeat ); - } - - this.on("input", function(msg) { - imap.once('ready', function() { - node.status({fill:"blue",shape:"dot",text:"fetching"}); - var pay = {}; - imap.openBox(node.box, false, function(err, box) { - if (err) { - node.status({fill:"red",shape:"ring",text:"fetch folder error"}); - node.error("Failed to fetch folder "+node.box,err); - } - else { - if (box.messages.total > 0) { - //var f = imap.seq.fetch(box.messages.total + ':*', { markSeen:true, bodies: ['HEADER.FIELDS (FROM SUBJECT DATE TO CC BCC)','TEXT'] }); - var f = imap.seq.fetch(box.messages.total + ':*', { markSeen:true, bodies: ['HEADER','TEXT'] }); - f.on('message', function(msg, seqno) { - node.log('message: #'+ seqno); - var prefix = '(#' + seqno + ') '; - msg.on('body', function(stream, info) { - var buffer = ''; - stream.on('data', function(chunk) { - buffer += chunk.toString('utf8'); - }); - stream.on('end', function() { - if (info.which !== 'TEXT') { - var head = Imap.parseHeader(buffer); - pay.from = head.from[0]; - pay.topic = head.subject[0]; - pay.date = head.date[0]; - pay.header = head; - } else { - var parts = buffer.split("Content-Type"); - for (var p = 0; p < parts.length; p++) { - if (parts[p].indexOf("text/plain") >= 0) { - pay.payload = parts[p].split("\n").slice(1,-2).join("\n").trim(); - } - else if (parts[p].indexOf("text/html") >= 0) { - pay.html = parts[p].split("\n").slice(1,-2).join("\n").trim(); - } else { - pay.payload = parts[0]; - } - } - //pay.body = buffer; - } - }); - }); - msg.on('end', function() { - //node.log('Finished: '+prefix); - }); - }); - f.on('error', function(err) { - node.warn('fetch message error: ' + err); - node.status({fill:"red",shape:"ring",text:"fetch message error"}); - }); - f.on('end', function() { - delete(pay._msgid); - if (JSON.stringify(pay) !== oldmail) { - oldmail = JSON.stringify(pay); - node.send(pay); - node.log('received new email: '+pay.topic); - } - else { node.log('duplicate not sent: '+pay.topic); } - //node.status({fill:"green",shape:"dot",text:"ok"}); - node.status({}); - }); - } - else { - node.log("you have achieved inbox zero"); - //node.status({fill:"green",shape:"dot",text:"ok"}); - node.status({}); - } - } - imap.end(); - }); - }); - node.status({fill:"grey",shape:"dot",text:"connecting"}); - imap.connect(); - }); - - imap.on('error', function(err) { - node.log(err); - node.status({fill:"red",shape:"ring",text:"connect error"}); - }); - - this.on("error", function(err) { - node.log("error: ",err); - }); - - this.on("close", function() { - if (this.interval_id != null) { - clearInterval(this.interval_id); - } - if (imap) { imap.destroy(); } - }); - - node.emit("input",{}); - } - RED.nodes.registerType("e-mail in",EmailInNode,{ - credentials: { - userid: {type:"text"}, - password: {type: "password"}, - global: { type:"boolean"} - } - }); -}; diff --git a/nodes/core/social/91-irc.html b/nodes/core/social/91-irc.html deleted file mode 100644 index 61ced52aa..000000000 --- a/nodes/core/social/91-irc.html +++ /dev/null @@ -1,235 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/nodes/core/social/91-irc.js b/nodes/core/social/91-irc.js deleted file mode 100644 index ffc1bc28b..000000000 --- a/nodes/core/social/91-irc.js +++ /dev/null @@ -1,282 +0,0 @@ -/** - * Copyright 2013,2014 IBM Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - **/ - -module.exports = function(RED) { - "use strict"; - var irc = require("irc"); - - // The Server Definition - this opens (and closes) the connection - function IRCServerNode(n) { - RED.nodes.createNode(this,n); - this.server = n.server; - this.port = n.port || 6667; - this.ssl = n.ssl || false; - this.cert = n.cert || false; - this.channel = n.channel; - this.nickname = n.nickname; - this.lastseen = 0; - this.ircclient = null; - this.on("close", function() { - if (this.ircclient != null) { - this.ircclient.removeAllListeners(); - this.ircclient.disconnect(); - } - }); - } - RED.nodes.registerType("irc-server",IRCServerNode); - - - // The Input Node - function IrcInNode(n) { - RED.nodes.createNode(this,n); - this.ircserver = n.ircserver; - this.serverConfig = RED.nodes.getNode(this.ircserver); - this.channel = n.channel || this.serverConfig.channel; - var node = this; - if (node.serverConfig.ircclient === null) { - node.log("CONNECT: "+node.serverConfig.server); - node.status({fill:"grey",shape:"dot",text:"connecting"}); - var options = {autoConnect:true,autoRejoin:false,floodProtection:true,secure:node.serverConfig.ssl,selfSigned:node.serverConfig.cert,port:node.serverConfig.port,retryDelay:20000}; - node.serverConfig.ircclient = new irc.Client(node.serverConfig.server, node.serverConfig.nickname, options); - node.serverConfig.ircclient.setMaxListeners(0); - node.serverConfig.ircclient.addListener('error', function(message) { - if (RED.settings.verbose) { node.log("ERR: "+JSON.stringify(message)); } - }); - node.serverConfig.ircclient.addListener('netError', function(message) { - node.serverConfig.lastseen = Date.now(); - if (RED.settings.verbose) { node.log("NET: "+JSON.stringify(message)); } - node.status({fill:"red",shape:"ring",text:"net error"}); - }); - node.serverConfig.ircclient.addListener('connect', function() { - node.serverConfig.lastseen = Date.now(); - if (RED.settings.verbose) { node.log("CONNECTED "); } - }); - node.serverConfig.ircclient.addListener('registered', function(message) { - node.serverConfig.lastseen = Date.now(); - node.log(node.serverConfig.ircclient.nick+" ONLINE: "+message.server); - node.status({fill:"yellow",shape:"dot",text:"connected"}); - node.serverConfig.ircclient.join( node.channel, function(data) { - node.log(data+" JOINED: "+node.channel); - node.status({fill:"green",shape:"dot",text:"joined"}); - }); - }); - node.serverConfig.ircclient.addListener('ping', function(server) { - node.serverConfig.lastseen = Date.now(); - if (RED.settings.verbose) { node.log("PING from "+JSON.stringify(server)); } - node.status({fill:"green",shape:"dot",text:"ok"}); - }); - node.serverConfig.ircclient.addListener('quit', function(nick, reason, channels, message) { - node.serverConfig.lastseen = Date.now(); - if (RED.settings.verbose) { node.log("QUIT: "+nick+" "+reason+" "+channels+" "+JSON.stringify(message)); } - node.status({fill:"grey",shape:"ring",text:"quit"}); - //node.serverConfig.ircclient.disconnect( function() { - // node.serverConfig.ircclient.connect(); - //}); - //if (RED.settings.verbose) { node.log("restart"); } // then retry - }); - node.serverConfig.ircclient.addListener('raw', function (message) { // any message received means we are alive - //console.log("RAW:"+JSON.stringify(message)); - if (message.commandType === "reply") { - //console.log("RAW:"+JSON.stringify(message)); - node.serverConfig.lastseen = Date.now(); - } - }); - node.recon = setInterval( function() { - //console.log("CHK ",(Date.now()-node.serverConfig.lastseen)/1000); - if ((Date.now()-node.serverConfig.lastseen) > 240000) { // if more than 4 mins since last seen - node.serverConfig.ircclient.send.apply(node.serverConfig.ircclient,["TIME"]); // request time to check link - } - if ((Date.now()-node.serverConfig.lastseen) > 300000) { // If more than 5 mins - //node.serverConfig.ircclient.disconnect(); - //node.serverConfig.ircclient.connect(); - node.status({fill:"grey",shape:"ring",text:"no connection"}); - if (RED.settings.verbose) { node.log("CONNECTION LOST ?"); } - } - //node.serverConfig.ircclient.send.apply(node.serverConfig.ircclient,["TIME"]); // request time to check link - }, 60000); // check every 1 min - //node.serverConfig.ircclient.connect(); - } - else { node.status({text:""}); } - node.ircclient = node.serverConfig.ircclient; - - node.ircclient.addListener('registered', function(message) { - //node.log(node.ircclient.nick+" ONLINE"); - node.status({fill:"yellow",shape:"dot",text:"connected"}); - node.ircclient.join( node.channel, function(data) { - // node.log(data+" JOINED "+node.channel); - node.status({fill:"green",shape:"dot",text:"joined"}); - }); - }); - node.ircclient.addListener('message', function (from, to, message) { - //node.log(from + ' => ' + to + ' : ' + message); - if (~node.channel.toLowerCase().indexOf(to.toLowerCase())) { - var msg = { "topic":from, "from":from, "to":to, "payload":message }; - node.send([msg,null]); - } - //else { console.log(node.channel,to); } - }); - node.ircclient.addListener('pm', function(from, message) { - //node.log("PM => "+from + ': ' + message); - var msg = { "topic":from, "from":from, "to":"PRIV", "payload":message }; - node.send([msg,null]); - }); - node.ircclient.addListener('join', function(channel, who) { - var msg = { "payload": { "type":"join", "who":who, "channel":channel } }; - node.send([null,msg]); - //node.log(who+' has joined '+channel); - }); - node.ircclient.addListener('invite', function(channel, from, message) { - var msg = { "payload": { "type":"invite", "who":from, "channel":channel, "message":message } }; - node.send([null,msg]); - //node.log(from+' sent invite to '+channel+': '+message); - }); - node.ircclient.addListener('part', function(channel, who, reason) { - var msg = { "payload": { "type":"part", "who":who, "channel":channel, "reason":reason } }; - node.send([null,msg]); - //node.log(who+' has left '+channel+': '+reason); - }); - node.ircclient.addListener('quit', function(nick, reason, channels, message) { - var msg = { "payload": { "type":"quit", "who":nick, "channel":channels, "reason":reason } }; - node.send([null,msg]); - //node.log(nick+' has quit '+channels+': '+reason); - }); - node.ircclient.addListener('kick', function(channel, who, by, reason) { - var msg = { "payload": { "type":"kick", "who":who, "channel":channel, "by":by, "reason":reason } }; - node.send([null,msg]); - //node.log(who+' was kicked from '+channel+' by '+by+': '+reason); - }); - node.ircclient.addListener('names', function (channel, nicks) { - var msg = { "payload": { "type": "names", "channel": channel, "names": nicks} }; - node.send([null, msg]); - }); - node.ircclient.addListener('raw', function (message) { // any message means we are alive - node.serverConfig.lastseen = Date.now(); - }); - node.on("close", function() { - node.ircclient.removeAllListeners(); - if (node.recon) { clearInterval(node.recon); } - }); - } - RED.nodes.registerType("irc in",IrcInNode); - - - // The Output Node - function IrcOutNode(n) { - RED.nodes.createNode(this,n); - this.sendFlag = n.sendObject; - this.ircserver = n.ircserver; - this.serverConfig = RED.nodes.getNode(this.ircserver); - this.channel = n.channel || this.serverConfig.channel; - var node = this; - if (node.serverConfig.ircclient === null) { - node.log("CONNECT: "+node.serverConfig.server); - node.status({fill:"grey",shape:"dot",text:"connecting"}); - var options = {autoConnect:true,autoRejoin:false,floodProtection:true,secure:node.serverConfig.ssl,selfSigned:node.serverConfig.cert,port:node.serverConfig.port,retryDelay:20000}; - node.serverConfig.ircclient = new irc.Client(node.serverConfig.server, node.serverConfig.nickname, options); - node.serverConfig.ircclient.setMaxListeners(0); - node.serverConfig.ircclient.addListener('error', function(message) { - if (RED.settings.verbose) { node.log("ERR: "+JSON.stringify(message)); } - }); - node.serverConfig.ircclient.addListener('netError', function(message) { - node.serverConfig.lastseen = Date.now(); - if (RED.settings.verbose) { node.log("NET: "+JSON.stringify(message)); } - node.status({fill:"red",shape:"ring",text:"net error"}); - }); - node.serverConfig.ircclient.addListener('connect', function() { - node.serverConfig.lastseen = Date.now(); - if (RED.settings.verbose) { node.log("CONNECTED "); } - }); - node.serverConfig.ircclient.addListener('registered', function(message) { - node.serverConfig.lastseen = Date.now(); - node.log(node.serverConfig.ircclient.nick+" ONLINE: "+message.server); - node.status({fill:"yellow",shape:"dot",text:"connected"}); - node.serverConfig.ircclient.join( node.channel, function(data) { - node.log(data+" JOINED: "+node.channel); - node.status({fill:"green",shape:"dot",text:"joined"}); - }); - }); - node.serverConfig.ircclient.addListener('ping', function(server) { - node.serverConfig.lastseen = Date.now(); - if (RED.settings.verbose) { node.log("PING from "+JSON.stringify(server)); } - node.status({fill:"green",shape:"dot",text:"ok"}); - }); - node.serverConfig.ircclient.addListener('quit', function(nick, reason, channels, message) { - node.serverConfig.lastseen = Date.now(); - if (RED.settings.verbose) { node.log("QUIT: "+nick+" "+reason+" "+channels+" "+JSON.stringify(message)); } - node.status({fill:"grey",shape:"ring",text:"quit"}); - //node.serverConfig.ircclient.disconnect( function() { - // node.serverConfig.ircclient.connect(); - //}); - //if (RED.settings.verbose) { node.log("restart"); } // then retry - }); - node.serverConfig.ircclient.addListener('raw', function (message) { // any message received means we are alive - //console.log("RAW:"+JSON.stringify(message)); - if (message.commandType === "reply") { - //console.log("RAW:"+JSON.stringify(message)); - node.serverConfig.lastseen = Date.now(); - } - }); - node.recon = setInterval( function() { - //console.log("CHK ",(Date.now()-node.serverConfig.lastseen)/1000); - if ((Date.now()-node.serverConfig.lastseen) > 240000) { // if more than 4 mins since last seen - node.serverConfig.ircclient.send.apply(node.serverConfig.ircclient,["TIME"]); // request time to check link - } - if ((Date.now()-node.serverConfig.lastseen) > 300000) { // If more than 5 mins - //node.serverConfig.ircclient.disconnect(); - //node.serverConfig.ircclient.connect(); - node.status({fill:"grey",shape:"ring",text:"no connection"}); - if (RED.settings.verbose) { node.log("CONNECTION LOST ?"); } - } - //node.serverConfig.ircclient.send.apply(node.serverConfig.ircclient,["TIME"]); // request time to check link - }, 60000); // check every 1 min - //node.serverConfig.ircclient.connect(); - } - else { node.status({text:""}); } - node.ircclient = node.serverConfig.ircclient; - - node.on("input", function(msg) { - if (Object.prototype.toString.call( msg.raw ) === '[object Array]') { - if (RED.settings.verbose) { node.log("RAW command:"+msg.raw); } - node.ircclient.send.apply(node.ircclient,msg.raw); - } - else { - if (msg._topic) { delete msg._topic; } - var ch = node.channel.split(","); // split on , so we can send to multiple - if (node.sendFlag == "true") { // override channels with msg.topic - if ((msg.hasOwnProperty('topic'))&&(typeof msg.topic === "string")) { - ch = msg.topic.split(","); // split on , so we can send to multiple - } - else { node.warn("msg.topic not set"); } - } - for (var c = 0; c < ch.length; c++) { - if (node.sendFlag == "false") { // send whole message object to each channel - node.ircclient.say(ch[c], JSON.stringify(msg)); - } - else { // send just the payload to each channel - if (typeof msg.payload === "object") { msg.payload = JSON.stringify(msg.payload); } - node.ircclient.say(ch[c], msg.payload); - } - } - } - }); - - node.on("close", function() { - node.ircclient.removeAllListeners(); - if (node.recon) { clearInterval(node.recon); } - }); - } - RED.nodes.registerType("irc out",IrcOutNode); -} diff --git a/nodes/core/storage/65-redisout.html b/nodes/core/storage/65-redisout.html deleted file mode 100644 index dc1f7b838..000000000 --- a/nodes/core/storage/65-redisout.html +++ /dev/null @@ -1,105 +0,0 @@ - - - - - - - diff --git a/nodes/core/storage/65-redisout.js b/nodes/core/storage/65-redisout.js deleted file mode 100644 index 18a5f2b4a..000000000 --- a/nodes/core/storage/65-redisout.js +++ /dev/null @@ -1,110 +0,0 @@ -/** - * Copyright 2013 IBM Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - **/ - -module.exports = function(RED) { - "use strict"; - var redis = require("redis"); - - var hashFieldRE = /^([^=]+)=(.*)$/; - - var redisConnectionPool = function() { - var connections = {}; - var obj = { - get: function(host,port) { - var id = host+":"+port; - if (!connections[id]) { - connections[id] = redis.createClient(port,host); - connections[id].on("error",function(err) { - RED.log.error(err); - }); - connections[id].on("connect",function() { - if (RED.settings.verbose) { RED.log.info("connected to "+host+":"+port); } - }); - connections[id]._id = id; - connections[id]._nodeCount = 0; - } - connections[id]._nodeCount += 1; - return connections[id]; - }, - close: function(connection) { - connection._nodeCount -= 1; - if (connection._nodeCount === 0) { - if (connection) { - clearTimeout(connection.retry_timer); - connection.end(); - } - delete connections[connection._id]; - } - } - }; - return obj; - }(); - - - function RedisOutNode(n) { - RED.nodes.createNode(this,n); - this.port = n.port||"6379"; - this.hostname = n.hostname||"127.0.0.1"; - this.key = n.key; - this.structtype = n.structtype; - - this.client = redisConnectionPool.get(this.hostname,this.port); - - if (this.client.connected) { - this.status({fill:"green",shape:"dot",text:"connected"}); - } else { - this.status({fill:"red",shape:"ring",text:"disconnected"},true); - } - - var node = this; - this.client.on("end", function() { - node.status({fill:"red",shape:"ring",text:"disconnected"}); - }); - this.client.on("connect", function() { - node.status({fill:"green",shape:"dot",text:"connected"}); - }); - - this.on("input", function(msg) { - var k = this.key || msg.topic; - if (k) { - if (this.structtype == "string") { - this.client.set(k,RED.util.ensureString(msg.payload)); - } else if (this.structtype == "hash") { - if (typeof msg.payload == "object") { - this.client.hmset(k,msg.payload); - } else { - var r = hashFieldRE.exec(msg.payload); - if (r) { - this.client.hset(k,r[1],r[2]); - } else { - this.warn("Invalid payload for redis hash"); - } - } - } else if (this.structtype == "set") { - this.client.sadd(k,msg.payload); - } else if (this.structtype == "list") { - this.client.rpush(k,msg.payload); - } - } else { - this.warn("No key or topic set"); - } - }); - this.on("close", function() { - redisConnectionPool.close(node.client); - }); - } - RED.nodes.registerType("redis out",RedisOutNode); -} diff --git a/nodes/core/storage/66-mongodb.html b/nodes/core/storage/66-mongodb.html deleted file mode 100644 index 1b448de95..000000000 --- a/nodes/core/storage/66-mongodb.html +++ /dev/null @@ -1,231 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/nodes/core/storage/66-mongodb.js b/nodes/core/storage/66-mongodb.js deleted file mode 100644 index 0e67fd291..000000000 --- a/nodes/core/storage/66-mongodb.js +++ /dev/null @@ -1,244 +0,0 @@ -/** - * Copyright 2013,2014 IBM Corp. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - **/ - -module.exports = function(RED) { - "use strict"; - var mongo = require('mongodb'); - var MongoClient = mongo.MongoClient; - - function MongoNode(n) { - RED.nodes.createNode(this,n); - this.hostname = n.hostname; - this.port = n.port; - this.db = n.db; - this.name = n.name; - - var url = "mongodb://"; - if (this.credentials && this.credentials.user && this.credentials.password) { - url += this.credentials.user+":"+this.credentials.password+"@"; - } - url += this.hostname+":"+this.port+"/"+this.db; - - this.url = url; - } - - RED.nodes.registerType("mongodb",MongoNode,{ - credentials: { - user: {type:"text"}, - password: {type: "password"} - } - }); - - function ensureValidSelectorObject(selector) { - if (selector != null && (typeof selector != 'object' || Buffer.isBuffer(selector))) { - return {}; - } - return selector; - } - - - function MongoOutNode(n) { - RED.nodes.createNode(this,n); - this.collection = n.collection; - this.mongodb = n.mongodb; - this.payonly = n.payonly || false; - this.upsert = n.upsert || false; - this.multi = n.multi || false; - this.operation = n.operation; - this.mongoConfig = RED.nodes.getNode(this.mongodb); - - if (this.mongoConfig) { - var node = this; - MongoClient.connect(this.mongoConfig.url, function(err, db) { - if (err) { - node.error(err); - } else { - node.clientDb = db; - var coll; - if (node.collection) { - coll = db.collection(node.collection); - } - node.on("input",function(msg) { - if (!node.collection) { - if (msg.collection) { - coll = db.collection(msg.collection); - } else { - node.error("No collection defined",msg); - return; - } - } - delete msg._topic; - delete msg.collection; - if (node.operation === "store") { - if (node.payonly) { - if (typeof msg.payload !== "object") { - msg.payload = {"payload": msg.payload}; - } - coll.save(msg.payload,function(err, item) { - if (err) { - node.error(err,msg); - } - }); - } else { - coll.save(msg,function(err, item) { - if (err) { - node.error(err,msg); - } - }); - } - } else if (node.operation === "insert") { - if (node.payonly) { - if (typeof msg.payload !== "object") { - msg.payload = {"payload": msg.payload}; - } - coll.insert(msg.payload, function(err, item) { - if (err) { - node.error(err,msg); - } - }); - } else { - coll.insert(msg, function(err,item) { - if (err) { - node.error(err,msg); - } - }); - } - } else if (node.operation === "update") { - if (typeof msg.payload !== "object") { - msg.payload = {"payload": msg.payload}; - } - var query = msg.query || {}; - var payload = msg.payload || {}; - var options = { - upsert: node.upsert, - multi: node.multi - }; - - coll.update(query, payload, options, function(err, item) { - if (err) { - node.error(err,msg); - } - }); - } else if (node.operation === "delete") { - coll.remove(msg.payload, function(err, items) { - if (err) { - node.error(err,msg); - } - }); - } - }); - } - }); - } else { - this.error("missing mongodb configuration"); - } - - this.on("close", function() { - if (this.clientDb) { - this.clientDb.close(); - } - }); - } - RED.nodes.registerType("mongodb out",MongoOutNode); - - function MongoInNode(n) { - RED.nodes.createNode(this,n); - this.collection = n.collection; - this.mongodb = n.mongodb; - this.operation = n.operation || "find"; - this.mongoConfig = RED.nodes.getNode(this.mongodb); - - if (this.mongoConfig) { - var node = this; - var selector; - MongoClient.connect(this.mongoConfig.url, function(err,db) { - if (err) { - node.error(err); - } else { - node.clientDb = db; - var coll; - if (node.collection) { - coll = db.collection(node.collection); - } - node.on("input", function(msg) { - if (!node.collection) { - if (msg.collection) { - coll = db.collection(msg.collection); - } else { - node.error("No collection defined"); - return; - } - } - if (node.operation === "find") { - msg.projection = msg.projection || {}; - selector = ensureValidSelectorObject(msg.payload); - var limit = msg.limit; - if (typeof limit === "string" && !isNaN(limit)) { - limit = Number(limit); - } - var skip = msg.skip; - if (typeof skip === "string" && !isNaN(skip)) { - skip = Number(skip); - } - - coll.find(selector,msg.projection).sort(msg.sort).limit(limit).skip(skip).toArray(function(err, items) { - if (err) { - node.error(err); - } else { - msg.payload = items; - delete msg.projection; - delete msg.sort; - delete msg.limit; - delete msg.skip; - node.send(msg); - } - }); - } else if (node.operation === "count") { - selector = ensureValidSelectorObject(msg.payload); - coll.count(selector, function(err, count) { - if (err) { - node.error(err); - } else { - msg.payload = count; - node.send(msg); - } - }); - } else if (node.operation === "aggregate") { - msg.payload = (Array.isArray(msg.payload)) ? msg.payload : []; - coll.aggregate(msg.payload, function(err, result) { - if (err) { - node.error(err); - } else { - msg.payload = result; - node.send(msg); - } - }); - } - }); - } - }); - } else { - this.error("missing mongodb configuration"); - } - - this.on("close", function() { - if (this.clientDb) { - this.clientDb.close(); - } - }); - } - RED.nodes.registerType("mongodb in",MongoInNode); -} diff --git a/package.json b/package.json index 9a30c9107..8e0d63e56 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version" : "0.10.7", "description" : "A visual tool for wiring the Internet of Things", "homepage" : "http://nodered.org", - "license" : "Apache", + "license" : "Apache-2.0", "repository" : { "type":"git", "url":"https://github.com/node-red/node-red.git" @@ -30,35 +30,31 @@ "bcryptjs": "2.1.0", "nopt": "3.0.1", "mqtt": "0.3.x", - "ws": "0.7.1", + "ws": "0.7.2", "fs-extra": "0.16.3", "clone": "0.2.0", "mustache": "1.0.0", "cron":"1.0.6", "raw-body":"1.3.2", - "twitter-ng":"0.6.2", - "oauth":"0.9.12", "xml2js":"0.4.4", "sentiment":"0.2.3", "follow-redirects":"0.0.3", "cors":"2.5.3", - "cheerio":"0.18.0", + "cheerio":"0.19.0", "uglify-js":"2.4.16", - "nodemailer":"1.3.0", - "imap":"0.8.14", - "request":"2.42.0", "on-headers":"1.0.0", "is-utf8":"0.2.0", - "feedparser":"0.19.2", "fs.notify":"0.0.4", "passport":"0.2.1", "passport-http-bearer":"1.0.1", "passport-oauth2-client-password":"0.1.2", - "oauth2orize":"1.0.1" + "oauth2orize":"1.0.1", + "node-red-node-feedparser":"0.0.2", + "node-red-node-email":"0.0.1", + "node-red-node-twitter":"0.0.4" }, "optionalDependencies": { - "irc":"0.3.9", - "serialport":"1.4.10", + "node-red-node-serialport":"0.0.1", "bcrypt":"0.8.1" }, "devDependencies": {