From 736529aa4a64a55049ad9a0984eb1fb240a30675 Mon Sep 17 00:00:00 2001 From: Evgenii Abramov Date: Tue, 30 Mar 2021 21:39:23 +0300 Subject: [PATCH] test --- device.js | 8 +++++--- routes/user.js | 3 +-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/device.js b/device.js index 1015a9c..c275203 100644 --- a/device.js +++ b/device.js @@ -34,13 +34,15 @@ class Device { room: options.room || '', type: options.type || 'devices.types.light', custom_data: { - allowedUsers: options.allowedUsers || [1], mqtt: options.mqtt || [], valueMapping: options.valueMapping || [], }, capabilities: (options.capabilities || []).map(c => Object.assign({}, c, {state: (c.state == undefined) ? this.initState(c) : c.state})), - properties: (options.properties || []).map(p => Object.assign({}, p, {state: (p.state == undefined) ? this.initState(p) : p.state})) - } + properties: (options.properties || []).map(p => Object.assign({}, p, {state: (p.state == undefined) ? this.initState(p) : p.state})), + }; + this.meta = { + allowedUsers: options.allowedUsers || [1], + }; } /* Create init state (for capabilities and properties) on device object create */ diff --git a/routes/user.js b/routes/user.js index 24d4b84..7c5c5a7 100644 --- a/routes/user.js +++ b/routes/user.js @@ -35,8 +35,7 @@ module.exports.devices = [ }; for (const d of global.devices) { - console.log(d); - const {allowedUsers} = d.custom_data; + const {allowedUsers} = d.meta; if (Array.isArray(allowedUsers) && allowedUsers.indexOf(userId)) { console.log(d.getInfo()); r.payload.devices.push(d.getInfo());