@cocreate/socket-server 1.21.4 → 1.21.6

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 CHANGED
@@ -1,3 +1,20 @@
1
+ ## [1.21.6](https://github.com/CoCreate-app/CoCreate-socket-server/compare/v1.21.5...v1.21.6) (2023-11-03)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * authorized false condition ([056e59a](https://github.com/CoCreate-app/CoCreate-socket-server/commit/056e59a41558f3a4a4450aa84ef8043ee1e5922b))
7
+ * $addToSet.activeHost ([d705f16](https://github.com/CoCreate-app/CoCreate-socket-server/commit/d705f16ab7bef6bf6c0fe2f5f4d9416b1d9df463))
8
+ * update dependencies to the lates versions ([6260248](https://github.com/CoCreate-app/CoCreate-socket-server/commit/62602485421b432ad00ca25712b3798c3a97eeef))
9
+ * update method to use object.update etc ([10e4530](https://github.com/CoCreate-app/CoCreate-socket-server/commit/10e4530ea792e7e71bdf79a1c965e94bf2204edf))
10
+
11
+ ## [1.21.5](https://github.com/CoCreate-app/CoCreate-socket-server/compare/v1.21.4...v1.21.5) (2023-10-26)
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * disabled message_log ([0977880](https://github.com/CoCreate-app/CoCreate-socket-server/commit/09778807aeaf9b7d574d956e0327d3277554ea19))
17
+
1
18
  ## [1.21.4](https://github.com/CoCreate-app/CoCreate-socket-server/compare/v1.21.3...v1.21.4) (2023-10-25)
2
19
 
3
20
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/socket-server",
3
- "version": "1.21.4",
3
+ "version": "1.21.6",
4
4
  "description": "CoCreate-socket-server",
5
5
  "keywords": [
6
6
  "cocreate-socket",
@@ -40,9 +40,9 @@
40
40
  },
41
41
  "homepage": "https://cocreate.app/docs/CoCreate-socket-server",
42
42
  "dependencies": {
43
- "@cocreate/config": "^1.6.5",
43
+ "@cocreate/config": "^1.6.6",
44
44
  "@cocreate/uuid": "^1.7.2",
45
- "@cocreate/utils": "^1.26.1",
45
+ "@cocreate/utils": "^1.26.2",
46
46
  "ws": "7.5.9"
47
47
  }
48
48
  }
package/src/index.js CHANGED
@@ -64,7 +64,7 @@ class SocketServer extends EventEmitter {
64
64
  if (!organization || organization && organization.status !== false) {
65
65
  let data = {
66
66
  socket,
67
- method: 'read.object',
67
+ method: 'object.read',
68
68
  array: 'message_log',
69
69
  $filter: {
70
70
  sort: [
@@ -142,11 +142,11 @@ class SocketServer extends EventEmitter {
142
142
 
143
143
  this.organizations.set(organization_id, organization)
144
144
 
145
- this.emit('update.object', {
146
- method: 'update.object',
145
+ this.emit('object.update', {
146
+ method: 'object.update',
147
147
  array: 'organizations',
148
148
  object: {
149
- _id: organization_id, ['$push.activeHost']: socket.socketUrl // needs socketId
149
+ _id: organization_id, ['$addToSet.activeHost']: socket.socketUrl // needs socketId
150
150
  },
151
151
  organization_id
152
152
  });
@@ -234,8 +234,8 @@ class SocketServer extends EventEmitter {
234
234
 
235
235
  if (!Object.keys(clients).length) {
236
236
  this.organizations.delete(socket.organization_id);
237
- this.emit('update.object', {
238
- method: 'update.object',
237
+ this.emit('object.update', {
238
+ method: 'object.update',
239
239
  array: 'organizations',
240
240
  object: {
241
241
  _id: organization_id, ['$pull.activeHost']: socket.socketUrl
@@ -348,7 +348,11 @@ class SocketServer extends EventEmitter {
348
348
 
349
349
  const authorized = await this.authorize.check(data, socket.user_id)
350
350
  let errors = {}
351
- if (authorized.serverOrganization === false) {
351
+ if (authorized === false) {
352
+ delete data.socket
353
+ data.error = 'authorization failed'
354
+ return socket.send(JSON.stringify(data))
355
+ } else if (authorized.serverOrganization === false) {
352
356
  organization.status = errors.status = false;
353
357
  organization.serverOrganization = false;
354
358
  organization.error = authorized.error
@@ -426,15 +430,16 @@ class SocketServer extends EventEmitter {
426
430
  if (authorized && authorized.authorized)
427
431
  data = authorized.authorized
428
432
 
429
- if (data.log !== false && data.log !== 'false' && !data.method.startsWith('read.') && data.method !== 'updateUserStatus' && data.method !== 'userStatus' && data.method !== 'signIn' && data.method !== 'signUp') {
430
- let object = { url: socket.socketUrl, data }
431
- delete object.socket
432
- this.emit('create.object', {
433
- method: 'create.object',
434
- array: 'message_log',
435
- object,
436
- organization_id: data.organization_id
437
- });
433
+ if (data.log !== false && data.log !== 'false' && !data.method.endsWith('.read') && data.method !== 'updateUserStatus' && data.method !== 'userStatus' && data.method !== 'signIn' && data.method !== 'signUp') {
434
+ // TODO: store logged messages more efficently by combing objects wherever possible
435
+ // let object = { url: socket.socketUrl, data }
436
+ // delete object.socket
437
+ // this.emit('object.create', {
438
+ // method: 'object.create',
439
+ // array: 'message_log',
440
+ // object,
441
+ // organization_id: data.organization_id
442
+ // });
438
443
  }
439
444
 
440
445
  let sockets = this.get(data);
package/src/mesh.js CHANGED
@@ -16,7 +16,7 @@ async function addServer(data) {
16
16
 
17
17
  // TODO: needs to get orgaizations activeRegions
18
18
  let activeRegions = await crud.send({
19
- method: 'read.object',
19
+ method: 'object.read',
20
20
  array: 'organizations',
21
21
  object: { _id: data.organization_id },
22
22
  organization_id: data.organization_id