node-red-viseo-helper
Advanced tools
Comparing version 0.2.0-alpha.10 to 0.2.0-alpha.11
@@ -0,0 +0,0 @@ # Contributor Covenant Code of Conduct |
@@ -0,0 +0,0 @@ # Contributing to the Project |
47
index.js
@@ -244,3 +244,2 @@ 'use strict'; | ||
let oldKeys = []; | ||
let version = ""; | ||
let actKey = ""; | ||
@@ -256,22 +255,17 @@ | ||
if (!version) { | ||
version = ((CONFIG.framework || {}).version) || '0.0.0'; | ||
} | ||
if (!actKey) { | ||
let keyField = "VISEO_BOT_MAKER_KEY"; | ||
let conf = CONFIG || global.CONFIG; | ||
let key = conf[keyField] || node.context().global.get(keyField); | ||
if (!key) { | ||
try { | ||
actKey = (CONFIG || global.CONFIG).server.key || node.context().global.get("VISEO_BOT_MAKER_KEY"); | ||
} | ||
catch(err) { | ||
actKey = ""; | ||
return nextErr("Missing VISEO Bot Maker key - Read the documentation."); | ||
} | ||
if ( key.length !== 40 || oldKeys.indexOf(key) !== -1) { | ||
return nextErr("Invalid VISEO Bot Maker key - Read the documentation."); | ||
} | ||
actKey = key; | ||
node.status({}); | ||
} | ||
if (!actKey || actKey.length !== 40 || oldKeys.indexOf(actKey) !== -1) { | ||
actKey = ""; | ||
return nextErr("Missing VISEO Bot Maker key - Read the documentation."); | ||
} | ||
node.status({}); | ||
let time = Date.now(); | ||
@@ -281,3 +275,3 @@ | ||
// First pass : set start time | ||
activities = { info : { start : time, key : actKey, version: version }}; | ||
activities = { info : { start : time, key : actKey }}; | ||
} | ||
@@ -288,6 +282,9 @@ else if (time - activities.info.start > 86400000){ | ||
await sendActivities(activities); | ||
activities = { info : { start : time, key : actKey, version: version }}; | ||
activities = { info : { start : time, key : actKey }}; | ||
} catch(err) { | ||
activities = { info : { start : time, key : actKey, version: version }}; | ||
if (err.statusCode === 401) return nextErr("Invalid VISEO Bot Maker key - Read the documentation."); | ||
activities = { info : { start : time, key : actKey }}; | ||
if (err.statusCode === 401) { | ||
oldKeys.push(actKey); | ||
return nextErr("Invalid VISEO Bot Maker key - Read the documentation."); | ||
} | ||
return true; | ||
@@ -305,5 +302,7 @@ } | ||
"start": time, | ||
"nodes": [], | ||
"calls": 0 | ||
"end": time, | ||
"nodes": [node.id], | ||
"calls": 1 | ||
} | ||
return true; | ||
} | ||
@@ -314,3 +313,3 @@ | ||
} | ||
activities[node.type].calls += 1; | ||
activities[node.type].calls++; | ||
activities[node.type].end = time; | ||
@@ -317,0 +316,0 @@ |
@@ -0,0 +0,0 @@ const extend = require('extend'); |
{ | ||
"name" : "node-red-viseo-helper", | ||
"version" : "0.2.0-alpha.10", | ||
"version" : "0.2.0-alpha.11", | ||
"description" : "Utility libarary for Node-RED", | ||
@@ -5,0 +5,0 @@ "dependencies" : { |
@@ -0,0 +0,0 @@ # Node-RED |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27806
302