mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Reset twitter polling on any api errors
This commit is contained in:
parent
85ddffb98f
commit
903a123049
@ -374,6 +374,10 @@ module.exports = function(RED) {
|
||||
var res = result.body;
|
||||
if (res.errors) {
|
||||
node.error(res.errors[0].message);
|
||||
clearInterval(pollId);
|
||||
node.timeout_ids.push(setTimeout(function() {
|
||||
node.poll(interval,url,opts);
|
||||
},interval))
|
||||
return;
|
||||
}
|
||||
if (res.length > 0) {
|
||||
@ -438,7 +442,11 @@ module.exports = function(RED) {
|
||||
node.debug("Twitter DM Poll, rateLimitRemaining="+result.rateLimitRemaining+" rateLimitTimeout="+Math.floor(result.rateLimitTimeout/1000)+"s");
|
||||
var res = result.body;
|
||||
if (res.errors) {
|
||||
throw new Error(res.errors[0].message);
|
||||
node.error(res.errors[0].message);
|
||||
node.timeout_ids.push(setTimeout(function() {
|
||||
node.pollDirectMessages();
|
||||
},interval))
|
||||
return;
|
||||
}
|
||||
var since = "0";
|
||||
var messages = res.events.filter(tweet => tweet.type === 'message_create' && tweet.id > since);
|
||||
@ -459,6 +467,10 @@ module.exports = function(RED) {
|
||||
var res = result.body;
|
||||
if (res.errors) {
|
||||
node.error(res.errors[0].message);
|
||||
clearInterval(pollId);
|
||||
node.timeout_ids.push(setTimeout(function() {
|
||||
node.pollDirectMessages();
|
||||
},interval))
|
||||
return;
|
||||
}
|
||||
var messages = res.events.filter(tweet => tweet.type === 'message_create' && tweet.id > since);
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "node-red-node-twitter",
|
||||
"version": "1.1.0",
|
||||
"version": "1.1.1",
|
||||
"description": "A Node-RED node to talk to Twitter",
|
||||
"dependencies": {
|
||||
"twitter-ng": "0.6.2",
|
||||
|
Loading…
x
Reference in New Issue
Block a user