@resolveio/server-lib 1.0.1 → 1.0.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/server-app.js +67 -45
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resolveio/server-lib",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "",
5
5
  "main": "index.ts",
6
6
  "scripts": {
package/server-app.js CHANGED
@@ -248,7 +248,7 @@ var ResolveIOMainServer = /** @class */ (function () {
248
248
  }, 10000);
249
249
  // On data received (message)
250
250
  ws.on('message', function (message) { return __awaiter(_this, void 0, void 0, function () {
251
- var _a, _b, _c, _d, _e, data, messageId, type, method, serverRes, methodCall, subType, pub, supportMethod, serverRes;
251
+ var _a, _b, _c, _d, _e, data, messageId, type, method, serverRes, query, methodCall, subType, pub, supportMethod, serverRes;
252
252
  var _this = this;
253
253
  return __generator(this, function (_f) {
254
254
  switch (_f.label) {
@@ -338,12 +338,34 @@ var ResolveIOMainServer = /** @class */ (function () {
338
338
  if (!this._methodManager._methods[method].skipQueue) return [3 /*break*/, 1];
339
339
  (_a = this._methodManager).callMethod.apply(_a, [ws, messageId, method].concat(data));
340
340
  return [3 /*break*/, 5];
341
- case 1: return [4 /*yield*/, method_call_collection_1.MethodCalls.findOne({ $and: [
341
+ case 1:
342
+ query = { $and: [
342
343
  { id_user: ws['id_user'] },
343
344
  { message_id: messageId },
344
- { method: method },
345
345
  { data: JSON.stringify(data) }
346
- ] }).exec()];
346
+ ] };
347
+ if (method !== 'updateDocumentOffline' && method !== 'updateDocumentPropsOffline') {
348
+ query.$and.push({ method: method });
349
+ }
350
+ else {
351
+ if (method === 'updateDocumentOffline') {
352
+ query.$and.push({
353
+ $or: [
354
+ { method: method },
355
+ { method: 'updateDocument' }
356
+ ]
357
+ });
358
+ }
359
+ else if (method === 'updateDocumentPropsOffline') {
360
+ query.$and.push({
361
+ $or: [
362
+ { method: method },
363
+ { method: 'updateDocumentProps' }
364
+ ]
365
+ });
366
+ }
367
+ }
368
+ return [4 /*yield*/, method_call_collection_1.MethodCalls.findOne(query).exec()];
347
369
  case 2:
348
370
  methodCall = _f.sent();
349
371
  if (!!methodCall) return [3 /*break*/, 4];
@@ -477,47 +499,47 @@ var ResolveIOMainServer = /** @class */ (function () {
477
499
  }
478
500
  else if (type === 'methodResponse') {
479
501
  method = data.shift();
480
- if (method !== 'generatePDF' && method !== 'getWOOfflineData' && method !== 'countQuery' && method !== 'countCollectionWithQuery' && method !== 'find' && method !== 'findOne' && method !== 'findWithOptions' && method !== 'setWSAppVersion') {
481
- if (common_1.getBinarySize(JSON.stringify(data)) < 200000) {
482
- log_collection_1.Logs.create({
483
- _id: mongoose_1.Types.ObjectId().toHexString(),
484
- date: new Date(),
485
- type: 'client-request',
486
- title: 'Client Request - Method Response',
487
- message: 'User: ' + ws['user'] + ', Type: ' + type + ', MessageId: ' + messageId + ', Method: ' + method,
488
- payload: data,
489
- method: method,
490
- user: ws['user'],
491
- messageId: messageId
492
- });
493
- }
494
- else {
495
- log_collection_1.Logs.create({
496
- _id: mongoose_1.Types.ObjectId().toHexString(),
497
- date: new Date(),
498
- type: 'client-request',
499
- title: 'Client Request - Method Response',
500
- message: 'User: ' + ws['user'] + ', Type: ' + type + ', MessageId: ' + messageId + ', Method: ' + method,
501
- payload: 'Too Big',
502
- method: method,
503
- user: ws['user'],
504
- messageId: messageId
505
- });
506
- }
507
- }
508
- else {
509
- log_collection_1.Logs.create({
510
- _id: mongoose_1.Types.ObjectId().toHexString(),
511
- date: new Date(),
512
- type: 'client-request',
513
- title: 'Client Request - Method Response',
514
- message: 'User: ' + ws['user'] + ', Type: ' + type + ', MessageId: ' + messageId + ', Method: ' + method,
515
- payload: 'Too Big',
516
- method: method,
517
- user: ws['user'],
518
- messageId: messageId
519
- });
520
- }
502
+ // if (method !== 'generatePDF' && method !== 'getWOOfflineData' &&method !== 'countQuery' && method !== 'countCollectionWithQuery' && method !== 'find' && method !== 'findOne' && method !== 'findWithOptions' && method !== 'setWSAppVersion') {
503
+ // if (getBinarySize(JSON.stringify(data)) < 200000) {
504
+ // Logs.create({
505
+ // _id: Types.ObjectId().toHexString(),
506
+ // date: new Date(),
507
+ // type: 'client-request',
508
+ // title: 'Client Request - Method Response',
509
+ // message: 'User: ' + ws['user'] + ', Type: ' + type + ', MessageId: ' + messageId + ', Method: ' + method,
510
+ // payload: data,
511
+ // method: method,
512
+ // user: ws['user'],
513
+ // messageId: messageId
514
+ // });
515
+ // }
516
+ // else {
517
+ // Logs.create({
518
+ // _id: Types.ObjectId().toHexString(),
519
+ // date: new Date(),
520
+ // type: 'client-request',
521
+ // title: 'Client Request - Method Response',
522
+ // message: 'User: ' + ws['user'] + ', Type: ' + type + ', MessageId: ' + messageId + ', Method: ' + method,
523
+ // payload: 'Too Big',
524
+ // method: method,
525
+ // user: ws['user'],
526
+ // messageId: messageId
527
+ // });
528
+ // }
529
+ // }
530
+ // else {
531
+ // Logs.create({
532
+ // _id: Types.ObjectId().toHexString(),
533
+ // date: new Date(),
534
+ // type: 'client-request',
535
+ // title: 'Client Request - Method Response',
536
+ // message: 'User: ' + ws['user'] + ', Type: ' + type + ', MessageId: ' + messageId + ', Method: ' + method,
537
+ // payload: 'Too Big',
538
+ // method: method,
539
+ // user: ws['user'],
540
+ // messageId: messageId
541
+ // });
542
+ // }
521
543
  method_response_collection_1.MethodResponses.findOne({ $and: [
522
544
  { id_user: ws['id_user'] },
523
545
  { message_id: messageId },