@cocreate/socket-server 1.28.2 → 1.28.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/index.js +10 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [1.28.3](https://github.com/CoCreate-app/CoCreate-socket-server/compare/v1.28.2...v1.28.3) (2024-02-18)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* add host ([7542ee7](https://github.com/CoCreate-app/CoCreate-socket-server/commit/7542ee7cb28821515078a912e40574aa0c761b00))
|
|
7
|
+
|
|
1
8
|
## [1.28.2](https://github.com/CoCreate-app/CoCreate-socket-server/compare/v1.28.1...v1.28.2) (2024-02-15)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -73,6 +73,7 @@ class SocketServer extends EventEmitter {
|
|
|
73
73
|
let data = {
|
|
74
74
|
socket,
|
|
75
75
|
method: 'object.read',
|
|
76
|
+
host: socket.host,
|
|
76
77
|
array: 'message_log',
|
|
77
78
|
$filter: {
|
|
78
79
|
sort: [
|
|
@@ -95,7 +96,7 @@ class SocketServer extends EventEmitter {
|
|
|
95
96
|
|
|
96
97
|
if (self.authenticate) {
|
|
97
98
|
const { user_id, expires } = await self.authenticate.decodeToken(options.token, organization_id, options.clientId)
|
|
98
|
-
const userStatus = { socket, method: 'userStatus', user_id: options.user_id, clientId: options.clientId, userStatus: 'off', organization_id }
|
|
99
|
+
const userStatus = { socket, method: 'userStatus', host: socket.host, user_id: options.user_id, clientId: options.clientId, userStatus: 'off', organization_id }
|
|
99
100
|
if (user_id) {
|
|
100
101
|
options.user_id = user_id
|
|
101
102
|
socket.user_id = user_id;
|
|
@@ -188,7 +189,7 @@ class SocketServer extends EventEmitter {
|
|
|
188
189
|
}
|
|
189
190
|
|
|
190
191
|
if (socket.user_id) {
|
|
191
|
-
this.emit('userStatus', { socket, user_id: socket.user_id, clientId: socket.clientId, userStatus: 'on', organization_id });
|
|
192
|
+
this.emit('userStatus', { socket, host: socket.host, user_id: socket.user_id, clientId: socket.clientId, userStatus: 'on', organization_id });
|
|
192
193
|
let user = this.users.get(socket.user_id)
|
|
193
194
|
|
|
194
195
|
if (!Array.isArray(user)) {
|
|
@@ -306,7 +307,7 @@ class SocketServer extends EventEmitter {
|
|
|
306
307
|
clearTimeout(userDebounceTimer);
|
|
307
308
|
userDebounceTimer = setTimeout(() => {
|
|
308
309
|
this.users.delete(socket.user_id);
|
|
309
|
-
this.emit('userStatus', { socket, user_id: socket.user_id, clientId: socket.clientId, userStatus: 'off', organization_id });
|
|
310
|
+
this.emit('userStatus', { socket, user_id: socket.user_id, host: socket.host, clientId: socket.clientId, userStatus: 'off', organization_id });
|
|
310
311
|
}, 10000);
|
|
311
312
|
|
|
312
313
|
this.users.set(socket.user_id, userDebounceTimer)
|
|
@@ -356,7 +357,7 @@ class SocketServer extends EventEmitter {
|
|
|
356
357
|
// data.error = 'Token expired'
|
|
357
358
|
// socket.send(JSON.stringify(data))
|
|
358
359
|
await this.send({
|
|
359
|
-
socket, method: 'updateUserStatus', user_id: socket.user_id, clientId: data.clientId, userStatus: 'off', socketId: data.socketId, organization_id
|
|
360
|
+
socket, method: 'updateUserStatus', user_id: socket.user_id, host: socket.host, clientId: data.clientId, userStatus: 'off', socketId: data.socketId, organization_id
|
|
360
361
|
})
|
|
361
362
|
socket.user_id = socket.expires = null
|
|
362
363
|
return
|
|
@@ -493,6 +494,11 @@ class SocketServer extends EventEmitter {
|
|
|
493
494
|
Data = { ...data }
|
|
494
495
|
}
|
|
495
496
|
|
|
497
|
+
// TODO: the following code can cause issues in client and improved approach is to check if user has permission and send or dont send
|
|
498
|
+
// if (Data.$filter && Data.$filter.query && Data.$filter.query._id && Data.$filter.query._id.$eq === '$user_id')
|
|
499
|
+
// delete Data.$filter.query._id
|
|
500
|
+
|
|
501
|
+
|
|
496
502
|
delete Data.socket
|
|
497
503
|
sockets[i].send(JSON.stringify(Data));
|
|
498
504
|
|