From b49bb6a2ccf8cf3f166b9f7acd511a28109202eb Mon Sep 17 00:00:00 2001 From: frankpagan Date: Fri, 10 Nov 2023 05:37:27 -0600 Subject: [PATCH] fix: sync console.log --- src/index.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/index.js b/src/index.js index 4e4fa0a..1fb21ee 100644 --- a/src/index.js +++ b/src/index.js @@ -416,14 +416,17 @@ class SocketServer extends EventEmitter { return for (let i = 0; i < data.object.length; i++) { - data.object[i].data._id = data.object[i]._id - data.object[i].data.sync = true + if (data.object[i].data) { + data.object[i].data._id = data.object[i]._id + data.object[i].data.sync = true - const authorized = await this.authorize.check(data.object[i].data, socket.user_id) - if (authorized && authorized.authorized) - socket.send(JSON.stringify(authorized.authorized)); - else - socket.send(JSON.stringify(data.object[i].data)); + const authorized = await this.authorize.check(data.object[i].data, socket.user_id) + if (authorized && authorized.authorized) + socket.send(JSON.stringify(authorized.authorized)); + else + socket.send(JSON.stringify(data.object[i].data)); + } else + console.log('server sync missing data') } } else { const sent = []