@cocreate/socket-server 1.21.0 → 1.21.2
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 +15 -0
- package/package.json +1 -1
- package/src/index.js +38 -35
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
## [1.21.2](https://github.com/CoCreate-app/CoCreate-socket-server/compare/v1.21.1...v1.21.2) (2023-10-24)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* if no organization conditions ([8847125](https://github.com/CoCreate-app/CoCreate-socket-server/commit/8847125f80dcc761692fa2cdcb87f446a0ee7623))
|
|
7
|
+
|
|
8
|
+
## [1.21.1](https://github.com/CoCreate-app/CoCreate-socket-server/compare/v1.21.0...v1.21.1) (2023-10-24)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* allow organization to connect if serverOrganization false ([b91a1b5](https://github.com/CoCreate-app/CoCreate-socket-server/commit/b91a1b574ecb14604245930bd8ebf563f9e9f445))
|
|
14
|
+
* return access denied ([bb9a929](https://github.com/CoCreate-app/CoCreate-socket-server/commit/bb9a929481fc34fc2ead377577100cf6908c4707))
|
|
15
|
+
|
|
1
16
|
# [1.21.0](https://github.com/CoCreate-app/CoCreate-socket-server/compare/v1.20.2...v1.21.0) (2023-10-22)
|
|
2
17
|
|
|
3
18
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -61,45 +61,48 @@ class SocketServer extends EventEmitter {
|
|
|
61
61
|
socket.host = url.host || socket.origin;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
if (!organization || organization && organization.status !== false) {
|
|
65
|
+
let data = {
|
|
66
|
+
socket,
|
|
67
|
+
method: 'read.object',
|
|
68
|
+
array: 'message_log',
|
|
69
|
+
$filter: {
|
|
70
|
+
sort: [
|
|
71
|
+
{ key: '_id', direction: 'desc' }
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
sync: true,
|
|
75
|
+
organization_id
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (options.lastSynced)
|
|
79
|
+
data.$filter.query = [
|
|
80
|
+
{ key: '_id', value: options.lastSynced, operator: '$gt' }
|
|
71
81
|
]
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
82
|
+
else
|
|
83
|
+
data.$filter.limit = 1
|
|
84
|
+
|
|
85
|
+
self.emit('read.object', data);
|
|
86
|
+
|
|
87
|
+
if (self.authenticate) {
|
|
88
|
+
const { user_id, expires } = self.authenticate.decodeToken(options.token)
|
|
89
|
+
const userStatus = { socket, method: 'userStatus', user_id: options.user_id, userStatus: 'off', organization_id }
|
|
90
|
+
if (user_id) {
|
|
91
|
+
options.user_id = user_id
|
|
92
|
+
socket.user_id = user_id;
|
|
93
|
+
socket.expires = expires;
|
|
94
|
+
userStatus.userStatus = 'on'
|
|
95
|
+
self.emit("notification.user", socket)
|
|
96
|
+
}
|
|
76
97
|
|
|
77
|
-
|
|
78
|
-
data.$filter.query = [
|
|
79
|
-
{ key: '_id', value: options.lastSynced, operator: '$gt' }
|
|
80
|
-
]
|
|
81
|
-
else
|
|
82
|
-
data.$filter.limit = 1
|
|
83
|
-
|
|
84
|
-
self.emit('read.object', data);
|
|
85
|
-
|
|
86
|
-
if (self.authenticate) {
|
|
87
|
-
const { user_id, expires } = self.authenticate.decodeToken(options.token)
|
|
88
|
-
const userStatus = { socket, method: 'userStatus', user_id: options.user_id, userStatus: 'off', organization_id }
|
|
89
|
-
if (user_id) {
|
|
90
|
-
options.user_id = user_id
|
|
91
|
-
socket.user_id = user_id;
|
|
92
|
-
socket.expires = expires;
|
|
93
|
-
userStatus.userStatus = 'on'
|
|
94
|
-
self.emit("notification.user", socket)
|
|
95
|
-
}
|
|
98
|
+
self.emit('userStatus', userStatus);
|
|
96
99
|
|
|
97
|
-
|
|
100
|
+
self.onWebSocket(socket);
|
|
98
101
|
|
|
99
|
-
|
|
102
|
+
} else
|
|
103
|
+
self.onWebSocket(socket);
|
|
104
|
+
}
|
|
100
105
|
|
|
101
|
-
} else
|
|
102
|
-
self.onWebSocket(socket);
|
|
103
106
|
} else {
|
|
104
107
|
socket.send(JSON.stringify({ method: 'Access Denied', error: 'An organization_id is required' }))
|
|
105
108
|
}
|
|
@@ -420,7 +423,7 @@ class SocketServer extends EventEmitter {
|
|
|
420
423
|
if (authorized && authorized.authorized)
|
|
421
424
|
data = authorized.authorized
|
|
422
425
|
|
|
423
|
-
if (!data.method.startsWith('read.') && data.method !== 'updateUserStatus' && data.method !== 'userStatus' && data.method !== 'signIn' && data.method !== 'signUp') {
|
|
426
|
+
if (data.log !== false && data.log !== 'false' && !data.method.startsWith('read.') && data.method !== 'updateUserStatus' && data.method !== 'userStatus' && data.method !== 'signIn' && data.method !== 'signUp') {
|
|
424
427
|
let object = { url: socket.socketUrl, data }
|
|
425
428
|
delete object.socket
|
|
426
429
|
this.emit('create.object', {
|