Skip to content

Commit

Permalink
Merge commit 'refs/pull/1533/head' of github.com:FlowFuse/node-red-da…
Browse files Browse the repository at this point in the history
…shboard into main
  • Loading branch information
Steve-Mcl committed Dec 18, 2024
2 parents 357ebba + c492bc0 commit 7c47522
Showing 1 changed file with 31 additions and 14 deletions.
45 changes: 31 additions & 14 deletions nodes/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,40 @@ async function appendTopic (RED, config, wNode, msg) {
*/
function addConnectionCredentials (RED, msg, conn, config) {
if (config.includeClientData) {

Check failure on line 40 in nodes/utils/index.js

View workflow job for this annotation

GitHub Actions / build / Build on 18

Block must not be padded by blank lines
if (!msg._client) {
msg._client = {}
}
RED.plugins.getByType('node-red-dashboard-2').forEach(plugin => {
if (plugin.hooks?.onAddConnectionCredentials && msg) {
msg = plugin.hooks.onAddConnectionCredentials(conn, msg)

Check failure on line 41 in nodes/utils/index.js

View workflow job for this annotation

GitHub Actions / build / Build on 18

Trailing spaces not allowed
// Add _client to each element
const addClientData = (item) => {
if (!item._client) {
item._client = {}
}
})
msg._client = {
...msg._client,
...{
socketId: conn.id,
socketIp: conn.handshake?.address
RED.plugins.getByType('node-red-dashboard-2').forEach(plugin => {
if (plugin.hooks?.onAddConnectionCredentials && item) {
item = plugin.hooks.onAddConnectionCredentials(conn, item);

Check failure on line 49 in nodes/utils/index.js

View workflow job for this annotation

GitHub Actions / build / Build on 18

Extra semicolon
}
});

Check failure on line 51 in nodes/utils/index.js

View workflow job for this annotation

GitHub Actions / build / Build on 18

Extra semicolon
item._client = {
...item._client,
...{
socketId: conn.id,
socketIp: conn.handshake?.address
}
};

Check failure on line 58 in nodes/utils/index.js

View workflow job for this annotation

GitHub Actions / build / Build on 18

Extra semicolon
return item;

Check failure on line 59 in nodes/utils/index.js

View workflow job for this annotation

GitHub Actions / build / Build on 18

Extra semicolon
};

Check failure on line 60 in nodes/utils/index.js

View workflow job for this annotation

GitHub Actions / build / Build on 18

Extra semicolon

// Handle arrays and nested arrays
const processMsg = (data) => {
if (Array.isArray(data)) {
return data.map(item => processMsg(item));

Check failure on line 65 in nodes/utils/index.js

View workflow job for this annotation

GitHub Actions / build / Build on 18

Extra semicolon
} else if (typeof data === 'object' && data !== null) {
return addClientData(data)
}
}
return data;

Check failure on line 69 in nodes/utils/index.js

View workflow job for this annotation

GitHub Actions / build / Build on 18

Extra semicolon
};

Check failure on line 70 in nodes/utils/index.js

View workflow job for this annotation

GitHub Actions / build / Build on 18

Extra semicolon

msg = processMsg(msg)
}
return msg
return msg;
}

function getThirdPartyWidgets (directory) {
Expand Down

0 comments on commit 7c47522

Please sign in to comment.