@resolveio/server-lib 5.2.68 → 5.2.70-newrole

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.
@@ -461,57 +461,66 @@ var SubscriptionManager = /** @class */ (function () {
461
461
  });
462
462
  oplog.on('insert', function (doc) {
463
463
  var nsArray = doc.ns.split('.');
464
- var collection = nsArray[1];
465
- if (nsArray[2]) {
466
- collection += '.' + nsArray[2];
467
- }
468
- if (collection === 'cron-jobs') {
469
- _this._mainServer.getCronManager().checkCronJobsForUpdates();
470
- }
471
- else if (collection === 'queue-methods') {
472
- _this._mainServer.getQueueManager().runMethodQueue();
473
- }
474
- else if (collection === 'queue-responses') {
475
- _this._mainServer.getQueueManager().runMethodResponse();
476
- }
477
- else if (collection === 'support-tickets' && _this.serverConfig['ROOT_URL'] !== 'http://localhost:4200') {
478
- _this._mainServer.getMethodManager().callMethodInternal('sendSupportTicketEmail', doc.o._id);
479
- }
480
- if (!collection.endsWith('.versions') && !collection.startsWith('system.')) {
481
- _this._oplogQueue.push({
482
- type: 'insert',
483
- collection: collection,
484
- doc: doc.o
485
- });
464
+ var database = nsArray[0];
465
+ if (_this.serverConfig['DATABASE'] === database) {
466
+ var collection = nsArray[1];
467
+ if (nsArray[2]) {
468
+ collection += '.' + nsArray[2];
469
+ }
470
+ if (collection === 'cron-jobs') {
471
+ _this._mainServer.getCronManager().checkCronJobsForUpdates();
472
+ }
473
+ else if (collection === 'queue-methods') {
474
+ _this._mainServer.getQueueManager().runMethodQueue();
475
+ }
476
+ else if (collection === 'queue-responses') {
477
+ _this._mainServer.getQueueManager().runMethodResponse();
478
+ }
479
+ else if (collection === 'support-tickets' && _this.serverConfig['ROOT_URL'] !== 'http://localhost:4200') {
480
+ _this._mainServer.getMethodManager().callMethodInternal('sendSupportTicketEmail', doc.o._id);
481
+ }
482
+ if (!collection.endsWith('.versions') && !collection.startsWith('system.')) {
483
+ _this._oplogQueue.push({
484
+ type: 'insert',
485
+ collection: collection,
486
+ doc: doc.o
487
+ });
488
+ }
486
489
  }
487
490
  });
488
491
  oplog.on('update', function (doc) {
489
492
  var nsArray = doc.ns.split('.');
490
- var collection = nsArray[1];
491
- if (nsArray[2]) {
492
- collection += '.' + nsArray[2];
493
- }
494
- doc.o['_id'] = doc.o2['_id'];
495
- if (collection === 'cron-jobs') {
496
- _this._mainServer.getCronManager().checkCronJobsForUpdates();
497
- }
498
- if (!collection.endsWith('.versions') && !collection.startsWith('system.')) {
499
- _this._oplogQueue.push({
500
- type: 'update',
501
- collection: collection,
502
- doc: doc.o
503
- });
493
+ var database = nsArray[0];
494
+ if (_this.serverConfig['DATABASE'] === database) {
495
+ var collection = nsArray[1];
496
+ if (nsArray[2]) {
497
+ collection += '.' + nsArray[2];
498
+ }
499
+ doc.o['_id'] = doc.o2['_id'];
500
+ if (collection === 'cron-jobs') {
501
+ _this._mainServer.getCronManager().checkCronJobsForUpdates();
502
+ }
503
+ if (!collection.endsWith('.versions') && !collection.startsWith('system.')) {
504
+ _this._oplogQueue.push({
505
+ type: 'update',
506
+ collection: collection,
507
+ doc: doc.o
508
+ });
509
+ }
504
510
  }
505
511
  });
506
512
  oplog.on('delete', function (doc) {
507
513
  var nsArray = doc.ns.split('.');
508
- var collection = nsArray[1];
509
- if (nsArray[2]) {
510
- collection += '.' + nsArray[2];
511
- }
512
- that.resendPubsForDelete(collection);
513
- if (collection === 'cron-jobs') {
514
- _this._mainServer.getCronManager().checkCronJobsForUpdates();
514
+ var database = nsArray[0];
515
+ if (_this.serverConfig['DATABASE'] === database) {
516
+ var collection = nsArray[1];
517
+ if (nsArray[2]) {
518
+ collection += '.' + nsArray[2];
519
+ }
520
+ that.resendPubsForDelete(collection);
521
+ if (collection === 'cron-jobs') {
522
+ _this._mainServer.getCronManager().checkCronJobsForUpdates();
523
+ }
515
524
  }
516
525
  });
517
526
  oplog.on('error', function (error) {
@@ -545,33 +554,42 @@ var SubscriptionManager = /** @class */ (function () {
545
554
  });
546
555
  oplog.on('insert', function (doc) {
547
556
  var nsArray = doc.ns.split('.');
548
- var collection = nsArray[1];
549
- if (nsArray[2]) {
550
- collection += '.' + nsArray[2];
551
- }
552
- if (collection === 'support-tickets') {
553
- that.checkSupportPubsForChanges(collection, doc.o);
557
+ var database = nsArray[0];
558
+ if (_this.serverConfig['DATABASE'] === database) {
559
+ var collection = nsArray[1];
560
+ if (nsArray[2]) {
561
+ collection += '.' + nsArray[2];
562
+ }
563
+ if (collection === 'support-tickets') {
564
+ that.checkSupportPubsForChanges(collection, doc.o);
565
+ }
554
566
  }
555
567
  });
556
568
  oplog.on('update', function (doc) {
557
569
  var nsArray = doc.ns.split('.');
558
- var collection = nsArray[1];
559
- if (nsArray[2]) {
560
- collection += '.' + nsArray[2];
561
- }
562
- doc.o['_id'] = doc.o2['_id'];
563
- if (collection === 'support-tickets') {
564
- that.checkSupportPubsForChanges(collection, doc.o);
570
+ var database = nsArray[0];
571
+ if (_this.serverConfig['DATABASE'] === database) {
572
+ var collection = nsArray[1];
573
+ if (nsArray[2]) {
574
+ collection += '.' + nsArray[2];
575
+ }
576
+ doc.o['_id'] = doc.o2['_id'];
577
+ if (collection === 'support-tickets') {
578
+ that.checkSupportPubsForChanges(collection, doc.o);
579
+ }
565
580
  }
566
581
  });
567
582
  oplog.on('delete', function (doc) {
568
583
  var nsArray = doc.ns.split('.');
569
- var collection = nsArray[1];
570
- if (nsArray[2]) {
571
- collection += '.' + nsArray[2];
572
- }
573
- if (collection === 'support-tickets') {
574
- that.resendPubsForDelete(collection);
584
+ var database = nsArray[0];
585
+ if (_this.serverConfig['DATABASE'] === database) {
586
+ var collection = nsArray[1];
587
+ if (nsArray[2]) {
588
+ collection += '.' + nsArray[2];
589
+ }
590
+ if (collection === 'support-tickets') {
591
+ that.resendPubsForDelete(collection);
592
+ }
575
593
  }
576
594
  });
577
595
  oplog.on('error', function (error) {
@@ -644,10 +662,15 @@ var SubscriptionManager = /** @class */ (function () {
644
662
  case 1:
645
663
  docs = _a.sent();
646
664
  needIds_1[collection].forEach(function (id_doc) {
647
- if (uniqueOplog_1.filter(function (a) { return a.doc && a.doc._id === id_doc; })[0] && docs.filter(function (a) { return a._id === id_doc; })[0]) {
648
- uniqueOplog_1.filter(function (a) { return a.doc && a.doc._id === id_doc; }).forEach(function (op) {
649
- op.doc = docs.filter(function (a) { return a._id === id_doc; })[0];
650
- });
665
+ if (uniqueOplog_1.filter(function (a) { return a.doc && a.doc._id === id_doc; })[0]) {
666
+ if (docs.filter(function (a) { return a._id === id_doc; })[0]) {
667
+ uniqueOplog_1.filter(function (a) { return a.doc && a.doc._id === id_doc; }).forEach(function (op) {
668
+ op.doc = docs.filter(function (a) { return a._id === id_doc; })[0];
669
+ });
670
+ }
671
+ else {
672
+ uniqueOplog_1.splice(uniqueOplog_1.findIndex(function (a) { return a.doc && a.doc._id === id_doc; })[0], 1);
673
+ }
651
674
  }
652
675
  else {
653
676
  _this._mainServer.getMethodManager().sendEmail('dev@resolveio.com', 'SERVER - Oplog Doc Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'id_doc: ' + id_doc + ', UniqueOplogs: ' + JSON.stringify(uniqueOplog_1, null, 2));