@flowfuse/nr-project-nodes
Advanced tools
Comparing version 0.6.2-00e0126-202311231108.0 to 0.6.2-29c8a93-202403191727.0
@@ -19,3 +19,7 @@ module.exports = function (RED) { | ||
const TOPIC_VERSION = 'v1' | ||
const OWNER_TYPE = RED.settings.flowforge.applicationID ? 'application' : 'instance' | ||
// It is not unreasonable to expect `projectID` and `applicationID` are set for an instance | ||
// owned device, however an application owned device should not have a projectID. | ||
// therefore, assume project owned if `projectID` is set | ||
const OWNER_TYPE = RED.settings.flowforge.projectID ? 'instance' : 'application' | ||
const featureEnabled = RED.settings.flowforge.projectLink.featureEnabled !== false | ||
@@ -687,4 +691,8 @@ // #region JSDoc | ||
let configOk = true | ||
if (node.broadcast !== true && OWNER_TYPE === 'application') { | ||
if (featureEnabled === false) { | ||
configOk = false | ||
node.status({ fill: 'red', shape: 'dot', text: 'feature not available' }) | ||
node.warn('Project Link feature is not available for your current Team.') | ||
} else if (node.broadcast !== true && OWNER_TYPE === 'application') { | ||
configOk = false | ||
node.status({ fill: 'red', shape: 'dot', text: 'unsupported source option' }) | ||
@@ -768,5 +776,14 @@ node.warn('Receiving direct messages is not supported for application assigned devices. Please update the nodes source option to use "Listen for broadcast messages".') | ||
node.broadcast = n.broadcast === true || n.broadcast === 'true' | ||
mqtt.connect() | ||
mqtt.registerStatus(node) | ||
if (featureEnabled === false) { | ||
node.status({ fill: 'red', shape: 'dot', text: 'feature not available' }) | ||
node.warn('Project Link feature is not available for your current Team.') | ||
} else { | ||
mqtt.connect() | ||
mqtt.registerStatus(node) | ||
} | ||
node.on('input', async function (msg, _send, done) { | ||
if (featureEnabled === false) { | ||
done() | ||
return | ||
} | ||
try { | ||
@@ -856,16 +873,24 @@ if (node.mode === 'return') { | ||
} | ||
if (featureEnabled === false) { | ||
node.status({ fill: 'red', shape: 'dot', text: 'feature not available' }) | ||
node.warn('Project Link feature is not available for your current Team.') | ||
} else { | ||
mqtt.connect() | ||
mqtt.registerStatus(node) | ||
// ↓ Useful for debugging ↓ | ||
// console.log(`🔗 LINK-CALL responseTopic SUB ${node.responseTopic}`) | ||
mqtt.subscribe(node, node.responseTopic, { qos: 2 }, onSub) | ||
.then(_result => {}) | ||
.catch(err => { | ||
node.status({ fill: 'red', shape: 'dot', text: 'subscribe error' }) | ||
node.error(err) | ||
}) | ||
} | ||
mqtt.connect() | ||
mqtt.registerStatus(node) | ||
// ↓ Useful for debugging ↓ | ||
// console.log(`🔗 LINK-CALL responseTopic SUB ${node.responseTopic}`) | ||
mqtt.subscribe(node, node.responseTopic, { qos: 2 }, onSub) | ||
.then(_result => {}) | ||
.catch(err => { | ||
node.status({ fill: 'red', shape: 'dot', text: 'subscribe error' }) | ||
node.error(err) | ||
}) | ||
node.on('input', async function (msg, send, done) { | ||
try { | ||
if (featureEnabled === false) { | ||
done() | ||
return | ||
} | ||
const eventId = crypto.randomBytes(14).toString('hex') | ||
@@ -872,0 +897,0 @@ /** @type {MessageEvent} */ |
{ | ||
"name": "@flowfuse/nr-project-nodes", | ||
"version": "0.6.2-00e0126-202311231108.0", | ||
"version": "0.6.2-29c8a93-202403191727.0", | ||
"description": "A collection of Node-RED nodes for easy communication between Node-RED instances running in the FlowFuse platform", | ||
@@ -5,0 +5,0 @@ "scripts": { |
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
87725
974