Skip to content

Commit

Permalink
linting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve-Mcl committed Dec 18, 2024
1 parent 7c47522 commit f99d34f
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions nodes/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,40 +38,39 @@ async function appendTopic (RED, config, wNode, msg) {
*/
function addConnectionCredentials (RED, msg, conn, config) {
if (config.includeClientData) {

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

// Handle arrays and nested arrays
const processMsg = (data) => {
if (Array.isArray(data)) {
return data.map(item => processMsg(item));
return data.map(item => processMsg(item))
} else if (typeof data === 'object' && data !== null) {
return addClientData(data)
}
return data;
};
return data
}

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

function getThirdPartyWidgets (directory) {
Expand Down

0 comments on commit f99d34f

Please sign in to comment.