@resolveio/server-lib 5.2.67 → 5.2.69
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.
|
@@ -603,7 +603,7 @@ var MethodManager = /** @class */ (function () {
|
|
|
603
603
|
replyTo: undefined,
|
|
604
604
|
from: send_from ? send_from : this.serverConfig.MAIL_FROM,
|
|
605
605
|
to: sendTo,
|
|
606
|
-
subject: subject,
|
|
606
|
+
subject: (this.serverConfig['ROOT_URL'].includes('dev.') ? '(DEV SERVER) - ' : '') + subject,
|
|
607
607
|
text: text,
|
|
608
608
|
html: html,
|
|
609
609
|
attachments: attachments
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/managers/method.manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,sDAA+D;AAE/D,wCAAiD;AACjD,gDAAyD;AACzD,sCAAgD;AAChD,sCAAgD;AAChD,wDAAkE;AAClE,2BAA6B;AAC7B,uBAAyB;AACzB,uCAAyC;AAEzC,6BAA+B;AAC/B,gDAAyD;AACzD,yCAAkD;AAClD,mDAA2D;AAC3D,kDAA0D;AAC1D,0CAAmD;AAEnD,wFAA4E;AAC5E,qCAAiC;AACjC,yCAAyD;AACzD,gEAAqD;AAErD,qDAAmD;AACnD,8FAAkF;AAClF,+BAAiC;AACjC,4DAAqE;AAErE;IAaC,uBAAY,UAAU,EAAE,YAAY,EAAE,SAAS;QAA/C,iBAuOC;QAjPM,aAAQ,GAAgB,EAAE,CAAC;QAO1B,eAAU,GAAG,EAAE,CAAC;QAChB,kBAAa,GAAG,KAAK,CAAC;QAG7B,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAE3B,WAAW;QACX,qBAAc,EAAE,CAAC;QACjB,8BAAkB,EAAE,CAAC;QAErB,UAAU;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B,QAAQ;QAAzB,iBAyBC;QAxBA,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;YAClC,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,aAAa,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE;gBACpE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,aAAa,GAAG,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,UAAC,GAAG,EAAE,GAAG;oBAChF,IAAI,GAAG,EAAE;wBACR,MAAM,CAAC,GAAG,CAAC,CAAC;qBACZ;yBACI;wBACJ,OAAO,CAAC,GAAG,CAAC,CAAC;qBACb;gBACF,CAAC,CAAC,CAAC;aACH;iBACI;gBACJ,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,KAAI,CAAC,SAAS,EAAE,CAAC,YAAY,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE;oBACxE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,KAAI,CAAC,SAAS,EAAE,CAAC,YAAY,GAAG,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,UAAC,GAAG,EAAE,GAAG;wBACpF,IAAI,GAAG,EAAE;4BACR,MAAM,CAAC,GAAG,CAAC,CAAC;yBACZ;6BACI;4BACJ,OAAO,CAAC,GAAG,CAAC,CAAC;yBACb;oBACF,CAAC,CAAC,CAAC;iBACH;aACD;QACF,CAAC,CAAC,CAAC;IACJ,CAAC;IACF,oBAAC;AAAD,CArsBA,AAqsBC,IAAA;AArsBY,sCAAa","file":"method.manager.js","sourcesContent":["import { ServerResponseModel } from '../models/server-response.model';\nimport { loadCollectionMethods } from '../methods/collections';\nimport { MethodModel } from '../models/method.model';\nimport { loadLogMethods } from '../methods/logs';\nimport { loadCounterMethods } from '../methods/counters';\nimport { loadPDFMethods } from '../methods/pdf';\nimport { loadAWSMethods } from '../methods/aws';\nimport { loadCloudConvertMethods } from '../methods/cloudconvert';\nimport * as path from 'path';\nimport * as fs from 'fs';\nimport * as nodemailer from 'nodemailer';\nimport * as imap from 'imap';\nimport * as aws from 'aws-sdk';\nimport { loadAccountMethods } from '../methods/accounts';\nimport { loadServerInit } from '../fixtures/init';\nimport { loadServerCronJobs } from '../fixtures/cron-jobs';\nimport { loadCronJobMethods } from '../methods/cron-jobs';\nimport { loadFlagMethods } from '../methods/flags';\nimport { QueueMethodModel } from '../models/queue-method.model';\nimport { MethodResponses } from '../collections/method-response.collection';\nimport { Types } from 'mongoose';\nimport { deepCopy, getBinarySize } from '../util/common';\nimport { Logs } from '../collections/log.collection';\nimport ResolveIOMainServer from '../server-app';\nimport { SupportManager } from './support.manager';\nimport { LogMethodLatencies } from '../collections/log-method-latency.collection';\nimport * as moment from 'moment';\nimport { loadReportBuilderMethods } from '../methods/report-builder';\n\nexport class MethodManager {\n\n\tprivate _mainServer: ResolveIOMainServer;\n\tpublic _methods: MethodModel = {};\n\tprivate _mailer: nodemailer.Transporter;\n\tprivate _imap: imap;\n\tprivate _aws: aws.S3;\n\tprivate serverConfig;\n\tprivate clientDir;\n\n\tprivate _sendQueue = [];\n\tprivate _runningQueue = false;\n\n\tconstructor(mainServer, serverConfig, clientDir) {\n\t\tthis._mainServer = mainServer;\n\t\tthis.serverConfig = serverConfig;\n\t\tthis.clientDir = clientDir;\n\n\t\t// Fixtures\n\t\tloadServerInit();\n\t\tloadServerCronJobs();\n\n\t\t// Methods\n\t\tloadAccountMethods(this);\n\t\tloadAWSMethods(this);\n\t\tloadCloudConvertMethods(this);\n\t\tloadCollectionMethods(this);\n\t\tloadCounterMethods(this);\n\t\tloadLogMethods(this);\n\t\tloadPDFMethods(this);\n\t\tloadCronJobMethods(this);\n\t\tloadFlagMethods(this);\n\t\tloadReportBuilderMethods(this);\n\n\t\tif (mainServer.sesMail) {\n\t\t\tthis._mailer = nodemailer.createTransport({\n\t\t\t\tSES: new aws.SES({\n\t\t\t\t\tapiVersion: '2010-12-01',\n\t\t\t\t\taccessKeyId: serverConfig.AWSACCESSKEYID,\n\t\t\t\t\tsecretAccessKey: serverConfig.AWSSECRETACCESSKEY,\n\t\t\t\t\tregion: serverConfig.AWSSES_REGION\n\t\t\t\t})\n\t\t\t});\n\t\t}\n\t\telse {\n\t\t\tthis._mailer = nodemailer.createTransport({\n\t\t\t\thost: this.serverConfig['MAIL_HOST'], // 'smtp.office365.com', // Office 365 server\n\t\t\t\tport: this.serverConfig['MAIL_PORT'], //587, // secure SMTP\n\t\t\t\tsecure: false, // false for TLS - as a boolean not string - but the default is false so just remove this completely\n\t\t\t\tauth: {\n\t\t\t\t\tuser: this.serverConfig['MAIL_USERNAME'],\n\t\t\t\t\tpass: this.serverConfig['MAIL_PASSWORD']\n\t\t\t\t},\n\t\t\t\ttls: {\n\t\t\t\t\tciphers: 'SSLv3'\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\t// this._imap = new imap({\n\t\t// \tuser: this.serverConfig['ORDERS_EMAIL'],\n\t\t// \tpassword: this.serverConfig['ORDERS_PASSWORD'],\n\t\t// \thost: this.serverConfig['ORDERS_HOST'],\n\t\t// \tport: this.serverConfig['ORDERS_PORT'],\n\t\t// \ttls: this.serverConfig['ORDERS_TLS']\n\t\t// });\n\n\t\t// let that = this;\n\n\t\t// let chemicalNames = await Chemicals.find({}).select('description').exec();\n\t\t// let jobNames = await Jobs.find({status: 'Active'}).select('well').exec();\n\n\t\t// console.log(jobNames.map(a => a.well));\n\n\t\t// this._imap.once('ready', () => {\n\t\t// \tthis._imap.openBox('INBOX', true, function(err, box) {\n\t\t// \t\tif (err) {\n\t\t// \t\t\tthrow err;\n\t\t// \t\t}\n\n\t\t// \t\tthat._imap.search([ 'NEW' ], function(err, results) {\n\n\t\t// \t\t\tconsole.log(err, results);\n\n\t\t// \t\t\tif (err || !results.length) {\n\t\t// \t\t\t\treturn that._imap.end();\n\t\t// \t\t\t}\n\n\t\t// \t\t\tlet f = that._imap.fetch(results[0], { bodies: ['HEADER.FIELDS (FROM)', 'TEXT'] });\n\t\t// \t\t\tf.on('message', function(msg, seqno) {\n\t\t// \t\t\t\t// console.log('Message #%d', seqno);\n\t\t// \t\t\t\tlet prefix = '(#' + seqno + ') ';\n\t\t// \t\t\t\tmsg.on('body', function(stream, info) {\n\t\t// \t\t\t\t\tlet buffer = '', count = 0;\n\t\t// \t\t\t\t\tstream.on('data', function(chunk) {\n\t\t// \t\t\t\t\t\tcount += chunk.length;\n\t\t// \t\t\t\t\t\tbuffer += chunk.toString('utf8');\n\t\t// \t\t\t\t\t});\n\t\t// \t\t\t\t\tstream.once('end', function() {\n\t\t// \t\t\t\t\t\tif (info.which === 'TEXT') {\n\t\t// \t\t\t\t\t\t\t// console.log(buffer);\n\t\t// \t\t\t\t\t\t\t// console.log(typeof(buffer));\n\t\t// \t\t\t\t\t\t\tlet lines = buffer.split('\\r\\n');\n\t\t// \t\t\t\t\t\t\t// console.log(lines);\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t// \t\t\t\t\t\t\t// let i = 0;\n\t\t// \t\t\t\t\t\t\t// lines.forEach(line => {\n\n\t\t// \t\t\t\t\t\t\t// \tlet date: Date;\n\t\t// \t\t\t\t\t\t\t// \tlet dateString;\n\n\t\t// \t\t\t\t\t\t\t// \tif (line.includes('From')) {\n\t\t// \t\t\t\t\t\t\t// \t\tconsole.log(line);\n\t\t// \t\t\t\t\t\t\t// \t}\n\t\t// \t\t\t\t\t\t\t// \tif (!line.includes('class=3D') && !line.includes('style=3D')) {\n\t\t// \t\t\t\t\t\t\t// \t\tif (line.includes('Well') || line.includes('Well Name') || line.includes('Job') || line.includes('Pad')) {\n\t\t// \t\t\t\t\t\t\t// \t\t\tlet best = stringSimilarity.findBestMatch(line, jobNames.map(a => a.well)).bestMatch;\n\t\n\t\t// \t\t\t\t\t\t\t// \t\t\tif (best && best.rating > 0.5) {\n\t\t// \t\t\t\t\t\t\t// \t\t\t\tconsole.log('Well', line);\n\t\t// \t\t\t\t\t\t\t// \t\t\t}\n\t\t// \t\t\t\t\t\t\t// \t\t}\n\t\t// \t\t\t\t\t\t\t// \t\tif (line.includes('Product') || line.includes('Chemical')) {\n\t\t// \t\t\t\t\t\t\t// \t\t\tlet best = stringSimilarity.findBestMatch(line, chemicalNames.map(a => a.description)).bestMatch;\n\t\n\t\t// \t\t\t\t\t\t\t// \t\t\tif (best && best.rating > 0.5) {\n\t\t// \t\t\t\t\t\t\t// \t\t\t\tconsole.log('Chemical', line);\n\t\t// \t\t\t\t\t\t\t// \t\t\t}\n\t\t// \t\t\t\t\t\t\t// \t\t}\n\t\t// \t\t\t\t\t\t\t// \t\tif (line.includes('Quantity') || line.includes('Qty') || line.includes('Amount')) {\n\t\t// \t\t\t\t\t\t\t// \t\t\tconsole.log('Qty', line);\n\t\t// \t\t\t\t\t\t\t// \t\t}\n\t\t// \t\t\t\t\t\t\t// \t\tif (line.includes('Date')) {\n\t\t// \t\t\t\t\t\t\t// \t\t\tconsole.log('Date', line);\n\t\t// \t\t\t\t\t\t\t// \t\t\tconsole.log(moment(Date.parse(line)));\n\t\t// \t\t\t\t\t\t\t// \t\t\tdate = moment(Date.parse(line)).toDate();\n\t\t// \t\t\t\t\t\t\t// \t\t\tdateString = line;\n\t\t// \t\t\t\t\t\t\t// \t\t}\n\t\t// \t\t\t\t\t\t\t// \t\tif (line.includes('Time')) {\n\t\t// \t\t\t\t\t\t\t// \t\t\tconsole.log('Time', line);\n\t\t// \t\t\t\t\t\t\t// \t\t\tconsole.log(moment(Date.parse(line)));\n\t\t// \t\t\t\t\t\t\t// \t\t\tconsole.log(moment(date.setTime(Date.parse(line))));\n\t\t// \t\t\t\t\t\t\t// \t\t}\n\t\t// \t\t\t\t\t\t\t// \t}\n\t\t// \t\t\t\t\t\t\t// });\n\t\t// \t\t\t\t\t\t}\n\t\t// \t\t\t\t\t});\n\t\t// \t\t\t\t});\n\t\t\t\t\t\n\t\t// \t\t\t\tmsg.once('attributes', function(attrs) {\n\t\t// \t\t\t\t\tconsole.log(prefix + 'Attributes: %s', inspect(attrs, false, 8));\n\t\t// \t\t\t\t});\n\n\t\t// \t\t\t\tmsg.once('end', function() {\n\t\t// \t\t\t\t\tconsole.log(prefix + 'Finished');\n\t\t// \t\t\t\t});\n\t\t// \t\t\t});\n\t\t\t\t\t\n\t\t// \t\t\tf.once('error', function(error) {\n\t\t// \t\t\t\tconsole.log('Fetch error: ' + error);\n\t\t// \t\t\t});\n\n\t\t// \t\t\tf.once('end', function() {\n\t\t// \t\t\t\tconsole.log('Done fetching all messages!');\n\t\t// \t\t\t\tthat._imap.end();\n\t\t// \t\t\t});\n\t\t// \t\t});\n\t\t// \t});\n\t\t// });\n\n\t\t// this._imap.connect();\n\n\t\tthis._aws = new aws.S3({\n\t\t\taccessKeyId: serverConfig.AWSACCESSKEYID,\n\t\t\tsecretAccessKey: serverConfig.AWSSECRETACCESSKEY,\n\t\t\tregion: serverConfig.AWSREGION\n\t\t});\n\n\t\tsetInterval(() => {\n\t\t\tif (!this._runningQueue) {\n\t\t\t\tif (this._sendQueue.length) {\n\t\t\t\t\tthis._runningQueue = true;\n\t\t\t\t\tfor (let i = this._sendQueue.length - 1; i >= 0; i--) {\n\t\t\t\t\t\tlet ws = this._mainServer.getWS(this._sendQueue[i].id_ws);\n\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\tif (ws.bufferedAmount < 20480) {\n\t\t\t\t\t\t\t\tlet sendItem = this._sendQueue.pop();\n\t\t\t\t\t\t\t\tws.send(JSON.stringify(sendItem.data), (error) => {\n\t\t\t\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\t\t\t\tconsole.log('Error on WS: ', error);\n\t\t\t\t\t\t\t\t\t\tthis._mainServer.unsubscribeWS(ws);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tif (sendItem.method !== 'reportBuilderGetResults' && sendItem.method !== 'reportBuilderGetDistinctValue' && sendItem.method !== 'reportBuilderBuildTree' && sendItem.method !== 'generatePDF' && sendItem.method !== 'getWOOfflineData' && sendItem.method !== 'countQuery' && sendItem.method !== 'countWithQuery' && sendItem.method !== 'countCollectionWithQuery' && sendItem.method !== 'find' && sendItem.method !== 'findOne' && sendItem.method !== 'findWithOptions' && sendItem.method !== 'setWSAppVersion' && sendItem.method !== 'uploadFileAndSave' && sendItem.method !== 'getDrivers') {\n\t\t\t\t\t\t\t\t\tif (getBinarySize(JSON.stringify(sendItem.methodData)) < 200000 && getBinarySize(JSON.stringify(sendItem.data)) < 200000) {\n\t\t\t\t\t\t\t\t\t\tLogs.create({\n\t\t\t\t\t\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\t\t\t\t\t\ttype: 'client-response',\n\t\t\t\t\t\t\t\t\t\t\ttitle: 'Client Response',\n\t\t\t\t\t\t\t\t\t\t\tmessage: 'User: ' + ws['user'] + ', MessageId: ' + sendItem.data.messageId + ', Method: ' + sendItem.method,\n\t\t\t\t\t\t\t\t\t\t\tpayload: JSON.stringify([sendItem.methodData, sendItem.data], null, 2),\n\t\t\t\t\t\t\t\t\t\t\tmethod: sendItem.method,\n\t\t\t\t\t\t\t\t\t\t\tuser: ws['user'],\n\t\t\t\t\t\t\t\t\t\t\tmessageId: sendItem.data.messageId\n\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\tMethodResponses.create({\n\t\t\t\t\t\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\t\t\t\t\t\tid_user: ws['id_user'],\n\t\t\t\t\t\t\t\t\t\t\tmessage_id: sendItem.data.messageId,\n\t\t\t\t\t\t\t\t\t\t\tresponse: sendItem.data,\n\t\t\t\t\t\t\t\t\t\t\tmethod: sendItem.method,\n\t\t\t\t\t\t\t\t\t\t\tdate: sendItem.date\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\t\tLogs.create({\n\t\t\t\t\t\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\t\t\t\t\t\ttype: 'client-response',\n\t\t\t\t\t\t\t\t\t\t\ttitle: 'Client Response',\n\t\t\t\t\t\t\t\t\t\t\tmessage: 'User: ' + ws['user'] + ', MessageId: ' + sendItem.data.messageId + ', Method: ' + sendItem.method,\n\t\t\t\t\t\t\t\t\t\t\tpayload: 'Too Big',\n\t\t\t\t\t\t\t\t\t\t\tmethod: sendItem.method,\n\t\t\t\t\t\t\t\t\t\t\tuser: ws['user'],\n\t\t\t\t\t\t\t\t\t\t\tmessageId: sendItem.data.messageId\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tthis._sendQueue.splice(i, 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tthis._runningQueue = false;\n\t\t\t\t}\n\t\t\t}\n\t\t}, 25);\n\t}\n\n\tpublic getMainServer() {\n\t\treturn this._mainServer;\n\t}\n\n\t// Add methods to private methods object\n\tpublic methods(method: MethodModel) {\n\t\tthis._methods = Object.assign(this._methods, method);\n\t}\n\n\tpublic callMethodCron(method: string, ...methodData: any[]) {\n\t\tlet that = this;\n\n\t\tif (!that._methods[method]) {\n\t\t\tconsole.log('No Method: ' + method);\n\n\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Method: ' + method);\n\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tif ((methodData.length > 1 || methodData[0]) && !that._methods[method].skipValidation) {\n\t\t\tif (!that._methods[method].check) {\n\t\t\t\tconsole.error('No Check Function For Method ' + method);\n\n\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + method);\n\t\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse if (!that._methods[method].check._schema) {\n\t\t\t\tconsole.error('No Check Schema For Method ' + method);\n\n\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + method);\n\t\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tlet valObj = {};\n\t\t\t\tlet valKeys = Object.keys(that._methods[method].check._schema);\n\n\t\t\t\tlet rootKeys = valKeys.filter(a => !a.includes('.'));\n\t\t\t\t\n\t\t\t\tfor (let i = 0; i < methodData.length; i++) {\n\t\t\t\t\tvalObj[rootKeys[i]] = methodData[i];\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tthat._methods[method].check.validate(valObj);\n\t\t\t\t}\n\t\t\t\tcatch (errors) {\n\t\t\t\t\tif (errors) {\n\t\t\t\t\t\tconsole.error('Error in Method Check (' + method + ')', errors);\n\n\t\t\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'Match Error On Method ' + method + '\\n\\nData Being Checked\\n' + JSON.stringify(valObj, null, 2) + '\\n\\nErrors\\n' + JSON.stringify(errors, null, 2));\n\t\t\t\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tthat._methods[method].function.call(Object.assign({}, that, MethodManager.prototype, {id_user: '', user: '', id_ws: ''}), ...methodData);\n\t}\n\n\tpublic callMethodQueue(update: QueueMethodModel) {\n\t\t// console.log('Call Method Queue', update);\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tlet updateCopy = deepCopy(update);\n\t\t\n\t\t\tlet that = this;\n\n\t\t\tif (!that._methods[update.method]) {\n\t\t\t\tconsole.log('No Method: ' + update.method);\n\n\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Method: ' + update.method);\n\t\t\t\t\n\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\tmessageId: update.messageId,\n\t\t\t\t\thasError: true,\n\t\t\t\t\tdata: 'Internal Error'\n\t\t\t\t};\n\n\t\t\t\tthis._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);\n\n\t\t\t\tLogMethodLatencies.deleteOne({_id: update.id_methodLatency});\n\n\t\t\t\treturn resolve('No Method: ' + update.method);\n\t\t\t}\n\n\t\t\tif ((update.method_data.length > 1 || update.method_data[0]) && !that._methods[update.method].skipValidation) {\n\t\t\t\tif (!that._methods[update.method].check) {\n\t\t\t\t\tconsole.error('No Check Function For Method ' + update.method);\n\n\t\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + update.method);\n\t\t\t\t\t\n\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\tmessageId: update.messageId,\n\t\t\t\t\t\thasError: true,\n\t\t\t\t\t\tdata: 'Internal Error'\n\t\t\t\t\t};\n\t\t\n\t\t\t\t\tthis._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);\n\n\t\t\t\t\tLogMethodLatencies.deleteOne({_id: update.id_methodLatency});\n\t\t\n\t\t\t\t\treturn resolve('No Check Function For Method ' + update.method);\n\t\t\t\t}\n\t\t\t\telse if (!that._methods[update.method].check._schema) {\n\t\t\t\t\tconsole.error('No Check Schema For Method ' + update.method);\n\n\t\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + update.method);\n\t\t\t\t\t\n\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\tmessageId: update.messageId,\n\t\t\t\t\t\thasError: true,\n\t\t\t\t\t\tdata: 'Internal Error'\n\t\t\t\t\t};\n\t\t\n\t\t\t\t\tthis._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);\n\n\t\t\t\t\tLogMethodLatencies.deleteOne({_id: update.id_methodLatency});\n\t\t\n\t\t\t\t\treturn resolve('No Check Schema For Method ' + update.method);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet valObj = {};\n\t\t\t\t\tlet valKeys = Object.keys(that._methods[update.method].check._schema);\n\n\t\t\t\t\tlet rootKeys = valKeys.filter(a => !a.includes('.'));\n\t\t\t\t\t\n\t\t\t\t\tfor (let i = 0; i < update.method_data.length; i++) {\n\t\t\t\t\t\tvalObj[rootKeys[i]] = update.method_data[i];\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tthat._methods[update.method].check.validate(valObj);\n\t\t\t\t\t}\n\t\t\t\t\tcatch (errors) {\n\t\t\t\t\t\tif (errors) {\n\t\t\t\t\t\t\tconsole.error('Error in Method Check (' + update.method + ')', errors);\n\n\t\t\t\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'Match Error On Method ' + update.method + '\\n\\nData Being Checked\\n' + JSON.stringify(valObj, null, 2) + '\\n\\nErrors\\n' + JSON.stringify(errors, null, 2));\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\t\tmessageId: update.messageId,\n\t\t\t\t\t\t\t\thasError: true,\n\t\t\t\t\t\t\t\tdata: 'Internal Error'\n\t\t\t\t\t\t\t};\n\t\t\t\t\n\t\t\t\t\t\t\tthis._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);\n\n\t\t\t\t\t\t\tLogMethodLatencies.deleteOne({_id: update.id_methodLatency});\n\t\t\t\t\n\t\t\t\t\t\t\treturn resolve('Error in Method Check (' + update.method + ')');\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet timeout = setTimeout(() => {\n\t\t\t\tconsole.error('Timeout on method', update);\n\t\t\t\tthis.callMethodInternal.call(this, 'insertErrorLog', 'Timeout on method: ', [update]);\n\t\t\t\tresolve('Timeout');\n\t\t\t}, 5000);\n\n\t\t\t// console.log('Run Method', update.method);\n\t\t\t\n\t\t\tthat._methods[update.method].function.call(Object.assign({}, that, MethodManager.prototype, {id_user: update.id_user, user: update.user, id_ws: update.id_ws}), ...update.method_data).then(async (res) => {\n\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\tmessageId: update.messageId,\n\t\t\t\t\thasError: false,\n\t\t\t\t\tdata: res\n\t\t\t\t};\n\n\t\t\t\tthis._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);\n\n\t\t\t\tclearTimeout(timeout);\n\n\t\t\t\tlet latency = await LogMethodLatencies.findById(update.id_methodLatency);\n\n\t\t\t\tif (latency) {\n\t\t\t\t\tLogMethodLatencies.updateOne({_id: update.id_methodLatency}, {$set: {date_end: new Date(), latency_ms: moment().diff(moment(latency.date_start), 'milliseconds', true)}}).exec();\n\t\t\t\t}\n\n\t\t\t\tresolve(serverRes);\n\t\t\t}, err => {\n\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\tmessageId: update.messageId,\n\t\t\t\t\thasError: true,\n\t\t\t\t\tdata: err\n\t\t\t\t};\n\n\t\t\t\tthis._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);\n\n\t\t\t\tclearTimeout(timeout);\n\n\t\t\t\tLogMethodLatencies.deleteOne({_id: update.id_methodLatency});\n\n\t\t\t\tresolve(serverRes);\n\t\t\t});\n\t\t});\n\t}\n\n\n\n\t// Call/run method (Emit on Socket)\n\tpublic callMethod(id_methodLatency: string, ws: WebSocket, messageDate: Date, messageId: number, method: string, ...methodData: any[]) {\n\t\tlet that = this;\n\n\t\tif (!that._methods[method]) {\n\t\t\tconsole.log('No Method: ' + method);\n\n\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Method: ' + method);\n\t\t\t\n\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\tmessageId: messageId,\n\t\t\t\thasError: true,\n\t\t\t\tdata: 'Internal Error'\n\t\t\t};\n\n\t\t\tthis.sendWS(ws, messageDate, method, methodData, serverRes);\n\n\t\t\tLogMethodLatencies.deleteOne({_id: id_methodLatency});\n\n\t\t\treturn;\n\t\t}\n\n\t\tif ((methodData.length > 1 || methodData[0]) && !that._methods[method].skipValidation) {\n\t\t\tif (!that._methods[method].check) {\n\t\t\t\tconsole.error('No Check Function For Method ' + method);\n\n\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + method);\n\t\t\t\t\n\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\thasError: true,\n\t\t\t\t\tdata: 'Internal Error'\n\t\t\t\t};\n\t\n\t\t\t\tthis.sendWS(ws, messageDate, method, methodData, serverRes);\n\n\t\t\t\tLogMethodLatencies.deleteOne({_id: id_methodLatency});\n\t\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse if (!that._methods[method].check._schema) {\n\t\t\t\tconsole.error('No Check Schema For Method ' + method);\n\n\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + method);\n\t\t\t\t\n\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\thasError: true,\n\t\t\t\t\tdata: 'Internal Error'\n\t\t\t\t};\n\n\t\t\t\tLogMethodLatencies.deleteOne({_id: id_methodLatency});\n\t\n\t\t\t\tthis.sendWS(ws, messageDate, method, methodData, serverRes);\n\t\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tlet valObj = {};\n\t\t\t\tlet valKeys = Object.keys(that._methods[method].check._schema);\n\n\t\t\t\tlet rootKeys = valKeys.filter(a => !a.includes('.'));\n\t\t\t\t\n\t\t\t\tfor (let i = 0; i < methodData.length; i++) {\n\t\t\t\t\tvalObj[rootKeys[i]] = methodData[i];\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tthat._methods[method].check.validate(valObj);\n\t\t\t\t}\n\t\t\t\tcatch (errors) {\n\t\t\t\t\tif (errors) {\n\t\t\t\t\t\tconsole.error('Error in Method Check (' + method + ')', errors);\n\n\t\t\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'Match Error On Method ' + method + '\\n\\nData Being Checked\\n' + JSON.stringify(valObj, null, 2) + '\\n\\nErrors\\n' + JSON.stringify(errors, null, 2));\n\t\t\t\t\t\t\n\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\thasError: true,\n\t\t\t\t\t\t\tdata: 'Internal Error'\n\t\t\t\t\t\t};\n\t\t\t\t\t\t\n\t\t\t\t\t\tthis.sendWS(ws, messageDate, method, methodData, serverRes);\n\n\t\t\t\t\t\tLogMethodLatencies.deleteOne({_id: id_methodLatency});\n\t\t\t\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tthat._methods[method].function.call(Object.assign({}, that, MethodManager.prototype, {id_user: ws['id_user'], user: ws['user'], id_ws: ws['id_socket']}), ...methodData).then(async (res) => {\n\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\tmessageId: messageId,\n\t\t\t\thasError: false,\n\t\t\t\tdata: res\n\t\t\t};\n\n\t\t\tthis.sendWS(ws, messageDate, method, methodData, serverRes);\n\n\t\t\tlet latency = await LogMethodLatencies.findById(id_methodLatency);\n\n\t\t\tif (latency) {\n\t\t\t\tLogMethodLatencies.updateOne({_id: id_methodLatency}, {$set: {date_end: new Date(), latency_ms: moment().diff(moment(latency.date_start), 'milliseconds', true)}}).exec();\n\t\t\t}\n\t\t}, err => {\n\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\tmessageId: messageId,\n\t\t\t\thasError: true,\n\t\t\t\tdata: err\n\t\t\t};\n\n\t\t\tthis.sendWS(ws, messageDate, method, methodData, serverRes);\n\n\t\t\tLogMethodLatencies.deleteOne({_id: id_methodLatency});\n\t\t});\n\t}\n\n\t// Call/run method internal (No Emit on Socket)\n\tpublic callMethodInternal(method, ...methodData: any[]): Promise<any> {\n\t\tlet that = this;\n\n\t\tif (!that._methods[method]) {\n\t\t\tconsole.log('No Method: ' + method);\n\t\t\treturn;\n\t\t}\n\n\t\tif ((methodData.length > 1 || (methodData[0] && typeof(methodData[0]) !== 'function')) && !that._methods[method].skipValidation) {\n\t\t\tif (!that._methods[method].check) {\n\t\t\t\tconsole.error('No Check Function For Method ' + method);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse if (!that._methods[method].check._schema) {\n\t\t\t\tconsole.error('No Check Schema For Method ' + method);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tlet promise = that._methods[method].function.call(Object.assign({}, that, MethodManager.prototype), ...methodData);\n\n\t\tif (methodData[methodData.length - 1] && typeof(methodData[methodData.length - 1]) === 'function') {\n\t\t\tpromise.then(res => methodData[methodData.length - 1](null, res), err => methodData[methodData.length - 1](err, null));\n\t\t}\n\n\t\treturn promise;\n\t}\n\n\tpublic callSupportMethodInternal(supportMethod, ...methodData: any[]): Promise<any> {\n\t\tlet that = this;\n\n\t\tif (!that.getMainServer().getSupportManager()._supportMethods[supportMethod]) {\n\t\t\tconsole.log('No Support Method: ' + supportMethod);\n\t\t\treturn;\n\t\t}\n\n\t\tif ((methodData.length > 1 || (methodData[0] && typeof(methodData[0]) !== 'function')) && !that.getMainServer().getSupportManager()._supportMethods[supportMethod].skipValidation) {\n\t\t\tif (!that.getMainServer().getSupportManager()._supportMethods[supportMethod].check) {\n\t\t\t\tconsole.error('No Check Function For Method ' + supportMethod);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse if (!that.getMainServer().getSupportManager()._supportMethods[supportMethod].check._schema) {\n\t\t\t\tconsole.error('No Check Schema For Method ' + supportMethod);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tlet promise = that.getMainServer().getSupportManager()._supportMethods[supportMethod].function.call(Object.assign({}, that, SupportManager.prototype), ...methodData);\n\n\t\tif (methodData[methodData.length - 1] && typeof(methodData[methodData.length - 1]) === 'function') {\n\t\t\tpromise.then(res => methodData[methodData.length - 1](null, res), err => methodData[methodData.length - 1](err, null));\n\t\t}\n\n\t\treturn promise;\n\t}\n\n\tprivate sendWS(ws: WebSocket, messageDate: Date, method: string, methodData: any[], data: ServerResponseModel) {\n\t\tthis._sendQueue.splice(0, 0, {\n\t\t\tid_ws: ws['id_socket'],\n\t\t\tmethod: method,\n\t\t\tmethodData: methodData,\n\t\t\tdata: data,\n\t\t\tdate: messageDate\n\t\t});\n\t}\n\n\tpublic sendEmail(sendTo: string, subject: string, text?: string, html?: string, attachments?: any[], send_from?: string) {\n\t\tthis._mailer.sendMail({\n\t\t\treplyTo: undefined,\n\t\t\tfrom: send_from ? send_from : this.serverConfig.MAIL_FROM,\n\t\t\tto: sendTo,\n\t\t\tsubject: subject,\n\t\t\ttext: text,\n\t\t\thtml: html,\n\t\t\tattachments: attachments\n\t\t}, (err, info) => {\n\t\t\tif (err) {\n\t\t\t\tconsole.log(err);\n\t\t\t}\n\t\t});\n\t}\n\n\tpublic getAWS() {\n\t\treturn this._aws;\n\t}\n\n\tpublic readFile(fileName) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tif (fs.existsSync(path.join(__dirname, ('../private/' + fileName)))) {\n\t\t\t\tfs.readFile(path.join(__dirname, ('../private/' + fileName)), 'utf-8', (err, res) => { \n\t\t\t\t\tif (err) {\n\t\t\t\t\t\treject(err);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tresolve(res);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (fs.existsSync(path.join(this.clientDir, ('./private/' + fileName)))) {\n\t\t\t\t\tfs.readFile(path.join(this.clientDir, ('./private/' + fileName)), 'utf-8', (err, res) => { \n\t\t\t\t\t\tif (err) {\n\t\t\t\t\t\t\treject(err);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tresolve(res);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tpublic readImage(fileName) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tif (fs.existsSync(path.join(__dirname, ('../private/' + fileName)))) {\n\t\t\t\tfs.readFile(path.join(__dirname, ('../private/' + fileName)), 'base64', (err, res) => { \n\t\t\t\t\tif (err) {\n\t\t\t\t\t\treject(err);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tresolve(res);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (fs.existsSync(path.join(this.clientDir, ('./private/' + fileName)))) {\n\t\t\t\t\tfs.readFile(path.join(this.clientDir, ('./private/' + fileName)), 'base64', (err, res) => { \n\t\t\t\t\t\tif (err) {\n\t\t\t\t\t\t\treject(err);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tresolve(res);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n}"]}
|
|
1
|
+
{"version":3,"sources":["../../src/managers/method.manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;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ACR,MAAM,CAAC,GAAG,CAAC,CAAC;qBACZ;yBACI;wBACJ,OAAO,CAAC,GAAG,CAAC,CAAC;qBACb;gBACF,CAAC,CAAC,CAAC;aACH;iBACI;gBACJ,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,KAAI,CAAC,SAAS,EAAE,CAAC,YAAY,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE;oBACxE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,KAAI,CAAC,SAAS,EAAE,CAAC,YAAY,GAAG,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,UAAC,GAAG,EAAE,GAAG;wBACpF,IAAI,GAAG,EAAE;4BACR,MAAM,CAAC,GAAG,CAAC,CAAC;yBACZ;6BACI;4BACJ,OAAO,CAAC,GAAG,CAAC,CAAC;yBACb;oBACF,CAAC,CAAC,CAAC;iBACH;aACD;QACF,CAAC,CAAC,CAAC;IACJ,CAAC;IACF,oBAAC;AAAD,CArsBA,AAqsBC,IAAA;AArsBY,sCAAa","file":"method.manager.js","sourcesContent":["import { ServerResponseModel } from '../models/server-response.model';\nimport { loadCollectionMethods } from '../methods/collections';\nimport { MethodModel } from '../models/method.model';\nimport { loadLogMethods } from '../methods/logs';\nimport { loadCounterMethods } from '../methods/counters';\nimport { loadPDFMethods } from '../methods/pdf';\nimport { loadAWSMethods } from '../methods/aws';\nimport { loadCloudConvertMethods } from '../methods/cloudconvert';\nimport * as path from 'path';\nimport * as fs from 'fs';\nimport * as nodemailer from 'nodemailer';\nimport * as imap from 'imap';\nimport * as aws from 'aws-sdk';\nimport { loadAccountMethods } from '../methods/accounts';\nimport { loadServerInit } from '../fixtures/init';\nimport { loadServerCronJobs } from '../fixtures/cron-jobs';\nimport { loadCronJobMethods } from '../methods/cron-jobs';\nimport { loadFlagMethods } from '../methods/flags';\nimport { QueueMethodModel } from '../models/queue-method.model';\nimport { MethodResponses } from '../collections/method-response.collection';\nimport { Types } from 'mongoose';\nimport { deepCopy, getBinarySize } from '../util/common';\nimport { Logs } from '../collections/log.collection';\nimport ResolveIOMainServer from '../server-app';\nimport { SupportManager } from './support.manager';\nimport { LogMethodLatencies } from '../collections/log-method-latency.collection';\nimport * as moment from 'moment';\nimport { loadReportBuilderMethods } from '../methods/report-builder';\n\nexport class MethodManager {\n\n\tprivate _mainServer: ResolveIOMainServer;\n\tpublic _methods: MethodModel = {};\n\tprivate _mailer: nodemailer.Transporter;\n\tprivate _imap: imap;\n\tprivate _aws: aws.S3;\n\tprivate serverConfig;\n\tprivate clientDir;\n\n\tprivate _sendQueue = [];\n\tprivate _runningQueue = false;\n\n\tconstructor(mainServer, serverConfig, clientDir) {\n\t\tthis._mainServer = mainServer;\n\t\tthis.serverConfig = serverConfig;\n\t\tthis.clientDir = clientDir;\n\n\t\t// Fixtures\n\t\tloadServerInit();\n\t\tloadServerCronJobs();\n\n\t\t// Methods\n\t\tloadAccountMethods(this);\n\t\tloadAWSMethods(this);\n\t\tloadCloudConvertMethods(this);\n\t\tloadCollectionMethods(this);\n\t\tloadCounterMethods(this);\n\t\tloadLogMethods(this);\n\t\tloadPDFMethods(this);\n\t\tloadCronJobMethods(this);\n\t\tloadFlagMethods(this);\n\t\tloadReportBuilderMethods(this);\n\n\t\tif (mainServer.sesMail) {\n\t\t\tthis._mailer = nodemailer.createTransport({\n\t\t\t\tSES: new aws.SES({\n\t\t\t\t\tapiVersion: '2010-12-01',\n\t\t\t\t\taccessKeyId: serverConfig.AWSACCESSKEYID,\n\t\t\t\t\tsecretAccessKey: serverConfig.AWSSECRETACCESSKEY,\n\t\t\t\t\tregion: serverConfig.AWSSES_REGION\n\t\t\t\t})\n\t\t\t});\n\t\t}\n\t\telse {\n\t\t\tthis._mailer = nodemailer.createTransport({\n\t\t\t\thost: this.serverConfig['MAIL_HOST'], // 'smtp.office365.com', // Office 365 server\n\t\t\t\tport: this.serverConfig['MAIL_PORT'], //587, // secure SMTP\n\t\t\t\tsecure: false, // false for TLS - as a boolean not string - but the default is false so just remove this completely\n\t\t\t\tauth: {\n\t\t\t\t\tuser: this.serverConfig['MAIL_USERNAME'],\n\t\t\t\t\tpass: this.serverConfig['MAIL_PASSWORD']\n\t\t\t\t},\n\t\t\t\ttls: {\n\t\t\t\t\tciphers: 'SSLv3'\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\t// this._imap = new imap({\n\t\t// \tuser: this.serverConfig['ORDERS_EMAIL'],\n\t\t// \tpassword: this.serverConfig['ORDERS_PASSWORD'],\n\t\t// \thost: this.serverConfig['ORDERS_HOST'],\n\t\t// \tport: this.serverConfig['ORDERS_PORT'],\n\t\t// \ttls: this.serverConfig['ORDERS_TLS']\n\t\t// });\n\n\t\t// let that = this;\n\n\t\t// let chemicalNames = await Chemicals.find({}).select('description').exec();\n\t\t// let jobNames = await Jobs.find({status: 'Active'}).select('well').exec();\n\n\t\t// console.log(jobNames.map(a => a.well));\n\n\t\t// this._imap.once('ready', () => {\n\t\t// \tthis._imap.openBox('INBOX', true, function(err, box) {\n\t\t// \t\tif (err) {\n\t\t// \t\t\tthrow err;\n\t\t// \t\t}\n\n\t\t// \t\tthat._imap.search([ 'NEW' ], function(err, results) {\n\n\t\t// \t\t\tconsole.log(err, results);\n\n\t\t// \t\t\tif (err || !results.length) {\n\t\t// \t\t\t\treturn that._imap.end();\n\t\t// \t\t\t}\n\n\t\t// \t\t\tlet f = that._imap.fetch(results[0], { bodies: ['HEADER.FIELDS (FROM)', 'TEXT'] });\n\t\t// \t\t\tf.on('message', function(msg, seqno) {\n\t\t// \t\t\t\t// console.log('Message #%d', seqno);\n\t\t// \t\t\t\tlet prefix = '(#' + seqno + ') ';\n\t\t// \t\t\t\tmsg.on('body', function(stream, info) {\n\t\t// \t\t\t\t\tlet buffer = '', count = 0;\n\t\t// \t\t\t\t\tstream.on('data', function(chunk) {\n\t\t// \t\t\t\t\t\tcount += chunk.length;\n\t\t// \t\t\t\t\t\tbuffer += chunk.toString('utf8');\n\t\t// \t\t\t\t\t});\n\t\t// \t\t\t\t\tstream.once('end', function() {\n\t\t// \t\t\t\t\t\tif (info.which === 'TEXT') {\n\t\t// \t\t\t\t\t\t\t// console.log(buffer);\n\t\t// \t\t\t\t\t\t\t// console.log(typeof(buffer));\n\t\t// \t\t\t\t\t\t\tlet lines = buffer.split('\\r\\n');\n\t\t// \t\t\t\t\t\t\t// console.log(lines);\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t// \t\t\t\t\t\t\t// let i = 0;\n\t\t// \t\t\t\t\t\t\t// lines.forEach(line => {\n\n\t\t// \t\t\t\t\t\t\t// \tlet date: Date;\n\t\t// \t\t\t\t\t\t\t// \tlet dateString;\n\n\t\t// \t\t\t\t\t\t\t// \tif (line.includes('From')) {\n\t\t// \t\t\t\t\t\t\t// \t\tconsole.log(line);\n\t\t// \t\t\t\t\t\t\t// \t}\n\t\t// \t\t\t\t\t\t\t// \tif (!line.includes('class=3D') && !line.includes('style=3D')) {\n\t\t// \t\t\t\t\t\t\t// \t\tif (line.includes('Well') || line.includes('Well Name') || line.includes('Job') || line.includes('Pad')) {\n\t\t// \t\t\t\t\t\t\t// \t\t\tlet best = stringSimilarity.findBestMatch(line, jobNames.map(a => a.well)).bestMatch;\n\t\n\t\t// \t\t\t\t\t\t\t// \t\t\tif (best && best.rating > 0.5) {\n\t\t// \t\t\t\t\t\t\t// \t\t\t\tconsole.log('Well', line);\n\t\t// \t\t\t\t\t\t\t// \t\t\t}\n\t\t// \t\t\t\t\t\t\t// \t\t}\n\t\t// \t\t\t\t\t\t\t// \t\tif (line.includes('Product') || line.includes('Chemical')) {\n\t\t// \t\t\t\t\t\t\t// \t\t\tlet best = stringSimilarity.findBestMatch(line, chemicalNames.map(a => a.description)).bestMatch;\n\t\n\t\t// \t\t\t\t\t\t\t// \t\t\tif (best && best.rating > 0.5) {\n\t\t// \t\t\t\t\t\t\t// \t\t\t\tconsole.log('Chemical', line);\n\t\t// \t\t\t\t\t\t\t// \t\t\t}\n\t\t// \t\t\t\t\t\t\t// \t\t}\n\t\t// \t\t\t\t\t\t\t// \t\tif (line.includes('Quantity') || line.includes('Qty') || line.includes('Amount')) {\n\t\t// \t\t\t\t\t\t\t// \t\t\tconsole.log('Qty', line);\n\t\t// \t\t\t\t\t\t\t// \t\t}\n\t\t// \t\t\t\t\t\t\t// \t\tif (line.includes('Date')) {\n\t\t// \t\t\t\t\t\t\t// \t\t\tconsole.log('Date', line);\n\t\t// \t\t\t\t\t\t\t// \t\t\tconsole.log(moment(Date.parse(line)));\n\t\t// \t\t\t\t\t\t\t// \t\t\tdate = moment(Date.parse(line)).toDate();\n\t\t// \t\t\t\t\t\t\t// \t\t\tdateString = line;\n\t\t// \t\t\t\t\t\t\t// \t\t}\n\t\t// \t\t\t\t\t\t\t// \t\tif (line.includes('Time')) {\n\t\t// \t\t\t\t\t\t\t// \t\t\tconsole.log('Time', line);\n\t\t// \t\t\t\t\t\t\t// \t\t\tconsole.log(moment(Date.parse(line)));\n\t\t// \t\t\t\t\t\t\t// \t\t\tconsole.log(moment(date.setTime(Date.parse(line))));\n\t\t// \t\t\t\t\t\t\t// \t\t}\n\t\t// \t\t\t\t\t\t\t// \t}\n\t\t// \t\t\t\t\t\t\t// });\n\t\t// \t\t\t\t\t\t}\n\t\t// \t\t\t\t\t});\n\t\t// \t\t\t\t});\n\t\t\t\t\t\n\t\t// \t\t\t\tmsg.once('attributes', function(attrs) {\n\t\t// \t\t\t\t\tconsole.log(prefix + 'Attributes: %s', inspect(attrs, false, 8));\n\t\t// \t\t\t\t});\n\n\t\t// \t\t\t\tmsg.once('end', function() {\n\t\t// \t\t\t\t\tconsole.log(prefix + 'Finished');\n\t\t// \t\t\t\t});\n\t\t// \t\t\t});\n\t\t\t\t\t\n\t\t// \t\t\tf.once('error', function(error) {\n\t\t// \t\t\t\tconsole.log('Fetch error: ' + error);\n\t\t// \t\t\t});\n\n\t\t// \t\t\tf.once('end', function() {\n\t\t// \t\t\t\tconsole.log('Done fetching all messages!');\n\t\t// \t\t\t\tthat._imap.end();\n\t\t// \t\t\t});\n\t\t// \t\t});\n\t\t// \t});\n\t\t// });\n\n\t\t// this._imap.connect();\n\n\t\tthis._aws = new aws.S3({\n\t\t\taccessKeyId: serverConfig.AWSACCESSKEYID,\n\t\t\tsecretAccessKey: serverConfig.AWSSECRETACCESSKEY,\n\t\t\tregion: serverConfig.AWSREGION\n\t\t});\n\n\t\tsetInterval(() => {\n\t\t\tif (!this._runningQueue) {\n\t\t\t\tif (this._sendQueue.length) {\n\t\t\t\t\tthis._runningQueue = true;\n\t\t\t\t\tfor (let i = this._sendQueue.length - 1; i >= 0; i--) {\n\t\t\t\t\t\tlet ws = this._mainServer.getWS(this._sendQueue[i].id_ws);\n\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\tif (ws.bufferedAmount < 20480) {\n\t\t\t\t\t\t\t\tlet sendItem = this._sendQueue.pop();\n\t\t\t\t\t\t\t\tws.send(JSON.stringify(sendItem.data), (error) => {\n\t\t\t\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\t\t\t\tconsole.log('Error on WS: ', error);\n\t\t\t\t\t\t\t\t\t\tthis._mainServer.unsubscribeWS(ws);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tif (sendItem.method !== 'reportBuilderGetResults' && sendItem.method !== 'reportBuilderGetDistinctValue' && sendItem.method !== 'reportBuilderBuildTree' && sendItem.method !== 'generatePDF' && sendItem.method !== 'getWOOfflineData' && sendItem.method !== 'countQuery' && sendItem.method !== 'countWithQuery' && sendItem.method !== 'countCollectionWithQuery' && sendItem.method !== 'find' && sendItem.method !== 'findOne' && sendItem.method !== 'findWithOptions' && sendItem.method !== 'setWSAppVersion' && sendItem.method !== 'uploadFileAndSave' && sendItem.method !== 'getDrivers') {\n\t\t\t\t\t\t\t\t\tif (getBinarySize(JSON.stringify(sendItem.methodData)) < 200000 && getBinarySize(JSON.stringify(sendItem.data)) < 200000) {\n\t\t\t\t\t\t\t\t\t\tLogs.create({\n\t\t\t\t\t\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\t\t\t\t\t\ttype: 'client-response',\n\t\t\t\t\t\t\t\t\t\t\ttitle: 'Client Response',\n\t\t\t\t\t\t\t\t\t\t\tmessage: 'User: ' + ws['user'] + ', MessageId: ' + sendItem.data.messageId + ', Method: ' + sendItem.method,\n\t\t\t\t\t\t\t\t\t\t\tpayload: JSON.stringify([sendItem.methodData, sendItem.data], null, 2),\n\t\t\t\t\t\t\t\t\t\t\tmethod: sendItem.method,\n\t\t\t\t\t\t\t\t\t\t\tuser: ws['user'],\n\t\t\t\t\t\t\t\t\t\t\tmessageId: sendItem.data.messageId\n\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\tMethodResponses.create({\n\t\t\t\t\t\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\t\t\t\t\t\tid_user: ws['id_user'],\n\t\t\t\t\t\t\t\t\t\t\tmessage_id: sendItem.data.messageId,\n\t\t\t\t\t\t\t\t\t\t\tresponse: sendItem.data,\n\t\t\t\t\t\t\t\t\t\t\tmethod: sendItem.method,\n\t\t\t\t\t\t\t\t\t\t\tdate: sendItem.date\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\t\tLogs.create({\n\t\t\t\t\t\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\t\t\t\t\t\ttype: 'client-response',\n\t\t\t\t\t\t\t\t\t\t\ttitle: 'Client Response',\n\t\t\t\t\t\t\t\t\t\t\tmessage: 'User: ' + ws['user'] + ', MessageId: ' + sendItem.data.messageId + ', Method: ' + sendItem.method,\n\t\t\t\t\t\t\t\t\t\t\tpayload: 'Too Big',\n\t\t\t\t\t\t\t\t\t\t\tmethod: sendItem.method,\n\t\t\t\t\t\t\t\t\t\t\tuser: ws['user'],\n\t\t\t\t\t\t\t\t\t\t\tmessageId: sendItem.data.messageId\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tthis._sendQueue.splice(i, 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tthis._runningQueue = false;\n\t\t\t\t}\n\t\t\t}\n\t\t}, 25);\n\t}\n\n\tpublic getMainServer() {\n\t\treturn this._mainServer;\n\t}\n\n\t// Add methods to private methods object\n\tpublic methods(method: MethodModel) {\n\t\tthis._methods = Object.assign(this._methods, method);\n\t}\n\n\tpublic callMethodCron(method: string, ...methodData: any[]) {\n\t\tlet that = this;\n\n\t\tif (!that._methods[method]) {\n\t\t\tconsole.log('No Method: ' + method);\n\n\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Method: ' + method);\n\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tif ((methodData.length > 1 || methodData[0]) && !that._methods[method].skipValidation) {\n\t\t\tif (!that._methods[method].check) {\n\t\t\t\tconsole.error('No Check Function For Method ' + method);\n\n\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + method);\n\t\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse if (!that._methods[method].check._schema) {\n\t\t\t\tconsole.error('No Check Schema For Method ' + method);\n\n\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + method);\n\t\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tlet valObj = {};\n\t\t\t\tlet valKeys = Object.keys(that._methods[method].check._schema);\n\n\t\t\t\tlet rootKeys = valKeys.filter(a => !a.includes('.'));\n\t\t\t\t\n\t\t\t\tfor (let i = 0; i < methodData.length; i++) {\n\t\t\t\t\tvalObj[rootKeys[i]] = methodData[i];\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tthat._methods[method].check.validate(valObj);\n\t\t\t\t}\n\t\t\t\tcatch (errors) {\n\t\t\t\t\tif (errors) {\n\t\t\t\t\t\tconsole.error('Error in Method Check (' + method + ')', errors);\n\n\t\t\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'Match Error On Method ' + method + '\\n\\nData Being Checked\\n' + JSON.stringify(valObj, null, 2) + '\\n\\nErrors\\n' + JSON.stringify(errors, null, 2));\n\t\t\t\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tthat._methods[method].function.call(Object.assign({}, that, MethodManager.prototype, {id_user: '', user: '', id_ws: ''}), ...methodData);\n\t}\n\n\tpublic callMethodQueue(update: QueueMethodModel) {\n\t\t// console.log('Call Method Queue', update);\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tlet updateCopy = deepCopy(update);\n\t\t\n\t\t\tlet that = this;\n\n\t\t\tif (!that._methods[update.method]) {\n\t\t\t\tconsole.log('No Method: ' + update.method);\n\n\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Method: ' + update.method);\n\t\t\t\t\n\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\tmessageId: update.messageId,\n\t\t\t\t\thasError: true,\n\t\t\t\t\tdata: 'Internal Error'\n\t\t\t\t};\n\n\t\t\t\tthis._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);\n\n\t\t\t\tLogMethodLatencies.deleteOne({_id: update.id_methodLatency});\n\n\t\t\t\treturn resolve('No Method: ' + update.method);\n\t\t\t}\n\n\t\t\tif ((update.method_data.length > 1 || update.method_data[0]) && !that._methods[update.method].skipValidation) {\n\t\t\t\tif (!that._methods[update.method].check) {\n\t\t\t\t\tconsole.error('No Check Function For Method ' + update.method);\n\n\t\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + update.method);\n\t\t\t\t\t\n\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\tmessageId: update.messageId,\n\t\t\t\t\t\thasError: true,\n\t\t\t\t\t\tdata: 'Internal Error'\n\t\t\t\t\t};\n\t\t\n\t\t\t\t\tthis._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);\n\n\t\t\t\t\tLogMethodLatencies.deleteOne({_id: update.id_methodLatency});\n\t\t\n\t\t\t\t\treturn resolve('No Check Function For Method ' + update.method);\n\t\t\t\t}\n\t\t\t\telse if (!that._methods[update.method].check._schema) {\n\t\t\t\t\tconsole.error('No Check Schema For Method ' + update.method);\n\n\t\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + update.method);\n\t\t\t\t\t\n\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\tmessageId: update.messageId,\n\t\t\t\t\t\thasError: true,\n\t\t\t\t\t\tdata: 'Internal Error'\n\t\t\t\t\t};\n\t\t\n\t\t\t\t\tthis._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);\n\n\t\t\t\t\tLogMethodLatencies.deleteOne({_id: update.id_methodLatency});\n\t\t\n\t\t\t\t\treturn resolve('No Check Schema For Method ' + update.method);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet valObj = {};\n\t\t\t\t\tlet valKeys = Object.keys(that._methods[update.method].check._schema);\n\n\t\t\t\t\tlet rootKeys = valKeys.filter(a => !a.includes('.'));\n\t\t\t\t\t\n\t\t\t\t\tfor (let i = 0; i < update.method_data.length; i++) {\n\t\t\t\t\t\tvalObj[rootKeys[i]] = update.method_data[i];\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tthat._methods[update.method].check.validate(valObj);\n\t\t\t\t\t}\n\t\t\t\t\tcatch (errors) {\n\t\t\t\t\t\tif (errors) {\n\t\t\t\t\t\t\tconsole.error('Error in Method Check (' + update.method + ')', errors);\n\n\t\t\t\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'Match Error On Method ' + update.method + '\\n\\nData Being Checked\\n' + JSON.stringify(valObj, null, 2) + '\\n\\nErrors\\n' + JSON.stringify(errors, null, 2));\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\t\tmessageId: update.messageId,\n\t\t\t\t\t\t\t\thasError: true,\n\t\t\t\t\t\t\t\tdata: 'Internal Error'\n\t\t\t\t\t\t\t};\n\t\t\t\t\n\t\t\t\t\t\t\tthis._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);\n\n\t\t\t\t\t\t\tLogMethodLatencies.deleteOne({_id: update.id_methodLatency});\n\t\t\t\t\n\t\t\t\t\t\t\treturn resolve('Error in Method Check (' + update.method + ')');\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet timeout = setTimeout(() => {\n\t\t\t\tconsole.error('Timeout on method', update);\n\t\t\t\tthis.callMethodInternal.call(this, 'insertErrorLog', 'Timeout on method: ', [update]);\n\t\t\t\tresolve('Timeout');\n\t\t\t}, 5000);\n\n\t\t\t// console.log('Run Method', update.method);\n\t\t\t\n\t\t\tthat._methods[update.method].function.call(Object.assign({}, that, MethodManager.prototype, {id_user: update.id_user, user: update.user, id_ws: update.id_ws}), ...update.method_data).then(async (res) => {\n\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\tmessageId: update.messageId,\n\t\t\t\t\thasError: false,\n\t\t\t\t\tdata: res\n\t\t\t\t};\n\n\t\t\t\tthis._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);\n\n\t\t\t\tclearTimeout(timeout);\n\n\t\t\t\tlet latency = await LogMethodLatencies.findById(update.id_methodLatency);\n\n\t\t\t\tif (latency) {\n\t\t\t\t\tLogMethodLatencies.updateOne({_id: update.id_methodLatency}, {$set: {date_end: new Date(), latency_ms: moment().diff(moment(latency.date_start), 'milliseconds', true)}}).exec();\n\t\t\t\t}\n\n\t\t\t\tresolve(serverRes);\n\t\t\t}, err => {\n\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\tmessageId: update.messageId,\n\t\t\t\t\thasError: true,\n\t\t\t\t\tdata: err\n\t\t\t\t};\n\n\t\t\t\tthis._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);\n\n\t\t\t\tclearTimeout(timeout);\n\n\t\t\t\tLogMethodLatencies.deleteOne({_id: update.id_methodLatency});\n\n\t\t\t\tresolve(serverRes);\n\t\t\t});\n\t\t});\n\t}\n\n\n\n\t// Call/run method (Emit on Socket)\n\tpublic callMethod(id_methodLatency: string, ws: WebSocket, messageDate: Date, messageId: number, method: string, ...methodData: any[]) {\n\t\tlet that = this;\n\n\t\tif (!that._methods[method]) {\n\t\t\tconsole.log('No Method: ' + method);\n\n\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Method: ' + method);\n\t\t\t\n\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\tmessageId: messageId,\n\t\t\t\thasError: true,\n\t\t\t\tdata: 'Internal Error'\n\t\t\t};\n\n\t\t\tthis.sendWS(ws, messageDate, method, methodData, serverRes);\n\n\t\t\tLogMethodLatencies.deleteOne({_id: id_methodLatency});\n\n\t\t\treturn;\n\t\t}\n\n\t\tif ((methodData.length > 1 || methodData[0]) && !that._methods[method].skipValidation) {\n\t\t\tif (!that._methods[method].check) {\n\t\t\t\tconsole.error('No Check Function For Method ' + method);\n\n\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + method);\n\t\t\t\t\n\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\thasError: true,\n\t\t\t\t\tdata: 'Internal Error'\n\t\t\t\t};\n\t\n\t\t\t\tthis.sendWS(ws, messageDate, method, methodData, serverRes);\n\n\t\t\t\tLogMethodLatencies.deleteOne({_id: id_methodLatency});\n\t\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse if (!that._methods[method].check._schema) {\n\t\t\t\tconsole.error('No Check Schema For Method ' + method);\n\n\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + method);\n\t\t\t\t\n\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\thasError: true,\n\t\t\t\t\tdata: 'Internal Error'\n\t\t\t\t};\n\n\t\t\t\tLogMethodLatencies.deleteOne({_id: id_methodLatency});\n\t\n\t\t\t\tthis.sendWS(ws, messageDate, method, methodData, serverRes);\n\t\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tlet valObj = {};\n\t\t\t\tlet valKeys = Object.keys(that._methods[method].check._schema);\n\n\t\t\t\tlet rootKeys = valKeys.filter(a => !a.includes('.'));\n\t\t\t\t\n\t\t\t\tfor (let i = 0; i < methodData.length; i++) {\n\t\t\t\t\tvalObj[rootKeys[i]] = methodData[i];\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tthat._methods[method].check.validate(valObj);\n\t\t\t\t}\n\t\t\t\tcatch (errors) {\n\t\t\t\t\tif (errors) {\n\t\t\t\t\t\tconsole.error('Error in Method Check (' + method + ')', errors);\n\n\t\t\t\t\t\tthat.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'Match Error On Method ' + method + '\\n\\nData Being Checked\\n' + JSON.stringify(valObj, null, 2) + '\\n\\nErrors\\n' + JSON.stringify(errors, null, 2));\n\t\t\t\t\t\t\n\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\thasError: true,\n\t\t\t\t\t\t\tdata: 'Internal Error'\n\t\t\t\t\t\t};\n\t\t\t\t\t\t\n\t\t\t\t\t\tthis.sendWS(ws, messageDate, method, methodData, serverRes);\n\n\t\t\t\t\t\tLogMethodLatencies.deleteOne({_id: id_methodLatency});\n\t\t\t\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tthat._methods[method].function.call(Object.assign({}, that, MethodManager.prototype, {id_user: ws['id_user'], user: ws['user'], id_ws: ws['id_socket']}), ...methodData).then(async (res) => {\n\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\tmessageId: messageId,\n\t\t\t\thasError: false,\n\t\t\t\tdata: res\n\t\t\t};\n\n\t\t\tthis.sendWS(ws, messageDate, method, methodData, serverRes);\n\n\t\t\tlet latency = await LogMethodLatencies.findById(id_methodLatency);\n\n\t\t\tif (latency) {\n\t\t\t\tLogMethodLatencies.updateOne({_id: id_methodLatency}, {$set: {date_end: new Date(), latency_ms: moment().diff(moment(latency.date_start), 'milliseconds', true)}}).exec();\n\t\t\t}\n\t\t}, err => {\n\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\tmessageId: messageId,\n\t\t\t\thasError: true,\n\t\t\t\tdata: err\n\t\t\t};\n\n\t\t\tthis.sendWS(ws, messageDate, method, methodData, serverRes);\n\n\t\t\tLogMethodLatencies.deleteOne({_id: id_methodLatency});\n\t\t});\n\t}\n\n\t// Call/run method internal (No Emit on Socket)\n\tpublic callMethodInternal(method, ...methodData: any[]): Promise<any> {\n\t\tlet that = this;\n\n\t\tif (!that._methods[method]) {\n\t\t\tconsole.log('No Method: ' + method);\n\t\t\treturn;\n\t\t}\n\n\t\tif ((methodData.length > 1 || (methodData[0] && typeof(methodData[0]) !== 'function')) && !that._methods[method].skipValidation) {\n\t\t\tif (!that._methods[method].check) {\n\t\t\t\tconsole.error('No Check Function For Method ' + method);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse if (!that._methods[method].check._schema) {\n\t\t\t\tconsole.error('No Check Schema For Method ' + method);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tlet promise = that._methods[method].function.call(Object.assign({}, that, MethodManager.prototype), ...methodData);\n\n\t\tif (methodData[methodData.length - 1] && typeof(methodData[methodData.length - 1]) === 'function') {\n\t\t\tpromise.then(res => methodData[methodData.length - 1](null, res), err => methodData[methodData.length - 1](err, null));\n\t\t}\n\n\t\treturn promise;\n\t}\n\n\tpublic callSupportMethodInternal(supportMethod, ...methodData: any[]): Promise<any> {\n\t\tlet that = this;\n\n\t\tif (!that.getMainServer().getSupportManager()._supportMethods[supportMethod]) {\n\t\t\tconsole.log('No Support Method: ' + supportMethod);\n\t\t\treturn;\n\t\t}\n\n\t\tif ((methodData.length > 1 || (methodData[0] && typeof(methodData[0]) !== 'function')) && !that.getMainServer().getSupportManager()._supportMethods[supportMethod].skipValidation) {\n\t\t\tif (!that.getMainServer().getSupportManager()._supportMethods[supportMethod].check) {\n\t\t\t\tconsole.error('No Check Function For Method ' + supportMethod);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse if (!that.getMainServer().getSupportManager()._supportMethods[supportMethod].check._schema) {\n\t\t\t\tconsole.error('No Check Schema For Method ' + supportMethod);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tlet promise = that.getMainServer().getSupportManager()._supportMethods[supportMethod].function.call(Object.assign({}, that, SupportManager.prototype), ...methodData);\n\n\t\tif (methodData[methodData.length - 1] && typeof(methodData[methodData.length - 1]) === 'function') {\n\t\t\tpromise.then(res => methodData[methodData.length - 1](null, res), err => methodData[methodData.length - 1](err, null));\n\t\t}\n\n\t\treturn promise;\n\t}\n\n\tprivate sendWS(ws: WebSocket, messageDate: Date, method: string, methodData: any[], data: ServerResponseModel) {\n\t\tthis._sendQueue.splice(0, 0, {\n\t\t\tid_ws: ws['id_socket'],\n\t\t\tmethod: method,\n\t\t\tmethodData: methodData,\n\t\t\tdata: data,\n\t\t\tdate: messageDate\n\t\t});\n\t}\n\n\tpublic sendEmail(sendTo: string, subject: string, text?: string, html?: string, attachments?: any[], send_from?: string) {\n\t\tthis._mailer.sendMail({\n\t\t\treplyTo: undefined,\n\t\t\tfrom: send_from ? send_from : this.serverConfig.MAIL_FROM,\n\t\t\tto: sendTo,\n\t\t\tsubject: (this.serverConfig['ROOT_URL'].includes('dev.') ? '(DEV SERVER) - ' : '') + subject,\n\t\t\ttext: text,\n\t\t\thtml: html,\n\t\t\tattachments: attachments\n\t\t}, (err, info) => {\n\t\t\tif (err) {\n\t\t\t\tconsole.log(err);\n\t\t\t}\n\t\t});\n\t}\n\n\tpublic getAWS() {\n\t\treturn this._aws;\n\t}\n\n\tpublic readFile(fileName) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tif (fs.existsSync(path.join(__dirname, ('../private/' + fileName)))) {\n\t\t\t\tfs.readFile(path.join(__dirname, ('../private/' + fileName)), 'utf-8', (err, res) => { \n\t\t\t\t\tif (err) {\n\t\t\t\t\t\treject(err);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tresolve(res);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (fs.existsSync(path.join(this.clientDir, ('./private/' + fileName)))) {\n\t\t\t\t\tfs.readFile(path.join(this.clientDir, ('./private/' + fileName)), 'utf-8', (err, res) => { \n\t\t\t\t\t\tif (err) {\n\t\t\t\t\t\t\treject(err);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tresolve(res);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tpublic readImage(fileName) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tif (fs.existsSync(path.join(__dirname, ('../private/' + fileName)))) {\n\t\t\t\tfs.readFile(path.join(__dirname, ('../private/' + fileName)), 'base64', (err, res) => { \n\t\t\t\t\tif (err) {\n\t\t\t\t\t\treject(err);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tresolve(res);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (fs.existsSync(path.join(this.clientDir, ('./private/' + fileName)))) {\n\t\t\t\t\tfs.readFile(path.join(this.clientDir, ('./private/' + fileName)), 'base64', (err, res) => { \n\t\t\t\t\t\tif (err) {\n\t\t\t\t\t\t\treject(err);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tresolve(res);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n}"]}
|
|
@@ -645,9 +645,14 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
645
645
|
docs = _a.sent();
|
|
646
646
|
needIds_1[collection].forEach(function (id_doc) {
|
|
647
647
|
if (uniqueOplog_1.filter(function (a) { return a.doc && a.doc._id === id_doc; })[0]) {
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
648
|
+
if (docs.filter(function (a) { return a._id === id_doc; })[0]) {
|
|
649
|
+
uniqueOplog_1.filter(function (a) { return a.doc && a.doc._id === id_doc; }).forEach(function (op) {
|
|
650
|
+
op.doc = docs.filter(function (a) { return a._id === id_doc; })[0];
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
else {
|
|
654
|
+
uniqueOplog_1.splice(uniqueOplog_1.findIndex(function (a) { return a.doc && a.doc._id === id_doc; })[0], 1);
|
|
655
|
+
}
|
|
651
656
|
}
|
|
652
657
|
else {
|
|
653
658
|
_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));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/managers/subscription.manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,wCAA0C;AAC1C,6CAA2D;AAC3D,yDAAuE;AACvE,2DAAyE;AACzE,qCAAiC;AACjC,+CAA6D;AAC7D,2DAAyE;AACzE,gGAAoF;AACpF,wFAA0E;AAC1E,uDAAoE;AACpE,+CAA8D;AAC9D,6DAA2E;AAC3E,qEAAkF;AAClF,mEAAgF;AAEhF,kCAA2C;AAC3C,+DAA6E;AAC7E,yCAA0C;AAC1C,wGAAyF;AACzF,+BAAiC;AACjC,mFAA+F;AAC/F,iFAA6F;AAG7F,sCAAwC;AAExC;IAoBC,6BAAY,UAAU,EAAE,GAAqB,EAAE,YAAY;QAA3D,iBAqGC;QAtHO,kBAAa,GAAsB,EAAE,CAAC;QACtC,mBAAc,GAA8B,EAAE,CAAC;QAE/C,mBAAc,GAAwB,EAAE,CAAC;QAEzC,gBAAW,GAAG,EAAE,CAAC;QACjB,cAAS,GAAG,EAAE,CAAC;QAEf,aAAQ,GAAG,CAAC,CAAC;QACb,eAAU,GAAG,EAAE,CAAC;QAChB,kBAAa,GAAG,KAAK,CAAC;QAEtB,oBAAe,GAAG,KAAK,CAAC;QACxB,2BAAsB,GAAG,KAAK,CAAC;QAKtC,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAE9B,IAAI,CAAC,UAAU,GAAG,IAAI,SAAS,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EAAE,EAAE,SAAS,CAAC,CAAC;iCAC3B;4BACF,CAAC,CAAC,CAAC;wBACJ,CAAC,CAAC,CAAC;wBAEH,MAAM,CAAC,GAAG,CAAC,CAAC;oBACb,CAAC,CAAC,CAAC;iBACH;;;aACD,CAAC,CAAC;IACJ,CAAC;IAEO,oCAAM,GAAd,UAAe,EAAa,EAAE,IAAyB;QACtD,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE;YAC5B,KAAK,EAAE,EAAE,CAAC,WAAW,CAAC;YACtB,IAAI,EAAE,IAAI;SACV,CAAC,CAAC;IACJ,CAAC;IACF,0BAAC;AAAD,CAnnCA,AAmnCC,IAAA;AAnnCY,kDAAmB","file":"subscription.manager.js","sourcesContent":["import { ServerResponseModel } from '../models/server-response.model';\nimport { ActiveSubscriptionModel, SubscriptionModel } from '../models/subscription.model';\nimport * as WebSocket from 'ws';\nimport * as MongoOplog from 'mongo-oplog';\nimport { loadLogPublications } from '../publications/logs';\nimport { loadAppStatusPublications } from '../publications/app-status';\nimport { loadAppVersionPublications } from '../publications/app-version';\nimport { Types } from 'mongoose';\nimport { loadFilePublications } from '../publications/files';\nimport { loadSuperAdminPublications } from '../publications/super-admin';\nimport { ActiveSubscriptions } from '../collections/active-subscription.collection';\nimport { LoggedInUsers } from '../collections/logged-in-users.collection';\nimport { loadCronJobPublications } from '../publications/cron-jobs';\nimport { loadFlagsPublications } from '../publications/flags';\nimport { loadMethodCallsPublications } from '../publications/method-calls';\nimport { loadMethodResponsePublications } from '../publications/method-responses';\nimport { loadSupportTicketPublications } from '../publications/support-tickets';\nimport ResolveIOMainServer from '../server-app';\nimport { ResolveIOServer } from '../index';\nimport { loadNotificationPublications } from '../publications/notifications';\nimport { deepCopy } from '../util/common';\nimport { BillingLoggedInUsers } from '../collections/billing-logged-in-users.collection';\nimport * as moment from 'moment';\nimport { loadBillingLoggedInUsersPublications } from '../publications/billing-logged-in-users';\nimport { loadReportBuilderReportPublications } from '../publications/report-builder-reports';\nimport { LoggedInUserModel } from '../models/logged-in-users.model';\n\nimport * as NodeCache from 'node-cache';\n\nexport class SubscriptionManager {\n\n\tprivate _mainServer: ResolveIOMainServer;\n\tprivate _publications: SubscriptionModel = {};\n\tprivate _subscriptions: ActiveSubscriptionModel[] = [];\n\tprivate _wss: WebSocket.Server;\n\tprivate _loggedInUsers: LoggedInUserModel[] = [];\n\t\n\tprivate _oplogQueue = [];\n\tprivate _subCache = [];\n\tprivate _nodeCache;\n\tprivate _cacheId = 0;\n\tprivate _sendQueue = [];\n\tprivate _runningQueue = false;\n\n\tprivate _initOplogStart = false;\n\tprivate _initOplogSupportStart = false;\n\n\tprivate serverConfig;\n\n\tconstructor(mainServer, wss: WebSocket.Server, serverConfig) {\n\t\tthis._mainServer = mainServer;\n\n\t\tthis._nodeCache = new NodeCache( { stdTTL: 0, checkperiod: 0 } );\n\n\t\tthis.serverConfig = serverConfig;\n\t\tthis._wss = wss;\n\n\t\t// Publications\n\t\tloadSuperAdminPublications(this);\n\t\tloadAppVersionPublications(this);\n\t\tloadAppStatusPublications(this);\n\t\tloadLogPublications(this);\n\t\tloadFilePublications(this);\n\t\tloadCronJobPublications(this);\n\t\tloadFlagsPublications(this);\n\t\tloadMethodCallsPublications(this);\n\t\tloadMethodResponsePublications(this);\n\t\tloadBillingLoggedInUsersPublications(this);\n\t\tloadNotificationPublications(this);\n\t\tloadReportBuilderReportPublications(this);\n\n\t\tthis.tailOpLog();\n\t\tthis.runOpLogQueue();\n\n\t\tif (ResolveIOServer.getSupportDB()) {\n\t\t\tloadSupportTicketPublications(this);\n\t\t\t\n\t\t\tthis.tailOpLogSupport();\n\t\t}\n\n\t\tsetInterval(() => {\n\t\t\tconsole.log(new Date());\n\t\t\tconsole.log('Sub Cache Length: ' + this._subCache.length);\n\t\t\tconsole.log('Sub Length: ' + this._subscriptions.length);\n\t\t\tconsole.log(this._nodeCache.getStats().vsize);\n\t\t}, 43200000);\n\n\t\tsetInterval(() => {\n\t\t\tif (!this._runningQueue) {\n\t\t\t\tif (this._sendQueue.length) {\n\t\t\t\t\tthis._runningQueue = true;\n\t\t\t\t\tfor (let i = this._sendQueue.length - 1; i >= 0; i--) {\n\t\t\t\t\t\tlet ws = this._mainServer.getWS(this._sendQueue[i].id_ws);\n\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\tif (ws.bufferedAmount < 20480) {\n\t\t\t\t\t\t\t\tlet sendItem = this._sendQueue.pop();\n\t\t\t\t\t\t\t\tws.send(JSON.stringify(sendItem.data), (error) => {\n\t\t\t\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\t\t\t\tconsole.log('Error on WS: ', error);\n\t\t\t\t\t\t\t\t\t\tthis.unsubscribeAll(ws);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tthis._sendQueue.splice(i, 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tthis._runningQueue = false;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}, 25);\n\n\t\tLoggedInUsers.find().then(loggedInUsers => {\n\t\t\tthis._loggedInUsers = loggedInUsers;\n\t\t}, err => {\n\t\t\tconsole.log(err);\n\t\t});\n\n\t\tsetInterval(async () => {\n\t\t\tlet userCopy = deepCopy(this._loggedInUsers);\n\t\t\tfor (let i = this._loggedInUsers.length - 1; i >= 0; i--) {\n\t\t\t\tlet loggedInUser = userCopy[i];\n\n\t\t\t\tif (!loggedInUser.date || moment().diff(moment(loggedInUser.date), 'seconds') >= 60) {\n\t\t\t\t\tif (this._mainServer.getWS(loggedInUser.id_ws)) {\n\t\t\t\t\t\tthis.unsubscribeAll(this._mainServer.getWS(loggedInUser.id_ws));\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tthis._subscriptions.forEach(sub => {\n\t\t\t\t\t\t\tfor (let j = sub.clients.length - 1; j >= 0; j--) {\n\t\t\t\t\t\t\t\tlet client = sub.clients[j];\n\n\t\t\t\t\t\t\t\tif (client.id_socket === loggedInUser.id_ws) {\n\t\t\t\t\t\t\t\t\tsub.clients.splice(j, 1);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (await LoggedInUsers.findById(loggedInUser._id)) {\n\t\t\t\t\t\t\tawait LoggedInUsers.deleteOne({_id: loggedInUser._id}).exec();\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tthis._loggedInUsers.splice(i, 1);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}, 60000);\n\t}\n\n\t// Add all files to publications private object\n\tpublic publications(method: SubscriptionModel) {\n\t\tthis._publications = Object.assign(this._publications, method);\n\t}\n\n\tpublic async loggedInLatency(ws: WebSocket) {\n\t\tlet date = new Date();\n\n\t\tlet loggedInUser = this._loggedInUsers.filter(a => a.id_ws === ws['id_socket'])[0];\n\n\t\tif (loggedInUser) {\n\t\t\tloggedInUser.date = date;\n\t\t}\n\n\t\tLoggedInUsers.findOneAndUpdate({id_ws: ws['id_socket']}, {$set: {latency: ws['latency'], date: date}}).exec((err, res) => {\n\t\t\tif (err) {\n\t\t\t\tthis.unsubscribeAll(ws);\n\t\t\t}\n\t\t});\n\t}\n\n\t// Subscribe to publication\n\tpublic async subscribe(messageDate: Date, ws: WebSocket, messageId: number, publication: string, ...subscriptionData: any[]) {\n\t\tlet that = this;\n\n\t\tlet pub = that._publications[publication];\n\n\t\tif (!pub) {\n\t\t\tconsole.error('No Publication: ' + publication);\n\t\t\treturn;\n\t\t}\n\t\telse {\n\t\t\tif (subscriptionData.length > 1 || subscriptionData[0]) {\n\t\t\t\tif (!pub.check) {\n\t\t\t\t\tconsole.error('No Check Function For Pub ' + publication);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\telse if (!pub.check._schema) {\n\t\t\t\t\tconsole.error('No Check Schema For Pub ' + publication);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet valObj = {};\n\t\t\t\t\tlet valKeys = Object.keys(pub.check._schema);\n\n\t\t\t\t\tlet rootKeys = valKeys.filter(a => !a.includes('.'));\n\t\t\t\t\t\n\t\t\t\t\tfor (let i = 0; i < subscriptionData.length; i++) {\n\t\t\t\t\t\tvalObj[rootKeys[i]] = subscriptionData[i];\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tpub.check.validate(valObj);\n\t\t\t\t\t}\n\t\t\t\t\tcatch (errors) {\n\t\t\t\t\t\tif (errors) {\n\t\t\t\t\t\t\tconsole.error('Error in Pub Check (' + publication + ')', errors);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet sub = that._subscriptions.filter(a => a.publication === publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscriptionData))[0];\n\n\t\t\t// If sub found (another user watching same data), add client to same sub\n\t\t\tif (sub) {\n\t\t\t\tsub.clients.push({\n\t\t\t\t\tid_user: ws['id_user'],\n\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\tid_socket: ws['id_socket']\n\t\t\t\t});\n\t\t\t}\n\t\t\t// If sub not found, create new sub\n\t\t\telse {\n\t\t\t\tthat._subscriptions.push({\n\t\t\t\t\tpublication: publication,\n\t\t\t\t\tsubscriptionData: subscriptionData,\n\t\t\t\t\tcollections: that.getPublicationCollections(publication),\n\t\t\t\t\tclients: [{\n\t\t\t\t\t\tid_user: ws['id_user'],\n\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\tid_socket: ws['id_socket']\n\t\t\t\t\t}]\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (!sub) {\n\t\t\t\tsub = that._subscriptions.filter(a => a.publication === publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscriptionData))[0];\n\t\t\t}\n\n\t\t\t// console.log('Subscribe', new Date(), 'Success', sub);\n\n\t\t\t// Send pub data to client who just subscribed only, don't want to send to existing clients since nothing has changed\n\t\t\tthat.sendPubDataOnce(ws, messageId, sub, 'newSub', that.getPublicationCollections(publication)[0]);\n\n\t\t\tif (that._publications[sub.publication].preFunction && !sub.preSubscriptionData) {\n\t\t\t\tsub.preSubscriptionData = await that._publications[sub.publication].preFunction(...sub.subscriptionData);\n\t\t\t}\n\n\t\t\tlet newActiveSub = new ActiveSubscriptions({\n\t\t\t\tdate: new Date(),\n\t\t\t\tpublication: publication,\n\t\t\t\tsubData: JSON.stringify(subscriptionData),\n\t\t\t\tcollections: pub.collections,\n\t\t\t\tclients: sub.clients\n\t\t\t});\n\n\t\t\tActiveSubscriptions.findOneAndUpdate({\n\t\t\t\t$and: [\n\t\t\t\t\t{publication: publication},\n\t\t\t\t\t{subData: JSON.stringify(subscriptionData)}\n\t\t\t\t]\n\t\t\t}, {$setOnInsert: {_id: Types.ObjectId().toHexString(), __v: 0}, $set: newActiveSub}, {upsert: true}).exec();\n\t\t}\n\n\t\tif (publication === 'appversion') {\n\t\t\tlet newLoggedInUser = {\n\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t__v: 0,\n\t\t\t\tdate: new Date(),\n\t\t\t\tid_user: ws['id_user'],\n\t\t\t\tuser: ws['user'],\n\t\t\t\tid_ws: ws['id_socket']\n\t\t\t};\n\n\t\t\tthis._loggedInUsers.push(newLoggedInUser);\n\n\t\t\tLoggedInUsers.create(newLoggedInUser);\n\n\t\t\tif (ws['user'] !== 'Admin' && ResolveIOServer.getSupportDB()) {\n\t\t\t\tlet begDate = moment().startOf('month');\n\t\t\t\tlet endDate = moment().endOf('month');\n\n\t\t\t\tlet billUser = await BillingLoggedInUsers.findOne({\n\t\t\t\t\t$and: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tclient: ResolveIOServer.getClientName()\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid_user: ws['id_user']\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdate: {$gte: begDate}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdate: {$lte: endDate}\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t});\n\n\t\t\t\tif (!billUser) {\n\t\t\t\t\tBillingLoggedInUsers.create({\n\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\tid_user: ws['id_user'],\n\t\t\t\t\t\tuser: ws['user'],\n\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\tclient: ResolveIOServer.getClientName()\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Unsubscribe from publication \n\tpublic async unsubscribe(messageDate: Date, ws: WebSocket, messageId: number, publication: string, ...subscriptionData: any[]) {\n\t\tlet that = this;\n\n\t\t// console.log('Before');\n\t\t// console.dir(this._subscriptions.map(a => a.publication));\n\n\t\tif (!that._publications[publication]) {\n\t\t\tconsole.log('No Publication: ' + publication);\n\t\t\treturn;\n\t\t}\n\t\telse {\n\t\t\tlet sub = that._subscriptions.filter(a => a.publication === publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscriptionData))[0];\n\n\t\t\tif (sub) {\n\t\t\t\tfor (let i = sub.clients.length - 1; i >= 0; i--) {\n\t\t\t\t\tif (sub.clients[i].id_user === ws['id_user'] && sub.clients[i].messageId === messageId && sub.clients[i].id_socket === ws['id_socket']) {\n\t\t\t\t\t\tsub.clients.splice(i, 1);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlet activeSub = await ActiveSubscriptions.findOne({\n\t\t\t\t\t$and: [\n\t\t\t\t\t\t{publication: publication},\n\t\t\t\t\t\t{subData: JSON.stringify(subscriptionData)}\n\t\t\t\t\t]\n\t\t\t\t});\n\t\n\t\t\t\tif (activeSub) {\n\t\t\t\t\tActiveSubscriptions.updateOne({_id: activeSub._id}, {$set: {clients: sub.clients}}).exec();\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tconsole.log(ws['user'] + ' - Did not find sub on unsubscribe - publication: ' + publication + ', subData: ' + JSON.stringify(subscriptionData, null, 2));\n\t\t\t}\n\t\t}\n\t}\n\n\t// Unsubscribe from publication\n\tpublic async unsubscribeAll(ws: WebSocket) {\n\t\tlet that = this;\n\n\t\t// console.log('Before');\n\t\t// console.dir(this._subscriptions.map(a => a.publication));\n\n\t\tlet loggedInUser = await LoggedInUsers.findOne({id_ws: ws['id_socket']});\n\n\t\tif (loggedInUser) {\t\n\t\t\tif (this._loggedInUsers.map(a => a._id).indexOf(loggedInUser._id) >= 0) {\n\t\t\t\tthis._loggedInUsers.splice(this._loggedInUsers.map(a => a._id).indexOf(loggedInUser._id), 1);\n\t\t\t}\n\t\t\t\n\t\t\tLoggedInUsers.deleteOne({_id: loggedInUser._id}).exec();\n\t\t}\n\n\t\tlet userSubs = that._subscriptions.filter(a => a.clients.some(b => b.id_user === ws['id_user'] && b.id_socket === ws['id_socket']));\n\n\t\tfor (let i = userSubs.length - 1; i >= 0; i--) {\n\t\t\tlet sub = userSubs[i];\n\n\t\t\tfor (let j = sub.clients.length - 1; j >= 0; j--) {\n\t\t\t\tif (sub.clients[j].id_socket === ws['id_socket']) {\n\t\t\t\t\tsub.clients.splice(j, 1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tlet activeSubs = await ActiveSubscriptions.find({'clients.id_socket': ws['id_socket']});\n\n\t\tactiveSubs.forEach(sub => {\n\t\t\tfor (let j = sub.clients.length - 1; j >= 0; j--) {\n\t\t\t\tif (sub.clients[j].id_socket === ws['id_socket']) {\n\t\t\t\t\tsub.clients.splice(j, 1);\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tfor (let j = sub.clients.length - 1; j >= 0; j--) {\n\t\t\t\tif (sub.clients[j].id_socket === ws['id_socket']) {\n\t\t\t\t\tsub.clients.splice(j, 1);\n\t\t\t\t}\n\t\t\t}\n\t\t\tActiveSubscriptions.updateOne({_id: sub._id}, {$set: {clients: sub.clients}}).exec();\n\t\t});\n\n\t\tws.terminate();\n\n\t\t// console.log('After');\n\t\t// console.dir(this._subscriptions.map(a => a.publication));\n\t}\n\n\t// Get publication collection\n\tprivate getPublicationCollections(publication: string) {\n\t\treturn this._publications[publication].collections;\n\t}\n\n\t// Watch (tail) Mongo's operation log on the entire database (all insert/modify/delete will trigger this function)\n\tprivate tailOpLog() {\n\t\tlet that = this;\n\n\t\tconst oplog = MongoOplog(that.serverConfig['OPLOG_URL']);\n\t\toplog.tail().then(() => {\n\t\t\tconsole.log('tail started');\n\t\t\tthis._initOplogStart = true;\n\t\t}, err => {\n\t\t\tconsole.log(err);\n\t\t});\n\t\t\n\t\toplog.on('insert', doc => {\t\t\t\n\t\t\tlet nsArray = doc.ns.split('.');\n\t\t\tlet collection = nsArray[1];\n\n\t\t\tif (nsArray[2]) {\n\t\t\t\tcollection += '.' + nsArray[2];\n\t\t\t}\n\n\t\t\tif (collection === 'cron-jobs') {\n\t\t\t\tthis._mainServer.getCronManager().checkCronJobsForUpdates();\n\t\t\t}\n\t\t\telse if (collection === 'queue-methods') {\n\t\t\t\tthis._mainServer.getQueueManager().runMethodQueue();\n\t\t\t}\n\t\t\telse if (collection === 'queue-responses') {\n\t\t\t\tthis._mainServer.getQueueManager().runMethodResponse();\n\t\t\t}\n\t\t\telse if (collection === 'support-tickets' && this.serverConfig['ROOT_URL'] !== 'http://localhost:4200') {\n\t\t\t\tthis._mainServer.getMethodManager().callMethodInternal('sendSupportTicketEmail', doc.o._id);\n\t\t\t}\n\t\t\t\n\t\t\tif (!collection.endsWith('.versions') && !collection.startsWith('system.')) {\n\t\t\t\tthis._oplogQueue.push({\n\t\t\t\t\ttype: 'insert',\n\t\t\t\t\tcollection: collection,\n\t\t\t\t\tdoc: doc.o\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t\t\n\t\toplog.on('update', doc => {\t\t\t\n\t\t\tlet nsArray = doc.ns.split('.');\n\t\t\tlet collection = nsArray[1];\n\n\t\t\tif (nsArray[2]) {\n\t\t\t\tcollection += '.' + nsArray[2];\n\t\t\t}\n\n\t\t\tdoc.o['_id'] = doc.o2['_id'];\n\n\t\t\tif (collection === 'cron-jobs') {\n\t\t\t\tthis._mainServer.getCronManager().checkCronJobsForUpdates();\n\t\t\t}\n\n\t\t\tif (!collection.endsWith('.versions') && !collection.startsWith('system.')) {\n\t\t\t\tthis._oplogQueue.push({\n\t\t\t\t\ttype: 'update',\n\t\t\t\t\tcollection: collection,\n\t\t\t\t\tdoc: doc.o\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t\t\n\t\toplog.on('delete', doc => {\n\t\t\tlet nsArray = doc.ns.split('.');\n\t\t\tlet collection = nsArray[1];\n\n\t\t\tif (nsArray[2]) {\n\t\t\t\tcollection += '.' + nsArray[2];\n\t\t\t}\n\n\t\t\tthat.resendPubsForDelete(collection);\n\n\t\t\tif (collection === 'cron-jobs') {\n\t\t\t\tthis._mainServer.getCronManager().checkCronJobsForUpdates();\n\t\t\t}\n\t\t});\n\t\t\n\t\toplog.on('error', error => {\n\t\t\tconsole.log('oplog error', error);\n\n\t\t\tif (this._initOplogStart) {\n\t\t\t\tprocess.exit();\n\t\t\t}\n\t\t});\n\t\t\n\t\toplog.on('end', () => {\n\t\t\tconsole.log('oplog ended');\n\n\t\t\tif (this._initOplogStart) {\n\t\t\t\tprocess.exit();\n\t\t\t}\n\t\t});\n\n\t\toplog.stop(() => {\n\t\t\tconsole.log('oplog stopped');\n\t\t\t\n\t\t\tif (this._initOplogStart) {\n\t\t\t\tprocess.exit();\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate tailOpLogSupport() {\n\t\tlet that = this;\n\n\t\tconst oplog = MongoOplog(that.serverConfig['RESOLVEIO_SUPPORT_OPLOG_URL']);\n\t\toplog.tail().then(() => {\n\t\t\tconsole.log('tail started support');\n\n\t\t\tthis._initOplogSupportStart = true;\n\t\t}, err => {\n\t\t\tconsole.log(err);\n\t\t});\n\t\t\n\t\toplog.on('insert', doc => {\t\t\t\n\t\t\tlet nsArray = doc.ns.split('.');\n\t\t\tlet collection = nsArray[1];\n\n\t\t\tif (nsArray[2]) {\n\t\t\t\tcollection += '.' + nsArray[2];\n\t\t\t}\n\n\t\t\tif (collection === 'support-tickets') {\n\t\t\t\tthat.checkSupportPubsForChanges(collection, doc.o);\n\t\t\t}\n\t\t});\n\t\t\n\t\toplog.on('update', doc => {\t\t\t\n\t\t\tlet nsArray = doc.ns.split('.');\n\t\t\tlet collection = nsArray[1];\n\n\t\t\tif (nsArray[2]) {\n\t\t\t\tcollection += '.' + nsArray[2];\n\t\t\t}\n\n\t\t\tdoc.o['_id'] = doc.o2['_id'];\n\n\t\t\tif (collection === 'support-tickets') {\n\t\t\t\tthat.checkSupportPubsForChanges(collection, doc.o);\n\t\t\t}\n\t\t});\n\t\t\n\t\toplog.on('delete', doc => {\n\t\t\tlet nsArray = doc.ns.split('.');\n\t\t\tlet collection = nsArray[1];\n\n\t\t\tif (nsArray[2]) {\n\t\t\t\tcollection += '.' + nsArray[2];\n\t\t\t}\n\n\t\t\tif (collection === 'support-tickets') {\n\t\t\t\tthat.resendPubsForDelete(collection);\n\t\t\t}\n\t\t});\n\t\t\n\t\toplog.on('error', error => {\n\t\t\tconsole.log('oplog error support', error);\n\n\t\t\tif (this._initOplogSupportStart) {\n\t\t\t\tprocess.exit();\n\t\t\t}\n\t\t});\n\t\t\n\t\toplog.on('end', () => {\n\t\t\tconsole.log('oplog ended support');\n\n\t\t\tif (this._initOplogSupportStart) {\n\t\t\t\tprocess.exit();\n\t\t\t}\n\t\t});\n\n\t\toplog.stop(() => {\n\t\t\tconsole.log('oplog stopped support');\n\n\t\t\tif (this._initOplogSupportStart) {\n\t\t\t\tprocess.exit();\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate runOpLogQueue() {\n\t\tlet that = this;\n\t\tsetInterval(async () => {\n\t\t\tif (this._oplogQueue.length) {\n\t\t\t\tlet uniqueOplog = deepCopy(this._oplogQueue);\n\t\t\t\tthis._oplogQueue = [];\n\n\t\t\t\tlet uniquePubs = [];\n\n\t\t\t\tlet needIds = {};\n\n\t\t\t\tfor (let i = uniqueOplog.length - 1; i >= 0; i--) {\n\t\t\t\t\tif (!that._subscriptions.some(a => a.collections.includes(uniqueOplog[i].collection))) {\n\t\t\t\t\t\tuniqueOplog.splice(i, 1);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tuniqueOplog.forEach(oplog => {\n\t\t\t\t\tlet schemaErrors = null;\n\t\n\t\t\t\t\ttry {\n\t\t\t\t\t\tResolveIOServer.getMainDB().model(oplog.collection)['simplschema'].validate(oplog.doc);\n\t\t\t\t\t}\n\t\t\t\t\tcatch (errors) {\n\t\t\t\t\t\tschemaErrors = errors;\n\t\t\t\t\t}\n\t\t\n\t\t\t\t\tif (schemaErrors) {\n\t\t\t\t\t\tif (!needIds[oplog.collection]) {\n\t\t\t\t\t\t\tneedIds[oplog.collection] = [oplog.doc['_id']];\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tif (!needIds[oplog.collection].filter(a => a === oplog.doc['_id'])[0]) {\n\t\t\t\t\t\t\t\tneedIds[oplog.collection].push(oplog.doc['_id']);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\tfor (let i = 0; i < Object.keys(needIds).length; i++) {\n\t\t\t\t\tlet collection = Object.keys(needIds)[i];\n\t\t\t\t\tlet docs = await ResolveIOServer.getMainDB().model(collection).find({_id: {$in: needIds[collection]}});\n\n\t\t\t\t\tneedIds[collection].forEach(id_doc => {\n\t\t\t\t\t\tif (uniqueOplog.filter(a => a.doc && a.doc._id === id_doc)[0]) {\n\t\t\t\t\t\t\tuniqueOplog.filter(a => a.doc && a.doc._id === id_doc).forEach(op => {\n\t\t\t\t\t\t\t\top.doc = docs.filter(a => a._id === id_doc)[0];\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tthis._mainServer.getMethodManager().sendEmail('dev@resolveio.com', 'SERVER - Oplog Doc Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'id_doc: ' + id_doc + ', UniqueOplogs: ' + JSON.stringify(uniqueOplog, null, 2));\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tfor (let i = uniqueOplog.length - 1; i >= 0; i--) {\n\t\t\t\t\tlet oplog = uniqueOplog[i];\n\n\t\t\t\t\tfor (let j = that._subscriptions.length - 1; j >= 0; j--) {\n\t\t\t\t\t\tlet sub = that._subscriptions[j];\n\n\t\t\t\t\t\tif (sub.collections.includes(oplog.collection)) {\n\t\t\t\t\t\t\tif (sub.preSubscriptionData) {\n\t\t\t\t\t\t\t\tif (that._publications[sub.publication].fetchFunction(oplog.doc, sub.preSubscriptionData)) {\n\t\t\t\t\t\t\t\t\tif (!uniquePubs.filter(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData) && JSON.stringify(oplog) === JSON.stringify(a.oplog)).length) {\n\t\t\t\t\t\t\t\t\t\tif (!sub.clients.length) {\n\t\t\t\t\t\t\t\t\t\t\tthat._subscriptions.splice(j, 1);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\tawait ActiveSubscriptions.deleteOne({\n\t\t\t\t\t\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t{publication: sub.publication},\n\t\t\t\t\t\t\t\t\t\t\t\t\t{subData: JSON.stringify(sub.subscriptionData)}\n\t\t\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t\t}).exec();\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\t\t\tsub['oplog'] = oplog;\n\t\t\t\t\t\t\t\t\t\t\tuniquePubs.push(deepCopy(sub));\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\tif (this._subCache.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)) >= 0) {\n\t\t\t\t\t\t\t\t\t\t\tthis._nodeCache.del(this._subCache.filter(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData))[0].id);\n\t\t\t\t\t\t\t\t\t\t\tthis._subCache.splice(this._subCache.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)), 1);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (that._publications[sub.publication].preFunction) {\n\t\t\t\t\t\t\t\tif (!sub.clients.length) {\n\t\t\t\t\t\t\t\t\tthat._subscriptions.splice(j, 1);\n\t\t\t\t\n\t\t\t\t\t\t\t\t\tawait ActiveSubscriptions.deleteOne({\n\t\t\t\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t\t\t\t{publication: sub.publication},\n\t\t\t\t\t\t\t\t\t\t\t{subData: JSON.stringify(sub.subscriptionData)}\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t}).exec();\n\n\t\t\t\t\t\t\t\t\tif (this._subCache.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)) >= 0) {\n\t\t\t\t\t\t\t\t\t\tthis._nodeCache.del(this._subCache.filter(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData))[0].id);\n\t\t\t\t\t\t\t\t\t\tthis._subCache.splice(this._subCache.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)), 1);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tif (!uniquePubs.filter(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData) && JSON.stringify(oplog) === JSON.stringify(a.oplog)).length) {\n\t\t\t\t\t\t\t\t\t\tsub['oplog'] = oplog;\n\t\t\t\t\t\t\t\t\t\tuniquePubs.push(deepCopy(sub));\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tif (that._publications[sub.publication].fetchFunction) {\n\t\t\t\t\t\t\t\t\tif (that._publications[sub.publication].fetchFunction(oplog.doc, ...sub.subscriptionData)) {\n\t\t\t\t\t\t\t\t\t\tif (!uniquePubs.filter(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)).length) {\n\t\t\t\t\t\t\t\t\t\t\tif (!sub.clients.length) {\n\t\t\t\t\t\t\t\t\t\t\t\tthat._subscriptions.splice(j, 1);\n\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\tawait ActiveSubscriptions.deleteOne({\n\t\t\t\t\t\t\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{publication: sub.publication},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{subData: JSON.stringify(sub.subscriptionData)}\n\t\t\t\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t\t\t}).exec();\n\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\tif (this._subCache.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)) >= 0) {\n\t\t\t\t\t\t\t\t\t\t\t\t\tthis._nodeCache.del(this._subCache.filter(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData))[0].id);\n\t\t\t\t\t\t\t\t\t\t\t\t\tthis._subCache.splice(this._subCache.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)), 1);\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\t\t\t\tsub['oplog'] = oplog;\n\t\t\t\t\t\t\t\t\t\t\t\tuniquePubs.push(deepCopy(sub));\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tif (!uniquePubs.filter(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)).length) {\n\t\t\t\t\t\t\t\t\t\tif (!sub.clients.length) {\n\t\t\t\t\t\t\t\t\t\t\tthat._subscriptions.splice(j, 1);\n\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\tawait ActiveSubscriptions.deleteOne({\n\t\t\t\t\t\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t{publication: sub.publication},\n\t\t\t\t\t\t\t\t\t\t\t\t\t{subData: JSON.stringify(sub.subscriptionData)}\n\t\t\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t\t}).exec();\n\n\t\t\t\t\t\t\t\t\t\t\tif (this._subCache.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)) >= 0) {\n\t\t\t\t\t\t\t\t\t\t\t\tthis._nodeCache.del(this._subCache.filter(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData))[0].id);\n\t\t\t\t\t\t\t\t\t\t\t\tthis._subCache.splice(this._subCache.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)), 1);\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\t\t\tsub['oplog'] = oplog;\n\t\t\t\t\t\t\t\t\t\t\tuniquePubs.push(deepCopy(sub));\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor (let i = 0; i < uniquePubs.length; i++) {\n\t\t\t\t\tlet pub = uniquePubs[i];\n\t\t\t\t\tawait this.checkPubsForChanges(pub['oplog'].collection, pub['oplog'].doc, pub['oplog'].type, pub);\n\t\t\t\t}\n\t\t\t}\n\t\t}, 500);\n\t}\n\n\tprivate async resendPubsForDelete(collection: string) {\n\t\tlet that = this;\n\n\t\tlet subCopy = deepCopy(that._subscriptions.filter(a => a.collections.includes(collection)));\n\n\t\tfor (let jj = this._subCache.length - 1; jj >= 0; jj--) {\n\t\t\tif (this._subCache[jj].collection === collection || subCopy.some(a => a.publication === this._subCache[jj].publication)) {\n\t\t\t\tthis._nodeCache.del(this._subCache[jj].id);\n\n\t\t\t\tthis._subCache.splice(jj, 1);\n\t\t\t}\n\t\t}\n\n\t\tfor (let zz = subCopy.length - 1; zz >= 0; zz--) {\n\t\t\tlet sub = subCopy[zz];\n\n\t\t\tif (that._publications[sub.publication].ws_specific) {\n\t\t\t\tfor (let aa = 0; aa < sub.clients.length; aa++) {\n\t\t\t\t\tlet client = sub.clients[aa];\n\t\t\t\t\tfor (let bb = 0; bb < that._wss.clients.size; bb++) {\n\t\t\t\t\t\tlet ws = Array.from(that._wss.clients)[bb];\n\t\t\t\t\t\tif (ws['id_socket'] === client.id_socket) {\n\t\t\t\t\t\t\tawait that.sendPubDataOnce(ws, client.messageId, sub, 'delete', collection);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (!sub.clients.length) {\n\t\t\t\t\tif (that._subscriptions.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)) >= 0) {\n\t\t\t\t\t\tthat._subscriptions.splice(that._subscriptions.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)), 1);\n\t\t\t\t\t}\n\n\t\t\t\t\tawait ActiveSubscriptions.deleteOne({\n\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t{publication: sub.publication},\n\t\t\t\t\t\t\t{subData: JSON.stringify(sub.subscriptionData)}\n\t\t\t\t\t\t]\n\t\t\t\t\t}).exec();\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tawait that.sendPubData(sub, 'delete', collection);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Document: Inserted/Modified Document\n\t// Collection: Collection Document Lives In\n\t// Check to see if any pubs need to refetch due to Mongo operation\n\tprivate async checkPubsForChanges(collection: string, document: Object, type: string, sub: ActiveSubscriptionModel) {\n\t\tlet that = this;\n\n\t\tif (sub.preSubscriptionData) {\n\t\t\tif (that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) {\n\t\t\t\tif (this._subCache.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)) >= 0) {\n\t\t\t\t\tthis._nodeCache.del(this._subCache.filter(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData))[0].id);\n\t\t\t\t\tthis._subCache.splice(this._subCache.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)), 1);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tawait that.sendPubData(sub, type, collection);\n\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t\n\t\tif (that._publications[sub.publication].preFunction) {\n\t\t\tsub.preSubscriptionData = await that._publications[sub.publication].preFunction(sub.subscriptionData);\n\t\t\tif (that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) {\n\t\t\t\tif (this._subCache.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)) >= 0) {\n\t\t\t\t\tthis._nodeCache.del(this._subCache.filter(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData))[0].id);\n\t\t\t\t\tthis._subCache.splice(this._subCache.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)), 1);\n\t\t\t\t}\n\n\t\t\t\tawait that.sendPubData(sub, type, collection);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tif (that._publications[sub.publication].ws_specific) {\n\t\t\t\tif (this._subCache.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)) >= 0) {\n\t\t\t\t\tthis._nodeCache.del(this._subCache.filter(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData))[0].id);\n\t\t\t\t\tthis._subCache.splice(this._subCache.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)), 1);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tfor (let k = 0; k < sub.clients.length; k++) {\n\t\t\t\t\tlet client = sub.clients[k];\n\t\t\t\t\tif (that._publications[sub.publication].fetchFunction) {\n\t\t\t\t\t\tif (that._publications[sub.publication].fetchFunction(document, client.id_user, ...sub.subscriptionData)) {\n\t\t\t\t\t\t\tfor (let j = 0; j < that._wss.clients.size; j++) {\n\t\t\t\t\t\t\t\tlet ws = Array.from(that._wss.clients)[j];\n\t\t\t\t\t\t\t\tif (ws['id_socket'] === client.id_socket) {\n\t\t\t\t\t\t\t\t\tawait that.sendPubDataOnce(ws, client.messageId, sub, type, collection);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tfor (let j = 0; j < that._wss.clients.size; j++) {\n\t\t\t\t\t\t\tlet ws = Array.from(that._wss.clients)[j];\n\t\t\t\t\t\t\tif (ws['id_socket'] === client.id_socket) {\n\t\t\t\t\t\t\t\tawait that.sendPubDataOnce(ws, client.messageId, sub, type, collection);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (that._publications[sub.publication].fetchFunction) {\n\t\t\t\t\tif (that._publications[sub.publication].fetchFunction(document, ...sub.subscriptionData)) {\n\t\t\t\t\t\tif (this._subCache.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)) >= 0) {\n\t\t\t\t\t\t\tthis._nodeCache.del(this._subCache.filter(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData))[0].id);\n\t\t\t\t\t\t\tthis._subCache.splice(this._subCache.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)), 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tawait that.sendPubData(sub, type, collection);\n\t\t\t\t\t}\n\t\t\t\t\t// else\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tif (this._subCache.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)) >= 0) {\n\t\t\t\t\t\tthis._nodeCache.del(this._subCache.filter(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData))[0].id);\n\t\t\t\t\t\tthis._subCache.splice(this._subCache.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)), 1);\n\t\t\t\t\t}\n\n\t\t\t\t\tawait that.sendPubData(sub, type, collection);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate checkSupportPubsForChanges(collection: string, document: Object) {\n\t\tlet that = this;\n\n\t\tthat._subscriptions.filter(a => a.collections.includes(collection)).forEach(async sub => {\n\t\t\tlet schemaErrors = null;\n\n\t\t\ttry {\n\t\t\t\tResolveIOServer.getSupportDB().model(collection)['simplschema'].validate(document);\n\t\t\t}\n\t\t\tcatch (errors) {\n\t\t\t\tschemaErrors = errors;\n\t\t\t}\n\n\t\t\tif (schemaErrors) {\n\t\t\t\tdocument = await ResolveIOServer.getSupportDB().model(collection).findById(document['_id']);\n\t\t\t}\n\n\t\t\tif (sub.preSubscriptionData) {\n\t\t\t\tif (that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) {\n\t\t\t\t\tthat.sendPubData(sub, 'support', collection);\n\n\t\t\t\t\tsub.preSubscriptionData = await that._publications[sub.publication].preFunction(...sub.subscriptionData);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (that._publications[sub.publication].preFunction) {\n\t\t\t\tsub.preSubscriptionData = await that._publications[sub.publication].preFunction(...sub.subscriptionData);\n\t\t\t\tif (that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) {\n\t\t\t\t\tthat.sendPubData(sub, 'support', collection);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (that._publications[sub.publication].ws_specific) {\n\t\t\t\t\tsub.clients.forEach(client => {\n\t\t\t\t\t\tif (that._publications[sub.publication].fetchFunction) {\n\t\t\t\t\t\t\tif (that._publications[sub.publication].fetchFunction(document, client.id_user, ...sub.subscriptionData)) {\n\t\t\t\t\t\t\t\tthat._wss.clients.forEach(ws => {\n\t\t\t\t\t\t\t\t\tif (ws['id_socket'] === client.id_socket) {\n\t\t\t\t\t\t\t\t\t\tthat.sendPubDataOnce(ws, client.messageId, sub, 'support', collection);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tthat._wss.clients.forEach(ws => {\n\t\t\t\t\t\t\t\tif (ws['id_socket'] === client.id_socket) {\n\t\t\t\t\t\t\t\t\tthat.sendPubDataOnce(ws, client.messageId, sub, 'support', collection);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tif (that._publications[sub.publication].fetchFunction) {\n\t\t\t\t\t\tif (that._publications[sub.publication].fetchFunction(document, ...sub.subscriptionData)) {\n\t\t\t\t\t\t\tthat.sendPubData(sub, 'support', collection);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tthat.sendPubData(sub, 'support', collection);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\t// Fetch pub once, send to all clients linked to this pub\n\tprivate sendPubDataOnce(ws: WebSocket, messageId: number, subscription: ActiveSubscriptionModel, type: string, collection: string) {\n\t\treturn new Promise(async (resolve, reject) => {\n\t\t\tlet that = this;\n\n\t\t\tif (!that._publications[subscription.publication].ws_specific) { // Same pub for all users\n\t\t\t\tif (this._subCache.some(a => a.publication === subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscription.subscriptionData))) {\n\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\tdata: this._nodeCache.get(this._subCache.filter(a => a.publication === subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscription.subscriptionData))[0].id)\n\t\t\t\t\t};\n\n\t\t\t\t\tthis.sendWS(ws, serverRes);\n\n\t\t\t\t\tresolve(true);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tif (subscription.publication !== 'superadminAPM' && subscription.publication !== 'loggedInUsers') {\n\t\t\t\t\t\tthat._mainServer.getMethodManager().callMethodInternal('insertSubscriptionLog', type, subscription.publication, collection, JSON.stringify(subscription.subscriptionData));\n\t\t\t\t\t}\n\n\t\t\t\t\tthat._publications[subscription.publication].function.call(Object.assign({}, that, SubscriptionManager.prototype), ...subscription.subscriptionData).then(res => {\n\t\t\t\t\t\tlet nodeCacheSize = this._nodeCache.getStats().vsize;\n\n\t\t\t\t\t\tif (nodeCacheSize > 500000000) {\n\t\t\t\t\t\t\tlet neededSizeIndex = 0;\n\n\t\t\t\t\t\t\tfor (let zz = 0; zz < this._subCache.length; zz++) {\n\t\t\t\t\t\t\t\tthis._nodeCache.del(this._subCache[zz].id);\n\n\t\t\t\t\t\t\t\tif (this._nodeCache.getStats().vsize < 500000000) {\n\t\t\t\t\t\t\t\t\tneededSizeIndex = zz;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// console.log('Cache1: ' + 'Too Big - ' + subscription.publication + ' - ' + getBinarySize(JSON.stringify(this._subCache)));\n\t\t\t\t\t\t\tthis._subCache.splice(0, neededSizeIndex);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (this._subCache.some(a => a.collection === collection && a.publication === subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscription.subscriptionData))) {\n\t\t\t\t\t\t\tthis._subCache.splice(this._subCache.findIndex(a => a.collection === collection && a.publication === subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscription.subscriptionData)), 1);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet cacheId = this._cacheId++;\n\t\t\t\t\t\tthis._nodeCache.set(cacheId, res);\n\t\t\t\t\t\tthis._subCache.push({collection: collection, publication: subscription.publication, subscriptionData: subscription.subscriptionData, id: cacheId});\n\n\t\t\t\t\t\t// console.log('Cache1: ' + 'Create - ' + subscription.publication + ' - ' + getBinarySize(JSON.stringify(this._subCache)));\n\n\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\tdata: res\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tthis.sendWS(ws, serverRes);\n\n\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t}, err => {\n\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\thasError: true,\n\t\t\t\t\t\t\tdata: err\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tthis.sendWS(ws, serverRes);\n\n\t\t\t\t\t\treject(err);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\telse { // Pub is different for each user (Look at users publication) [MUCH SLOWER, RE-RUNS FOR EACH USER]\n\t\t\t\tthat._publications[subscription.publication].function.call(Object.assign({}, that, SubscriptionManager.prototype), ws['id_user'], ...subscription.subscriptionData).then(res => {\n\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\tdata: res\n\t\t\t\t\t};\n\n\t\t\t\t\t// console.log('Send Pub Data Once 2', new Date(), 'Success', subscription);\n\n\t\t\t\t\tthis.sendWS(ws, serverRes);\n\n\t\t\t\t\tresolve(true);\n\n\t\t\t\t}, err => {\n\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\thasError: true,\n\t\t\t\t\t\tdata: err\n\t\t\t\t\t};\n\n\t\t\t\t\t// console.log('Send Pub Data Once 2', new Date(), 'Error', subscription);\n\n\t\t\t\t\tthis.sendWS(ws, serverRes);\n\n\t\t\t\t\treject(err);\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n\n\t// Fetch pub once, send to all clients linked to this pub\n\tprivate sendPubData(subscription: ActiveSubscriptionModel, type: string, collection: string) {\n\t\treturn new Promise(async (resolve, reject) => {\n\t\t\tlet that = this;\n\n\t\t\tif (this._subCache.some(a => a.publication === subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscription.subscriptionData))) {\n\t\t\t\tsubscription.clients.forEach(client => {\n\t\t\t\t\tthat._wss.clients.forEach(ws => {\n\t\t\t\t\t\tif (ws['id_socket'] === client.id_socket) {\n\t\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\t\tmessageId: client.messageId,\n\t\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\t\tdata: this._nodeCache.get(this._subCache.filter(a => a.publication === subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscription.subscriptionData))[0].id)\n\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\t// console.log('Cache: ' + 'Found - ' + subscription.publication + ' - ' + getBinarySize(JSON.stringify(this._subCache)));\n\t\t\t\t\t\t\tthis.sendWS(ws, serverRes);\n\n\t\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (subscription.publication !== 'superadminAPM' && subscription.publication !== 'loggedInUsers') {\n\t\t\t\t\tthat._mainServer.getMethodManager().callMethodInternal('insertSubscriptionLog', type, subscription.publication, collection, JSON.stringify(subscription.subscriptionData));\n\t\t\t\t}\n\n\t\t\t\tthat._publications[subscription.publication].function.call(Object.assign({}, that, SubscriptionManager.prototype), ...subscription.subscriptionData).then(res => {\n\t\t\t\t\tlet nodeCacheSize = this._nodeCache.getStats().vsize;\n\t\t\t\t\t\n\t\t\t\t\tif (nodeCacheSize > 500000000) {\n\t\t\t\t\t\tlet neededSizeIndex = 0;\n\n\t\t\t\t\t\tfor (let zz = 0; zz < this._subCache.length; zz++) {\n\t\t\t\t\t\t\tthis._nodeCache.del(this._subCache[zz].id);\n\n\t\t\t\t\t\t\tif (this._nodeCache.getStats().vsize < 500000000) {\n\t\t\t\t\t\t\t\tneededSizeIndex = zz;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// console.log('Cache: ' + 'Too Big - ' + subscription.publication + ' - ' + getBinarySize(JSON.stringify(this._subCache)));\n\t\t\t\t\t\tthis._subCache.splice(0, neededSizeIndex);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this._subCache.some(a => a.collection === collection && a.publication === subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscription.subscriptionData))) {\n\t\t\t\t\t\tthis._subCache.splice(this._subCache.findIndex(a => a.collection === collection && a.publication === subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscription.subscriptionData)), 1);\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tlet cacheId = this._cacheId++;\n\t\t\t\t\tthis._nodeCache.set(cacheId, res);\n\t\t\t\t\tthis._subCache.push({collection: collection, publication: subscription.publication, subscriptionData: subscription.subscriptionData, id: cacheId});\n\n\t\t\t\t\t// console.log('Cache: ' + 'Create - ' + subscription.publication + ' - ' + getBinarySize(JSON.stringify(this._subCache)));\n\n\t\t\t\t\tsubscription.clients.forEach(client => {\n\t\t\t\t\t\tthat._wss.clients.forEach(ws => {\n\t\t\t\t\t\t\tif (ws['id_socket'] === client.id_socket) {\n\t\t\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\t\t\tmessageId: client.messageId,\n\t\t\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\t\t\tdata: res\n\t\t\t\t\t\t\t\t};\n\t\t\n\t\t\t\t\t\t\t\tthis.sendWS(ws, serverRes);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\n\t\t\t\t\tresolve(true);\n\t\t\t\t}, err => {\n\t\t\t\t\tsubscription.clients.forEach(client => {\n\t\t\t\t\t\tthat._wss.clients.forEach(ws => {\n\t\t\t\t\t\t\tif (ws['id_socket'] === client.id_socket) {\n\t\t\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\t\t\tmessageId: client.messageId,\n\t\t\t\t\t\t\t\t\thasError: true,\n\t\t\t\t\t\t\t\t\tdata: err\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tthis.sendWS(ws, serverRes);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\n\t\t\t\t\treject(err);\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate sendWS(ws: WebSocket, data: ServerResponseModel) {\n\t\tthis._sendQueue.splice(0, 0, {\n\t\t\tid_ws: ws['id_socket'],\n\t\t\tdata: data\n\t\t});\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/managers/subscription.manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,wCAA0C;AAC1C,6CAA2D;AAC3D,yDAAuE;AACvE,2DAAyE;AACzE,qCAAiC;AACjC,+CAA6D;AAC7D,2DAAyE;AACzE,gGAAoF;AACpF,wFAA0E;AAC1E,uDAAoE;AACpE,+CAA8D;AAC9D,6DAA2E;AAC3E,qEAAkF;AAClF,mEAAgF;AAEhF,kCAA2C;AAC3C,+DAA6E;AAC7E,yCAA0C;AAC1C,wGAAyF;AACzF,+BAAiC;AACjC,mFAA+F;AAC/F,iFAA6F;AAG7F,sCAAwC;AAExC;IAoBC,6BAAY,UAAU,EAAE,GAAqB,EAAE,YAAY;QAA3D,iBAqGC;QAtHO,kBAAa,GAAsB,EAAE,CAAC;QACtC,mBAAc,GAA8B,EAAE,CAAC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,WAAW,CAAC,KAAK,MAAM,CAAC,SAAS,EAAE;oCACzC,IAAI,SAAS,GAAwB;wCACpC,SAAS,EAAE,MAAM,CAAC,SAAS;wCAC3B,QAAQ,EAAE,KAAK;wCACf,IAAI,EAAE,GAAG;qCACT,CAAC;oCAEF,KAAI,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;iCAC3B;4BACF,CAAC,CAAC,CAAC;wBACJ,CAAC,CAAC,CAAC;wBAEH,OAAO,CAAC,IAAI,CAAC,CAAC;oBACf,CAAC,EAAE,UAAA,GAAG;wBACL,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,UAAA,MAAM;4BAClC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,UAAA,EAAE;gCAC3B,IAAI,EAAE,CAAC,WAAW,CAAC,KAAK,MAAM,CAAC,SAAS,EAAE;oCACzC,IAAI,SAAS,GAAwB;wCACpC,SAAS,EAAE,MAAM,CAAC,SAAS;wCAC3B,QAAQ,EAAE,IAAI;wCACd,IAAI,EAAE,GAAG;qCACT,CAAC;oCAEF,KAAI,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;iCAC3B;4BACF,CAAC,CAAC,CAAC;wBACJ,CAAC,CAAC,CAAC;wBAEH,MAAM,CAAC,GAAG,CAAC,CAAC;oBACb,CAAC,CAAC,CAAC;iBACH;;;aACD,CAAC,CAAC;IACJ,CAAC;IAEO,oCAAM,GAAd,UAAe,EAAa,EAAE,IAAyB;QACtD,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE;YAC5B,KAAK,EAAE,EAAE,CAAC,WAAW,CAAC;YACtB,IAAI,EAAE,IAAI;SACV,CAAC,CAAC;IACJ,CAAC;IACF,0BAAC;AAAD,CAxnCA,AAwnCC,IAAA;AAxnCY,kDAAmB","file":"subscription.manager.js","sourcesContent":["import { ServerResponseModel } from '../models/server-response.model';\nimport { ActiveSubscriptionModel, SubscriptionModel } from '../models/subscription.model';\nimport * as WebSocket from 'ws';\nimport * as MongoOplog from 'mongo-oplog';\nimport { loadLogPublications } from '../publications/logs';\nimport { loadAppStatusPublications } from '../publications/app-status';\nimport { loadAppVersionPublications } from '../publications/app-version';\nimport { Types } from 'mongoose';\nimport { loadFilePublications } from '../publications/files';\nimport { loadSuperAdminPublications } from '../publications/super-admin';\nimport { ActiveSubscriptions } from '../collections/active-subscription.collection';\nimport { LoggedInUsers } from '../collections/logged-in-users.collection';\nimport { loadCronJobPublications } from '../publications/cron-jobs';\nimport { loadFlagsPublications } from '../publications/flags';\nimport { loadMethodCallsPublications } from '../publications/method-calls';\nimport { loadMethodResponsePublications } from '../publications/method-responses';\nimport { loadSupportTicketPublications } from '../publications/support-tickets';\nimport ResolveIOMainServer from '../server-app';\nimport { ResolveIOServer } from '../index';\nimport { loadNotificationPublications } from '../publications/notifications';\nimport { deepCopy } from '../util/common';\nimport { BillingLoggedInUsers } from '../collections/billing-logged-in-users.collection';\nimport * as moment from 'moment';\nimport { loadBillingLoggedInUsersPublications } from '../publications/billing-logged-in-users';\nimport { loadReportBuilderReportPublications } from '../publications/report-builder-reports';\nimport { LoggedInUserModel } from '../models/logged-in-users.model';\n\nimport * as NodeCache from 'node-cache';\n\nexport class SubscriptionManager {\n\n\tprivate _mainServer: ResolveIOMainServer;\n\tprivate _publications: SubscriptionModel = {};\n\tprivate _subscriptions: ActiveSubscriptionModel[] = [];\n\tprivate _wss: WebSocket.Server;\n\tprivate _loggedInUsers: LoggedInUserModel[] = [];\n\t\n\tprivate _oplogQueue = [];\n\tprivate _subCache = [];\n\tprivate _nodeCache;\n\tprivate _cacheId = 0;\n\tprivate _sendQueue = [];\n\tprivate _runningQueue = false;\n\n\tprivate _initOplogStart = false;\n\tprivate _initOplogSupportStart = false;\n\n\tprivate serverConfig;\n\n\tconstructor(mainServer, wss: WebSocket.Server, serverConfig) {\n\t\tthis._mainServer = mainServer;\n\n\t\tthis._nodeCache = new NodeCache( { stdTTL: 0, checkperiod: 0 } );\n\n\t\tthis.serverConfig = serverConfig;\n\t\tthis._wss = wss;\n\n\t\t// Publications\n\t\tloadSuperAdminPublications(this);\n\t\tloadAppVersionPublications(this);\n\t\tloadAppStatusPublications(this);\n\t\tloadLogPublications(this);\n\t\tloadFilePublications(this);\n\t\tloadCronJobPublications(this);\n\t\tloadFlagsPublications(this);\n\t\tloadMethodCallsPublications(this);\n\t\tloadMethodResponsePublications(this);\n\t\tloadBillingLoggedInUsersPublications(this);\n\t\tloadNotificationPublications(this);\n\t\tloadReportBuilderReportPublications(this);\n\n\t\tthis.tailOpLog();\n\t\tthis.runOpLogQueue();\n\n\t\tif (ResolveIOServer.getSupportDB()) {\n\t\t\tloadSupportTicketPublications(this);\n\t\t\t\n\t\t\tthis.tailOpLogSupport();\n\t\t}\n\n\t\tsetInterval(() => {\n\t\t\tconsole.log(new Date());\n\t\t\tconsole.log('Sub Cache Length: ' + this._subCache.length);\n\t\t\tconsole.log('Sub Length: ' + this._subscriptions.length);\n\t\t\tconsole.log(this._nodeCache.getStats().vsize);\n\t\t}, 43200000);\n\n\t\tsetInterval(() => {\n\t\t\tif (!this._runningQueue) {\n\t\t\t\tif (this._sendQueue.length) {\n\t\t\t\t\tthis._runningQueue = true;\n\t\t\t\t\tfor (let i = this._sendQueue.length - 1; i >= 0; i--) {\n\t\t\t\t\t\tlet ws = this._mainServer.getWS(this._sendQueue[i].id_ws);\n\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\tif (ws.bufferedAmount < 20480) {\n\t\t\t\t\t\t\t\tlet sendItem = this._sendQueue.pop();\n\t\t\t\t\t\t\t\tws.send(JSON.stringify(sendItem.data), (error) => {\n\t\t\t\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\t\t\t\tconsole.log('Error on WS: ', error);\n\t\t\t\t\t\t\t\t\t\tthis.unsubscribeAll(ws);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tthis._sendQueue.splice(i, 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tthis._runningQueue = false;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}, 25);\n\n\t\tLoggedInUsers.find().then(loggedInUsers => {\n\t\t\tthis._loggedInUsers = loggedInUsers;\n\t\t}, err => {\n\t\t\tconsole.log(err);\n\t\t});\n\n\t\tsetInterval(async () => {\n\t\t\tlet userCopy = deepCopy(this._loggedInUsers);\n\t\t\tfor (let i = this._loggedInUsers.length - 1; i >= 0; i--) {\n\t\t\t\tlet loggedInUser = userCopy[i];\n\n\t\t\t\tif (!loggedInUser.date || moment().diff(moment(loggedInUser.date), 'seconds') >= 60) {\n\t\t\t\t\tif (this._mainServer.getWS(loggedInUser.id_ws)) {\n\t\t\t\t\t\tthis.unsubscribeAll(this._mainServer.getWS(loggedInUser.id_ws));\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tthis._subscriptions.forEach(sub => {\n\t\t\t\t\t\t\tfor (let j = sub.clients.length - 1; j >= 0; j--) {\n\t\t\t\t\t\t\t\tlet client = sub.clients[j];\n\n\t\t\t\t\t\t\t\tif (client.id_socket === loggedInUser.id_ws) {\n\t\t\t\t\t\t\t\t\tsub.clients.splice(j, 1);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (await LoggedInUsers.findById(loggedInUser._id)) {\n\t\t\t\t\t\t\tawait LoggedInUsers.deleteOne({_id: loggedInUser._id}).exec();\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tthis._loggedInUsers.splice(i, 1);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}, 60000);\n\t}\n\n\t// Add all files to publications private object\n\tpublic publications(method: SubscriptionModel) {\n\t\tthis._publications = Object.assign(this._publications, method);\n\t}\n\n\tpublic async loggedInLatency(ws: WebSocket) {\n\t\tlet date = new Date();\n\n\t\tlet loggedInUser = this._loggedInUsers.filter(a => a.id_ws === ws['id_socket'])[0];\n\n\t\tif (loggedInUser) {\n\t\t\tloggedInUser.date = date;\n\t\t}\n\n\t\tLoggedInUsers.findOneAndUpdate({id_ws: ws['id_socket']}, {$set: {latency: ws['latency'], date: date}}).exec((err, res) => {\n\t\t\tif (err) {\n\t\t\t\tthis.unsubscribeAll(ws);\n\t\t\t}\n\t\t});\n\t}\n\n\t// Subscribe to publication\n\tpublic async subscribe(messageDate: Date, ws: WebSocket, messageId: number, publication: string, ...subscriptionData: any[]) {\n\t\tlet that = this;\n\n\t\tlet pub = that._publications[publication];\n\n\t\tif (!pub) {\n\t\t\tconsole.error('No Publication: ' + publication);\n\t\t\treturn;\n\t\t}\n\t\telse {\n\t\t\tif (subscriptionData.length > 1 || subscriptionData[0]) {\n\t\t\t\tif (!pub.check) {\n\t\t\t\t\tconsole.error('No Check Function For Pub ' + publication);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\telse if (!pub.check._schema) {\n\t\t\t\t\tconsole.error('No Check Schema For Pub ' + publication);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet valObj = {};\n\t\t\t\t\tlet valKeys = Object.keys(pub.check._schema);\n\n\t\t\t\t\tlet rootKeys = valKeys.filter(a => !a.includes('.'));\n\t\t\t\t\t\n\t\t\t\t\tfor (let i = 0; i < subscriptionData.length; i++) {\n\t\t\t\t\t\tvalObj[rootKeys[i]] = subscriptionData[i];\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tpub.check.validate(valObj);\n\t\t\t\t\t}\n\t\t\t\t\tcatch (errors) {\n\t\t\t\t\t\tif (errors) {\n\t\t\t\t\t\t\tconsole.error('Error in Pub Check (' + publication + ')', errors);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet sub = that._subscriptions.filter(a => a.publication === publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscriptionData))[0];\n\n\t\t\t// If sub found (another user watching same data), add client to same sub\n\t\t\tif (sub) {\n\t\t\t\tsub.clients.push({\n\t\t\t\t\tid_user: ws['id_user'],\n\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\tid_socket: ws['id_socket']\n\t\t\t\t});\n\t\t\t}\n\t\t\t// If sub not found, create new sub\n\t\t\telse {\n\t\t\t\tthat._subscriptions.push({\n\t\t\t\t\tpublication: publication,\n\t\t\t\t\tsubscriptionData: subscriptionData,\n\t\t\t\t\tcollections: that.getPublicationCollections(publication),\n\t\t\t\t\tclients: [{\n\t\t\t\t\t\tid_user: ws['id_user'],\n\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\tid_socket: ws['id_socket']\n\t\t\t\t\t}]\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (!sub) {\n\t\t\t\tsub = that._subscriptions.filter(a => a.publication === publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscriptionData))[0];\n\t\t\t}\n\n\t\t\t// console.log('Subscribe', new Date(), 'Success', sub);\n\n\t\t\t// Send pub data to client who just subscribed only, don't want to send to existing clients since nothing has changed\n\t\t\tthat.sendPubDataOnce(ws, messageId, sub, 'newSub', that.getPublicationCollections(publication)[0]);\n\n\t\t\tif (that._publications[sub.publication].preFunction && !sub.preSubscriptionData) {\n\t\t\t\tsub.preSubscriptionData = await that._publications[sub.publication].preFunction(...sub.subscriptionData);\n\t\t\t}\n\n\t\t\tlet newActiveSub = new ActiveSubscriptions({\n\t\t\t\tdate: new Date(),\n\t\t\t\tpublication: publication,\n\t\t\t\tsubData: JSON.stringify(subscriptionData),\n\t\t\t\tcollections: pub.collections,\n\t\t\t\tclients: sub.clients\n\t\t\t});\n\n\t\t\tActiveSubscriptions.findOneAndUpdate({\n\t\t\t\t$and: [\n\t\t\t\t\t{publication: publication},\n\t\t\t\t\t{subData: JSON.stringify(subscriptionData)}\n\t\t\t\t]\n\t\t\t}, {$setOnInsert: {_id: Types.ObjectId().toHexString(), __v: 0}, $set: newActiveSub}, {upsert: true}).exec();\n\t\t}\n\n\t\tif (publication === 'appversion') {\n\t\t\tlet newLoggedInUser = {\n\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t__v: 0,\n\t\t\t\tdate: new Date(),\n\t\t\t\tid_user: ws['id_user'],\n\t\t\t\tuser: ws['user'],\n\t\t\t\tid_ws: ws['id_socket']\n\t\t\t};\n\n\t\t\tthis._loggedInUsers.push(newLoggedInUser);\n\n\t\t\tLoggedInUsers.create(newLoggedInUser);\n\n\t\t\tif (ws['user'] !== 'Admin' && ResolveIOServer.getSupportDB()) {\n\t\t\t\tlet begDate = moment().startOf('month');\n\t\t\t\tlet endDate = moment().endOf('month');\n\n\t\t\t\tlet billUser = await BillingLoggedInUsers.findOne({\n\t\t\t\t\t$and: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tclient: ResolveIOServer.getClientName()\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid_user: ws['id_user']\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdate: {$gte: begDate}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdate: {$lte: endDate}\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t});\n\n\t\t\t\tif (!billUser) {\n\t\t\t\t\tBillingLoggedInUsers.create({\n\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\tid_user: ws['id_user'],\n\t\t\t\t\t\tuser: ws['user'],\n\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\tclient: ResolveIOServer.getClientName()\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Unsubscribe from publication \n\tpublic async unsubscribe(messageDate: Date, ws: WebSocket, messageId: number, publication: string, ...subscriptionData: any[]) {\n\t\tlet that = this;\n\n\t\t// console.log('Before');\n\t\t// console.dir(this._subscriptions.map(a => a.publication));\n\n\t\tif (!that._publications[publication]) {\n\t\t\tconsole.log('No Publication: ' + publication);\n\t\t\treturn;\n\t\t}\n\t\telse {\n\t\t\tlet sub = that._subscriptions.filter(a => a.publication === publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscriptionData))[0];\n\n\t\t\tif (sub) {\n\t\t\t\tfor (let i = sub.clients.length - 1; i >= 0; i--) {\n\t\t\t\t\tif (sub.clients[i].id_user === ws['id_user'] && sub.clients[i].messageId === messageId && sub.clients[i].id_socket === ws['id_socket']) {\n\t\t\t\t\t\tsub.clients.splice(i, 1);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlet activeSub = await ActiveSubscriptions.findOne({\n\t\t\t\t\t$and: [\n\t\t\t\t\t\t{publication: publication},\n\t\t\t\t\t\t{subData: JSON.stringify(subscriptionData)}\n\t\t\t\t\t]\n\t\t\t\t});\n\t\n\t\t\t\tif (activeSub) {\n\t\t\t\t\tActiveSubscriptions.updateOne({_id: activeSub._id}, {$set: {clients: sub.clients}}).exec();\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tconsole.log(ws['user'] + ' - Did not find sub on unsubscribe - publication: ' + publication + ', subData: ' + JSON.stringify(subscriptionData, null, 2));\n\t\t\t}\n\t\t}\n\t}\n\n\t// Unsubscribe from publication\n\tpublic async unsubscribeAll(ws: WebSocket) {\n\t\tlet that = this;\n\n\t\t// console.log('Before');\n\t\t// console.dir(this._subscriptions.map(a => a.publication));\n\n\t\tlet loggedInUser = await LoggedInUsers.findOne({id_ws: ws['id_socket']});\n\n\t\tif (loggedInUser) {\t\n\t\t\tif (this._loggedInUsers.map(a => a._id).indexOf(loggedInUser._id) >= 0) {\n\t\t\t\tthis._loggedInUsers.splice(this._loggedInUsers.map(a => a._id).indexOf(loggedInUser._id), 1);\n\t\t\t}\n\t\t\t\n\t\t\tLoggedInUsers.deleteOne({_id: loggedInUser._id}).exec();\n\t\t}\n\n\t\tlet userSubs = that._subscriptions.filter(a => a.clients.some(b => b.id_user === ws['id_user'] && b.id_socket === ws['id_socket']));\n\n\t\tfor (let i = userSubs.length - 1; i >= 0; i--) {\n\t\t\tlet sub = userSubs[i];\n\n\t\t\tfor (let j = sub.clients.length - 1; j >= 0; j--) {\n\t\t\t\tif (sub.clients[j].id_socket === ws['id_socket']) {\n\t\t\t\t\tsub.clients.splice(j, 1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tlet activeSubs = await ActiveSubscriptions.find({'clients.id_socket': ws['id_socket']});\n\n\t\tactiveSubs.forEach(sub => {\n\t\t\tfor (let j = sub.clients.length - 1; j >= 0; j--) {\n\t\t\t\tif (sub.clients[j].id_socket === ws['id_socket']) {\n\t\t\t\t\tsub.clients.splice(j, 1);\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tfor (let j = sub.clients.length - 1; j >= 0; j--) {\n\t\t\t\tif (sub.clients[j].id_socket === ws['id_socket']) {\n\t\t\t\t\tsub.clients.splice(j, 1);\n\t\t\t\t}\n\t\t\t}\n\t\t\tActiveSubscriptions.updateOne({_id: sub._id}, {$set: {clients: sub.clients}}).exec();\n\t\t});\n\n\t\tws.terminate();\n\n\t\t// console.log('After');\n\t\t// console.dir(this._subscriptions.map(a => a.publication));\n\t}\n\n\t// Get publication collection\n\tprivate getPublicationCollections(publication: string) {\n\t\treturn this._publications[publication].collections;\n\t}\n\n\t// Watch (tail) Mongo's operation log on the entire database (all insert/modify/delete will trigger this function)\n\tprivate tailOpLog() {\n\t\tlet that = this;\n\n\t\tconst oplog = MongoOplog(that.serverConfig['OPLOG_URL']);\n\t\toplog.tail().then(() => {\n\t\t\tconsole.log('tail started');\n\t\t\tthis._initOplogStart = true;\n\t\t}, err => {\n\t\t\tconsole.log(err);\n\t\t});\n\t\t\n\t\toplog.on('insert', doc => {\t\t\t\n\t\t\tlet nsArray = doc.ns.split('.');\n\t\t\tlet collection = nsArray[1];\n\n\t\t\tif (nsArray[2]) {\n\t\t\t\tcollection += '.' + nsArray[2];\n\t\t\t}\n\n\t\t\tif (collection === 'cron-jobs') {\n\t\t\t\tthis._mainServer.getCronManager().checkCronJobsForUpdates();\n\t\t\t}\n\t\t\telse if (collection === 'queue-methods') {\n\t\t\t\tthis._mainServer.getQueueManager().runMethodQueue();\n\t\t\t}\n\t\t\telse if (collection === 'queue-responses') {\n\t\t\t\tthis._mainServer.getQueueManager().runMethodResponse();\n\t\t\t}\n\t\t\telse if (collection === 'support-tickets' && this.serverConfig['ROOT_URL'] !== 'http://localhost:4200') {\n\t\t\t\tthis._mainServer.getMethodManager().callMethodInternal('sendSupportTicketEmail', doc.o._id);\n\t\t\t}\n\t\t\t\n\t\t\tif (!collection.endsWith('.versions') && !collection.startsWith('system.')) {\n\t\t\t\tthis._oplogQueue.push({\n\t\t\t\t\ttype: 'insert',\n\t\t\t\t\tcollection: collection,\n\t\t\t\t\tdoc: doc.o\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t\t\n\t\toplog.on('update', doc => {\t\t\t\n\t\t\tlet nsArray = doc.ns.split('.');\n\t\t\tlet collection = nsArray[1];\n\n\t\t\tif (nsArray[2]) {\n\t\t\t\tcollection += '.' + nsArray[2];\n\t\t\t}\n\n\t\t\tdoc.o['_id'] = doc.o2['_id'];\n\n\t\t\tif (collection === 'cron-jobs') {\n\t\t\t\tthis._mainServer.getCronManager().checkCronJobsForUpdates();\n\t\t\t}\n\n\t\t\tif (!collection.endsWith('.versions') && !collection.startsWith('system.')) {\n\t\t\t\tthis._oplogQueue.push({\n\t\t\t\t\ttype: 'update',\n\t\t\t\t\tcollection: collection,\n\t\t\t\t\tdoc: doc.o\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t\t\n\t\toplog.on('delete', doc => {\n\t\t\tlet nsArray = doc.ns.split('.');\n\t\t\tlet collection = nsArray[1];\n\n\t\t\tif (nsArray[2]) {\n\t\t\t\tcollection += '.' + nsArray[2];\n\t\t\t}\n\n\t\t\tthat.resendPubsForDelete(collection);\n\n\t\t\tif (collection === 'cron-jobs') {\n\t\t\t\tthis._mainServer.getCronManager().checkCronJobsForUpdates();\n\t\t\t}\n\t\t});\n\t\t\n\t\toplog.on('error', error => {\n\t\t\tconsole.log('oplog error', error);\n\n\t\t\tif (this._initOplogStart) {\n\t\t\t\tprocess.exit();\n\t\t\t}\n\t\t});\n\t\t\n\t\toplog.on('end', () => {\n\t\t\tconsole.log('oplog ended');\n\n\t\t\tif (this._initOplogStart) {\n\t\t\t\tprocess.exit();\n\t\t\t}\n\t\t});\n\n\t\toplog.stop(() => {\n\t\t\tconsole.log('oplog stopped');\n\t\t\t\n\t\t\tif (this._initOplogStart) {\n\t\t\t\tprocess.exit();\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate tailOpLogSupport() {\n\t\tlet that = this;\n\n\t\tconst oplog = MongoOplog(that.serverConfig['RESOLVEIO_SUPPORT_OPLOG_URL']);\n\t\toplog.tail().then(() => {\n\t\t\tconsole.log('tail started support');\n\n\t\t\tthis._initOplogSupportStart = true;\n\t\t}, err => {\n\t\t\tconsole.log(err);\n\t\t});\n\t\t\n\t\toplog.on('insert', doc => {\t\t\t\n\t\t\tlet nsArray = doc.ns.split('.');\n\t\t\tlet collection = nsArray[1];\n\n\t\t\tif (nsArray[2]) {\n\t\t\t\tcollection += '.' + nsArray[2];\n\t\t\t}\n\n\t\t\tif (collection === 'support-tickets') {\n\t\t\t\tthat.checkSupportPubsForChanges(collection, doc.o);\n\t\t\t}\n\t\t});\n\t\t\n\t\toplog.on('update', doc => {\t\t\t\n\t\t\tlet nsArray = doc.ns.split('.');\n\t\t\tlet collection = nsArray[1];\n\n\t\t\tif (nsArray[2]) {\n\t\t\t\tcollection += '.' + nsArray[2];\n\t\t\t}\n\n\t\t\tdoc.o['_id'] = doc.o2['_id'];\n\n\t\t\tif (collection === 'support-tickets') {\n\t\t\t\tthat.checkSupportPubsForChanges(collection, doc.o);\n\t\t\t}\n\t\t});\n\t\t\n\t\toplog.on('delete', doc => {\n\t\t\tlet nsArray = doc.ns.split('.');\n\t\t\tlet collection = nsArray[1];\n\n\t\t\tif (nsArray[2]) {\n\t\t\t\tcollection += '.' + nsArray[2];\n\t\t\t}\n\n\t\t\tif (collection === 'support-tickets') {\n\t\t\t\tthat.resendPubsForDelete(collection);\n\t\t\t}\n\t\t});\n\t\t\n\t\toplog.on('error', error => {\n\t\t\tconsole.log('oplog error support', error);\n\n\t\t\tif (this._initOplogSupportStart) {\n\t\t\t\tprocess.exit();\n\t\t\t}\n\t\t});\n\t\t\n\t\toplog.on('end', () => {\n\t\t\tconsole.log('oplog ended support');\n\n\t\t\tif (this._initOplogSupportStart) {\n\t\t\t\tprocess.exit();\n\t\t\t}\n\t\t});\n\n\t\toplog.stop(() => {\n\t\t\tconsole.log('oplog stopped support');\n\n\t\t\tif (this._initOplogSupportStart) {\n\t\t\t\tprocess.exit();\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate runOpLogQueue() {\n\t\tlet that = this;\n\t\tsetInterval(async () => {\n\t\t\tif (this._oplogQueue.length) {\n\t\t\t\tlet uniqueOplog = deepCopy(this._oplogQueue);\n\t\t\t\tthis._oplogQueue = [];\n\n\t\t\t\tlet uniquePubs = [];\n\n\t\t\t\tlet needIds = {};\n\n\t\t\t\tfor (let i = uniqueOplog.length - 1; i >= 0; i--) {\n\t\t\t\t\tif (!that._subscriptions.some(a => a.collections.includes(uniqueOplog[i].collection))) {\n\t\t\t\t\t\tuniqueOplog.splice(i, 1);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tuniqueOplog.forEach(oplog => {\n\t\t\t\t\tlet schemaErrors = null;\n\t\n\t\t\t\t\ttry {\n\t\t\t\t\t\tResolveIOServer.getMainDB().model(oplog.collection)['simplschema'].validate(oplog.doc);\n\t\t\t\t\t}\n\t\t\t\t\tcatch (errors) {\n\t\t\t\t\t\tschemaErrors = errors;\n\t\t\t\t\t}\n\t\t\n\t\t\t\t\tif (schemaErrors) {\n\t\t\t\t\t\tif (!needIds[oplog.collection]) {\n\t\t\t\t\t\t\tneedIds[oplog.collection] = [oplog.doc['_id']];\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tif (!needIds[oplog.collection].filter(a => a === oplog.doc['_id'])[0]) {\n\t\t\t\t\t\t\t\tneedIds[oplog.collection].push(oplog.doc['_id']);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\t\t\tfor (let i = 0; i < Object.keys(needIds).length; i++) {\n\t\t\t\t\tlet collection = Object.keys(needIds)[i];\n\t\t\t\t\tlet docs = await ResolveIOServer.getMainDB().model(collection).find({_id: {$in: needIds[collection]}});\n\n\t\t\t\t\tneedIds[collection].forEach(id_doc => {\n\t\t\t\t\t\tif (uniqueOplog.filter(a => a.doc && a.doc._id === id_doc)[0]) {\n\t\t\t\t\t\t\tif (docs.filter(a => a._id === id_doc)[0]) {\n\t\t\t\t\t\t\t\tuniqueOplog.filter(a => a.doc && a.doc._id === id_doc).forEach(op => {\n\t\t\t\t\t\t\t\t\top.doc = docs.filter(a => a._id === id_doc)[0];\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tuniqueOplog.splice(uniqueOplog.findIndex(a => a.doc && a.doc._id === id_doc)[0], 1);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tthis._mainServer.getMethodManager().sendEmail('dev@resolveio.com', 'SERVER - Oplog Doc Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'id_doc: ' + id_doc + ', UniqueOplogs: ' + JSON.stringify(uniqueOplog, null, 2));\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tfor (let i = uniqueOplog.length - 1; i >= 0; i--) {\n\t\t\t\t\tlet oplog = uniqueOplog[i];\n\n\t\t\t\t\tfor (let j = that._subscriptions.length - 1; j >= 0; j--) {\n\t\t\t\t\t\tlet sub = that._subscriptions[j];\n\n\t\t\t\t\t\tif (sub.collections.includes(oplog.collection)) {\n\t\t\t\t\t\t\tif (sub.preSubscriptionData) {\n\t\t\t\t\t\t\t\tif (that._publications[sub.publication].fetchFunction(oplog.doc, sub.preSubscriptionData)) {\n\t\t\t\t\t\t\t\t\tif (!uniquePubs.filter(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData) && JSON.stringify(oplog) === JSON.stringify(a.oplog)).length) {\n\t\t\t\t\t\t\t\t\t\tif (!sub.clients.length) {\n\t\t\t\t\t\t\t\t\t\t\tthat._subscriptions.splice(j, 1);\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\tawait ActiveSubscriptions.deleteOne({\n\t\t\t\t\t\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t{publication: sub.publication},\n\t\t\t\t\t\t\t\t\t\t\t\t\t{subData: JSON.stringify(sub.subscriptionData)}\n\t\t\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t\t}).exec();\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\t\t\tsub['oplog'] = oplog;\n\t\t\t\t\t\t\t\t\t\t\tuniquePubs.push(deepCopy(sub));\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\tif (this._subCache.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)) >= 0) {\n\t\t\t\t\t\t\t\t\t\t\tthis._nodeCache.del(this._subCache.filter(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData))[0].id);\n\t\t\t\t\t\t\t\t\t\t\tthis._subCache.splice(this._subCache.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)), 1);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (that._publications[sub.publication].preFunction) {\n\t\t\t\t\t\t\t\tif (!sub.clients.length) {\n\t\t\t\t\t\t\t\t\tthat._subscriptions.splice(j, 1);\n\t\t\t\t\n\t\t\t\t\t\t\t\t\tawait ActiveSubscriptions.deleteOne({\n\t\t\t\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t\t\t\t{publication: sub.publication},\n\t\t\t\t\t\t\t\t\t\t\t{subData: JSON.stringify(sub.subscriptionData)}\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t}).exec();\n\n\t\t\t\t\t\t\t\t\tif (this._subCache.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)) >= 0) {\n\t\t\t\t\t\t\t\t\t\tthis._nodeCache.del(this._subCache.filter(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData))[0].id);\n\t\t\t\t\t\t\t\t\t\tthis._subCache.splice(this._subCache.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)), 1);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tif (!uniquePubs.filter(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData) && JSON.stringify(oplog) === JSON.stringify(a.oplog)).length) {\n\t\t\t\t\t\t\t\t\t\tsub['oplog'] = oplog;\n\t\t\t\t\t\t\t\t\t\tuniquePubs.push(deepCopy(sub));\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tif (that._publications[sub.publication].fetchFunction) {\n\t\t\t\t\t\t\t\t\tif (that._publications[sub.publication].fetchFunction(oplog.doc, ...sub.subscriptionData)) {\n\t\t\t\t\t\t\t\t\t\tif (!uniquePubs.filter(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)).length) {\n\t\t\t\t\t\t\t\t\t\t\tif (!sub.clients.length) {\n\t\t\t\t\t\t\t\t\t\t\t\tthat._subscriptions.splice(j, 1);\n\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\tawait ActiveSubscriptions.deleteOne({\n\t\t\t\t\t\t\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{publication: sub.publication},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{subData: JSON.stringify(sub.subscriptionData)}\n\t\t\t\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t\t\t}).exec();\n\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\tif (this._subCache.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)) >= 0) {\n\t\t\t\t\t\t\t\t\t\t\t\t\tthis._nodeCache.del(this._subCache.filter(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData))[0].id);\n\t\t\t\t\t\t\t\t\t\t\t\t\tthis._subCache.splice(this._subCache.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)), 1);\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\t\t\t\tsub['oplog'] = oplog;\n\t\t\t\t\t\t\t\t\t\t\t\tuniquePubs.push(deepCopy(sub));\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tif (!uniquePubs.filter(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)).length) {\n\t\t\t\t\t\t\t\t\t\tif (!sub.clients.length) {\n\t\t\t\t\t\t\t\t\t\t\tthat._subscriptions.splice(j, 1);\n\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\tawait ActiveSubscriptions.deleteOne({\n\t\t\t\t\t\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t{publication: sub.publication},\n\t\t\t\t\t\t\t\t\t\t\t\t\t{subData: JSON.stringify(sub.subscriptionData)}\n\t\t\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t\t}).exec();\n\n\t\t\t\t\t\t\t\t\t\t\tif (this._subCache.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)) >= 0) {\n\t\t\t\t\t\t\t\t\t\t\t\tthis._nodeCache.del(this._subCache.filter(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData))[0].id);\n\t\t\t\t\t\t\t\t\t\t\t\tthis._subCache.splice(this._subCache.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)), 1);\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\t\t\tsub['oplog'] = oplog;\n\t\t\t\t\t\t\t\t\t\t\tuniquePubs.push(deepCopy(sub));\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor (let i = 0; i < uniquePubs.length; i++) {\n\t\t\t\t\tlet pub = uniquePubs[i];\n\t\t\t\t\tawait this.checkPubsForChanges(pub['oplog'].collection, pub['oplog'].doc, pub['oplog'].type, pub);\n\t\t\t\t}\n\t\t\t}\n\t\t}, 500);\n\t}\n\n\tprivate async resendPubsForDelete(collection: string) {\n\t\tlet that = this;\n\n\t\tlet subCopy = deepCopy(that._subscriptions.filter(a => a.collections.includes(collection)));\n\n\t\tfor (let jj = this._subCache.length - 1; jj >= 0; jj--) {\n\t\t\tif (this._subCache[jj].collection === collection || subCopy.some(a => a.publication === this._subCache[jj].publication)) {\n\t\t\t\tthis._nodeCache.del(this._subCache[jj].id);\n\n\t\t\t\tthis._subCache.splice(jj, 1);\n\t\t\t}\n\t\t}\n\n\t\tfor (let zz = subCopy.length - 1; zz >= 0; zz--) {\n\t\t\tlet sub = subCopy[zz];\n\n\t\t\tif (that._publications[sub.publication].ws_specific) {\n\t\t\t\tfor (let aa = 0; aa < sub.clients.length; aa++) {\n\t\t\t\t\tlet client = sub.clients[aa];\n\t\t\t\t\tfor (let bb = 0; bb < that._wss.clients.size; bb++) {\n\t\t\t\t\t\tlet ws = Array.from(that._wss.clients)[bb];\n\t\t\t\t\t\tif (ws['id_socket'] === client.id_socket) {\n\t\t\t\t\t\t\tawait that.sendPubDataOnce(ws, client.messageId, sub, 'delete', collection);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (!sub.clients.length) {\n\t\t\t\t\tif (that._subscriptions.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)) >= 0) {\n\t\t\t\t\t\tthat._subscriptions.splice(that._subscriptions.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)), 1);\n\t\t\t\t\t}\n\n\t\t\t\t\tawait ActiveSubscriptions.deleteOne({\n\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t{publication: sub.publication},\n\t\t\t\t\t\t\t{subData: JSON.stringify(sub.subscriptionData)}\n\t\t\t\t\t\t]\n\t\t\t\t\t}).exec();\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tawait that.sendPubData(sub, 'delete', collection);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Document: Inserted/Modified Document\n\t// Collection: Collection Document Lives In\n\t// Check to see if any pubs need to refetch due to Mongo operation\n\tprivate async checkPubsForChanges(collection: string, document: Object, type: string, sub: ActiveSubscriptionModel) {\n\t\tlet that = this;\n\n\t\tif (sub.preSubscriptionData) {\n\t\t\tif (that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) {\n\t\t\t\tif (this._subCache.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)) >= 0) {\n\t\t\t\t\tthis._nodeCache.del(this._subCache.filter(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData))[0].id);\n\t\t\t\t\tthis._subCache.splice(this._subCache.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)), 1);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tawait that.sendPubData(sub, type, collection);\n\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t\n\t\tif (that._publications[sub.publication].preFunction) {\n\t\t\tsub.preSubscriptionData = await that._publications[sub.publication].preFunction(sub.subscriptionData);\n\t\t\tif (that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) {\n\t\t\t\tif (this._subCache.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)) >= 0) {\n\t\t\t\t\tthis._nodeCache.del(this._subCache.filter(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData))[0].id);\n\t\t\t\t\tthis._subCache.splice(this._subCache.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)), 1);\n\t\t\t\t}\n\n\t\t\t\tawait that.sendPubData(sub, type, collection);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tif (that._publications[sub.publication].ws_specific) {\n\t\t\t\tif (this._subCache.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)) >= 0) {\n\t\t\t\t\tthis._nodeCache.del(this._subCache.filter(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData))[0].id);\n\t\t\t\t\tthis._subCache.splice(this._subCache.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)), 1);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tfor (let k = 0; k < sub.clients.length; k++) {\n\t\t\t\t\tlet client = sub.clients[k];\n\t\t\t\t\tif (that._publications[sub.publication].fetchFunction) {\n\t\t\t\t\t\tif (that._publications[sub.publication].fetchFunction(document, client.id_user, ...sub.subscriptionData)) {\n\t\t\t\t\t\t\tfor (let j = 0; j < that._wss.clients.size; j++) {\n\t\t\t\t\t\t\t\tlet ws = Array.from(that._wss.clients)[j];\n\t\t\t\t\t\t\t\tif (ws['id_socket'] === client.id_socket) {\n\t\t\t\t\t\t\t\t\tawait that.sendPubDataOnce(ws, client.messageId, sub, type, collection);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tfor (let j = 0; j < that._wss.clients.size; j++) {\n\t\t\t\t\t\t\tlet ws = Array.from(that._wss.clients)[j];\n\t\t\t\t\t\t\tif (ws['id_socket'] === client.id_socket) {\n\t\t\t\t\t\t\t\tawait that.sendPubDataOnce(ws, client.messageId, sub, type, collection);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (that._publications[sub.publication].fetchFunction) {\n\t\t\t\t\tif (that._publications[sub.publication].fetchFunction(document, ...sub.subscriptionData)) {\n\t\t\t\t\t\tif (this._subCache.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)) >= 0) {\n\t\t\t\t\t\t\tthis._nodeCache.del(this._subCache.filter(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData))[0].id);\n\t\t\t\t\t\t\tthis._subCache.splice(this._subCache.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)), 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tawait that.sendPubData(sub, type, collection);\n\t\t\t\t\t}\n\t\t\t\t\t// else\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tif (this._subCache.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)) >= 0) {\n\t\t\t\t\t\tthis._nodeCache.del(this._subCache.filter(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData))[0].id);\n\t\t\t\t\t\tthis._subCache.splice(this._subCache.findIndex(a => a.publication === sub.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(sub.subscriptionData)), 1);\n\t\t\t\t\t}\n\n\t\t\t\t\tawait that.sendPubData(sub, type, collection);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate checkSupportPubsForChanges(collection: string, document: Object) {\n\t\tlet that = this;\n\n\t\tthat._subscriptions.filter(a => a.collections.includes(collection)).forEach(async sub => {\n\t\t\tlet schemaErrors = null;\n\n\t\t\ttry {\n\t\t\t\tResolveIOServer.getSupportDB().model(collection)['simplschema'].validate(document);\n\t\t\t}\n\t\t\tcatch (errors) {\n\t\t\t\tschemaErrors = errors;\n\t\t\t}\n\n\t\t\tif (schemaErrors) {\n\t\t\t\tdocument = await ResolveIOServer.getSupportDB().model(collection).findById(document['_id']);\n\t\t\t}\n\n\t\t\tif (sub.preSubscriptionData) {\n\t\t\t\tif (that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) {\n\t\t\t\t\tthat.sendPubData(sub, 'support', collection);\n\n\t\t\t\t\tsub.preSubscriptionData = await that._publications[sub.publication].preFunction(...sub.subscriptionData);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (that._publications[sub.publication].preFunction) {\n\t\t\t\tsub.preSubscriptionData = await that._publications[sub.publication].preFunction(...sub.subscriptionData);\n\t\t\t\tif (that._publications[sub.publication].fetchFunction(document, sub.preSubscriptionData)) {\n\t\t\t\t\tthat.sendPubData(sub, 'support', collection);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (that._publications[sub.publication].ws_specific) {\n\t\t\t\t\tsub.clients.forEach(client => {\n\t\t\t\t\t\tif (that._publications[sub.publication].fetchFunction) {\n\t\t\t\t\t\t\tif (that._publications[sub.publication].fetchFunction(document, client.id_user, ...sub.subscriptionData)) {\n\t\t\t\t\t\t\t\tthat._wss.clients.forEach(ws => {\n\t\t\t\t\t\t\t\t\tif (ws['id_socket'] === client.id_socket) {\n\t\t\t\t\t\t\t\t\t\tthat.sendPubDataOnce(ws, client.messageId, sub, 'support', collection);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tthat._wss.clients.forEach(ws => {\n\t\t\t\t\t\t\t\tif (ws['id_socket'] === client.id_socket) {\n\t\t\t\t\t\t\t\t\tthat.sendPubDataOnce(ws, client.messageId, sub, 'support', collection);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tif (that._publications[sub.publication].fetchFunction) {\n\t\t\t\t\t\tif (that._publications[sub.publication].fetchFunction(document, ...sub.subscriptionData)) {\n\t\t\t\t\t\t\tthat.sendPubData(sub, 'support', collection);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tthat.sendPubData(sub, 'support', collection);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\t// Fetch pub once, send to all clients linked to this pub\n\tprivate sendPubDataOnce(ws: WebSocket, messageId: number, subscription: ActiveSubscriptionModel, type: string, collection: string) {\n\t\treturn new Promise(async (resolve, reject) => {\n\t\t\tlet that = this;\n\n\t\t\tif (!that._publications[subscription.publication].ws_specific) { // Same pub for all users\n\t\t\t\tif (this._subCache.some(a => a.publication === subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscription.subscriptionData))) {\n\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\tdata: this._nodeCache.get(this._subCache.filter(a => a.publication === subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscription.subscriptionData))[0].id)\n\t\t\t\t\t};\n\n\t\t\t\t\tthis.sendWS(ws, serverRes);\n\n\t\t\t\t\tresolve(true);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tif (subscription.publication !== 'superadminAPM' && subscription.publication !== 'loggedInUsers') {\n\t\t\t\t\t\tthat._mainServer.getMethodManager().callMethodInternal('insertSubscriptionLog', type, subscription.publication, collection, JSON.stringify(subscription.subscriptionData));\n\t\t\t\t\t}\n\n\t\t\t\t\tthat._publications[subscription.publication].function.call(Object.assign({}, that, SubscriptionManager.prototype), ...subscription.subscriptionData).then(res => {\n\t\t\t\t\t\tlet nodeCacheSize = this._nodeCache.getStats().vsize;\n\n\t\t\t\t\t\tif (nodeCacheSize > 500000000) {\n\t\t\t\t\t\t\tlet neededSizeIndex = 0;\n\n\t\t\t\t\t\t\tfor (let zz = 0; zz < this._subCache.length; zz++) {\n\t\t\t\t\t\t\t\tthis._nodeCache.del(this._subCache[zz].id);\n\n\t\t\t\t\t\t\t\tif (this._nodeCache.getStats().vsize < 500000000) {\n\t\t\t\t\t\t\t\t\tneededSizeIndex = zz;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// console.log('Cache1: ' + 'Too Big - ' + subscription.publication + ' - ' + getBinarySize(JSON.stringify(this._subCache)));\n\t\t\t\t\t\t\tthis._subCache.splice(0, neededSizeIndex);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (this._subCache.some(a => a.collection === collection && a.publication === subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscription.subscriptionData))) {\n\t\t\t\t\t\t\tthis._subCache.splice(this._subCache.findIndex(a => a.collection === collection && a.publication === subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscription.subscriptionData)), 1);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet cacheId = this._cacheId++;\n\t\t\t\t\t\tthis._nodeCache.set(cacheId, res);\n\t\t\t\t\t\tthis._subCache.push({collection: collection, publication: subscription.publication, subscriptionData: subscription.subscriptionData, id: cacheId});\n\n\t\t\t\t\t\t// console.log('Cache1: ' + 'Create - ' + subscription.publication + ' - ' + getBinarySize(JSON.stringify(this._subCache)));\n\n\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\tdata: res\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tthis.sendWS(ws, serverRes);\n\n\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t}, err => {\n\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\thasError: true,\n\t\t\t\t\t\t\tdata: err\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tthis.sendWS(ws, serverRes);\n\n\t\t\t\t\t\treject(err);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\telse { // Pub is different for each user (Look at users publication) [MUCH SLOWER, RE-RUNS FOR EACH USER]\n\t\t\t\tthat._publications[subscription.publication].function.call(Object.assign({}, that, SubscriptionManager.prototype), ws['id_user'], ...subscription.subscriptionData).then(res => {\n\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\tdata: res\n\t\t\t\t\t};\n\n\t\t\t\t\t// console.log('Send Pub Data Once 2', new Date(), 'Success', subscription);\n\n\t\t\t\t\tthis.sendWS(ws, serverRes);\n\n\t\t\t\t\tresolve(true);\n\n\t\t\t\t}, err => {\n\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\thasError: true,\n\t\t\t\t\t\tdata: err\n\t\t\t\t\t};\n\n\t\t\t\t\t// console.log('Send Pub Data Once 2', new Date(), 'Error', subscription);\n\n\t\t\t\t\tthis.sendWS(ws, serverRes);\n\n\t\t\t\t\treject(err);\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n\n\t// Fetch pub once, send to all clients linked to this pub\n\tprivate sendPubData(subscription: ActiveSubscriptionModel, type: string, collection: string) {\n\t\treturn new Promise(async (resolve, reject) => {\n\t\t\tlet that = this;\n\n\t\t\tif (this._subCache.some(a => a.publication === subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscription.subscriptionData))) {\n\t\t\t\tsubscription.clients.forEach(client => {\n\t\t\t\t\tthat._wss.clients.forEach(ws => {\n\t\t\t\t\t\tif (ws['id_socket'] === client.id_socket) {\n\t\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\t\tmessageId: client.messageId,\n\t\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\t\tdata: this._nodeCache.get(this._subCache.filter(a => a.publication === subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscription.subscriptionData))[0].id)\n\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\t// console.log('Cache: ' + 'Found - ' + subscription.publication + ' - ' + getBinarySize(JSON.stringify(this._subCache)));\n\t\t\t\t\t\t\tthis.sendWS(ws, serverRes);\n\n\t\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (subscription.publication !== 'superadminAPM' && subscription.publication !== 'loggedInUsers') {\n\t\t\t\t\tthat._mainServer.getMethodManager().callMethodInternal('insertSubscriptionLog', type, subscription.publication, collection, JSON.stringify(subscription.subscriptionData));\n\t\t\t\t}\n\n\t\t\t\tthat._publications[subscription.publication].function.call(Object.assign({}, that, SubscriptionManager.prototype), ...subscription.subscriptionData).then(res => {\n\t\t\t\t\tlet nodeCacheSize = this._nodeCache.getStats().vsize;\n\t\t\t\t\t\n\t\t\t\t\tif (nodeCacheSize > 500000000) {\n\t\t\t\t\t\tlet neededSizeIndex = 0;\n\n\t\t\t\t\t\tfor (let zz = 0; zz < this._subCache.length; zz++) {\n\t\t\t\t\t\t\tthis._nodeCache.del(this._subCache[zz].id);\n\n\t\t\t\t\t\t\tif (this._nodeCache.getStats().vsize < 500000000) {\n\t\t\t\t\t\t\t\tneededSizeIndex = zz;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// console.log('Cache: ' + 'Too Big - ' + subscription.publication + ' - ' + getBinarySize(JSON.stringify(this._subCache)));\n\t\t\t\t\t\tthis._subCache.splice(0, neededSizeIndex);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this._subCache.some(a => a.collection === collection && a.publication === subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscription.subscriptionData))) {\n\t\t\t\t\t\tthis._subCache.splice(this._subCache.findIndex(a => a.collection === collection && a.publication === subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscription.subscriptionData)), 1);\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tlet cacheId = this._cacheId++;\n\t\t\t\t\tthis._nodeCache.set(cacheId, res);\n\t\t\t\t\tthis._subCache.push({collection: collection, publication: subscription.publication, subscriptionData: subscription.subscriptionData, id: cacheId});\n\n\t\t\t\t\t// console.log('Cache: ' + 'Create - ' + subscription.publication + ' - ' + getBinarySize(JSON.stringify(this._subCache)));\n\n\t\t\t\t\tsubscription.clients.forEach(client => {\n\t\t\t\t\t\tthat._wss.clients.forEach(ws => {\n\t\t\t\t\t\t\tif (ws['id_socket'] === client.id_socket) {\n\t\t\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\t\t\tmessageId: client.messageId,\n\t\t\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\t\t\tdata: res\n\t\t\t\t\t\t\t\t};\n\t\t\n\t\t\t\t\t\t\t\tthis.sendWS(ws, serverRes);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\n\t\t\t\t\tresolve(true);\n\t\t\t\t}, err => {\n\t\t\t\t\tsubscription.clients.forEach(client => {\n\t\t\t\t\t\tthat._wss.clients.forEach(ws => {\n\t\t\t\t\t\t\tif (ws['id_socket'] === client.id_socket) {\n\t\t\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\t\t\tmessageId: client.messageId,\n\t\t\t\t\t\t\t\t\thasError: true,\n\t\t\t\t\t\t\t\t\tdata: err\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tthis.sendWS(ws, serverRes);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\n\t\t\t\t\treject(err);\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate sendWS(ws: WebSocket, data: ServerResponseModel) {\n\t\tthis._sendQueue.splice(0, 0, {\n\t\t\tid_ws: ws['id_socket'],\n\t\t\tdata: data\n\t\t});\n\t}\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@resolveio/server-lib",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.69",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"package": "npm run build-prod && npm pack ./dist",
|
|
8
|
-
"start": "node_modules/.bin/forever -c node --max-old-space-size=
|
|
8
|
+
"start": "node_modules/.bin/forever -c node --max-old-space-size=1800 index.js",
|
|
9
9
|
"server": "node_modules/gulp/bin/gulp.js mongo-start && node_modules/gulp/bin/gulp.js",
|
|
10
10
|
"postserver": "node_modules/gulp/bin/gulp.js mongo-stop",
|
|
11
11
|
"build-prod": "node_modules/gulp/bin/gulp.js build-prod"
|
package/server-app.js
CHANGED
|
@@ -311,7 +311,7 @@ var ResolveIOMainServer = /** @class */ (function () {
|
|
|
311
311
|
}
|
|
312
312
|
catch (e) {
|
|
313
313
|
console.log('Error - JSON.parse', message);
|
|
314
|
-
this._methodManager.sendEmail('dev@resolveio.com', 'SERVER - JSON Parse Error - ' +
|
|
314
|
+
this._methodManager.sendEmail('dev@resolveio.com', 'SERVER - JSON Parse Error - ' + this._serverConfig['CLIENT_NAME'], JSON.stringify([message, e]));
|
|
315
315
|
parseErrorFound = true;
|
|
316
316
|
}
|
|
317
317
|
if (!parseErrorFound) {
|
|
@@ -362,11 +362,11 @@ var ResolveIOMainServer = /** @class */ (function () {
|
|
|
362
362
|
});
|
|
363
363
|
process.on('unhandledRejection', function (error) {
|
|
364
364
|
console.error('Unhandled Rejection at Promise', error);
|
|
365
|
-
_this._methodManager.sendEmail('dev@resolveio.com', 'SERVER - Unhandled Rejection - ' +
|
|
365
|
+
_this._methodManager.sendEmail('dev@resolveio.com', 'SERVER - Unhandled Rejection - ' + _this._serverConfig['CLIENT_NAME'], JSON.stringify([error]));
|
|
366
366
|
});
|
|
367
367
|
process.on('uncaughtException', function (err) {
|
|
368
368
|
console.error(err, 'Uncaught Exception thrown');
|
|
369
|
-
_this._methodManager.sendEmail('dev@resolveio.com', 'SERVER - Unhandled Exception - ' +
|
|
369
|
+
_this._methodManager.sendEmail('dev@resolveio.com', 'SERVER - Unhandled Exception - ' + _this._serverConfig['CLIENT_NAME'], JSON.stringify([err]));
|
|
370
370
|
process.exit(1);
|
|
371
371
|
});
|
|
372
372
|
// Keep alive timer to ping/pong
|
package/server-app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/server-app.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA4C;AAC5C,iCAAmC;AACnC,mCAAqC;AACrC,wCAA0C;AAC1C,kDAAoD;AACpD,mCAAqC;AACrC,8CAAgD;AAChD,8BAAgC;AAChC,kCAAoC;AACpC,8BAAgC;AAEhC,oCAA8C;AAC9C,wCAA2D;AAC3D,wCAAkD;AAGlD,+EAAmE;AAEnE,qCAAwC;AACxC,uFAA2E;AAC3E,+DAAoD;AAEpD,+BAAiC;AACjC,iEAAsD;AACtD,wDAAsD;AACtD,4DAA0D;AAC1D,wEAAsE;AACtE,8DAA4D;AAC5D,wEAAqE;AAErE,wCAAyC;AACzC,6FAAiF;AACjF,oCAA8C;AAE9C;IAqBC,6BAAY,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO;QAdhD,cAAS,GAAG,EAA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AC,EAAE,CAAC,CAAC;qDACvB;gDACF,CAAC,CAAC,CAAC;6CACH;4CAED,IAAI,OAAK,eAAe,CAAC,eAAe,CAAC,aAAa,CAAC,EAAE;gDAExD,CAAA,KAAA,OAAK,eAAe,CAAA,CAAC,iBAAiB,YAAC,EAAE,EAAE,SAAS,EAAE,aAAa,SAAK,IAAI,GAAE;6CAC9E;iDACI;gDACJ,OAAO,CAAC,GAAG,CAAC,iCAAiC,GAAG,aAAa,CAAC,CAAC;6CAC/D;yCACD;;;;;;;wBAjTO,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC;;;6BAAE,CAAA,CAAC,IAAI,CAAC,CAAA;sDAArC,CAAC;;;;;wBAAsC,CAAC,EAAE,CAAA;;;wBAoTnD,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;;;;;aAE/B,EAAE,EAAE,CAAC,CAAC;IACR,CAAC;IAEM,2CAAa,GAApB,UAAqB,EAAa;QACjC,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;IAC9C,CAAC;IAEM,oCAAM,GAAb;QACC,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IACF,0BAAC;AAAD,CAntBA,AAmtBC,IAAA","file":"server-app.js","sourcesContent":["import { createServer, Server } from 'http';\nimport * as express from 'express';\nimport * as mongoose from 'mongoose';\nimport * as bodyParser from 'body-parser';\nimport * as xmlParser from 'express-xml-bodyparser';\nimport * as passport from 'passport';\nimport * as passportlocal from 'passport-local';\nimport * as WebSocket from 'ws';\nimport * as jwt from 'jsonwebtoken';\nimport * as uuid from 'uuid/v4';\n\nimport { setupAuthRoutes } from './http/auth';\nimport { dateReviver, getBinarySize } from './util/common';\nimport { setupHealthRoutes } from './http/health';\n\nimport { ServerResponseModel } from './models/server-response.model';\nimport { MethodCalls } from './collections/method-call.collection';\n\nimport { Types, Query } from 'mongoose';\nimport { MethodResponses } from './collections/method-response.collection';\nimport { Logs } from './collections/log.collection';\n\nimport * as moment from 'moment';\nimport { Users } from './collections/user.collection';\nimport { CronManager } from './managers/cron.manager';\nimport { MethodManager } from './managers/method.manager';\nimport { SubscriptionManager } from './managers/subscription.manager';\nimport { SupportManager } from './managers/support.manager';\nimport { QueueMethodManager } from './managers/queue-method.manager';\nimport { ResolveIOServer } from '.';\nimport { deepCopy } from './util/common';\nimport { LogMethodLatencies } from './collections/log-method-latency.collection';\nimport { setupHomeRoutes } from './http/home';\n\nexport default class ResolveIOMainServer {\n\tprivate _app: express.Application;\n\tprivate _server: Server;\n\tprivate _port: string | number;\n\tprivate _wss;\n\tprivate _serverConfig;\n\tprivate _clientDir;\n\tprivate _msgQueue = [];\n\tprivate _msgQueueRunning = false;\n\tpublic sesMail = false;\n\n\tprivate LOGGER = 'ERROR'; //ERROR / DEBUG\n\t\n\tprivate _resolveioServer: ResolveIOServer;\n\n\tprivate _subscriptionManager: SubscriptionManager;\n\tprivate _methodManager: MethodManager;\n\tprivate _queueManager: QueueMethodManager;\n\tprivate _cronManager: CronManager;\n\tprivate _supportManager: SupportManager;\n\n\tconstructor(mainServer, serverConfig, clientDir, sesMail) {\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('Starting ResolveIO Server');\n\t\t}\n\t\tthis._resolveioServer = mainServer;\n\t\tthis._serverConfig = serverConfig;\n\t\tthis._clientDir = clientDir;\n\t\tthis.sesMail = sesMail;\n\n\t\t// Start express app\n\t\tthis._app = express();\n\n\t\t// Use body parser for http call (login)\n\t\tthis._app.use(bodyParser.json({limit: '50mb'}));\n\t\tthis._app.use(bodyParser.urlencoded({limit: '50mb', extended: true, parameterLimit: 1000000 }));\n\t\tthis._app.use(xmlParser());\n\t\t\n\t\t// Set port\n\t\tthis._port = process.env.PORT || serverConfig['PORT'];\n\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('Setup ports');\n\t\t}\n\n\t\t// Create http server and websock server\n\t\tthis.createServer();\n\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('Create server');\n\t\t}\n\t\t\n\t\t// Set CORS\n\t\tthis._app.use(function (req, res, next) {\n\n\t\t\t// Website you wish to allow to connect\n\t\t\t// res.setHeader('Access-Control-Allow-Origin', serverConfig['ROOT_URL']);\n\t\t\tres.setHeader('Access-Control-Allow-Origin', '*');\n\t\t\n\t\t\t// Request methods you wish to allow\n\t\t\t// res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');\n\t\t\tres.setHeader('Access-Control-Allow-Methods', 'GET, POST');\n\t\t\n\t\t\t// Request headers you wish to allow\n\t\t\tres.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');\n\t\t\n\t\t\t// Set to true if you need the website to include cookies in the requests sent\n\t\t\t// to the API (e.g. in case you use sessions)\n\t\t\tres.setHeader('Access-Control-Allow-Credentials', 'false');\n\t\t\n\t\t\t// Pass to next layer of middleware\n\t\t\tnext();\n\t\t});\n\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('Setup cors');\n\t\t}\n\n\t\t// Set up http login route\n\t\tsetupAuthRoutes(this, this._app, serverConfig);\n\t\tsetupHealthRoutes(this._app, serverConfig);\n\n\t\tif (serverConfig['CLIENT_NAME'] === 'ResolveIO') {\n\t\t\tsetupHomeRoutes(this, this._app, serverConfig);\n\t\t}\n\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('Setup express routes');\n\t\t}\n\t}\n\n\tpublic getWS(id_ws: string) {\n\t\tlet res = null;\n\n\t\tthis._wss.clients.forEach((ws: WebSocket) => {\n\t\t\tif (ws['id_socket'] === id_ws) {\n\t\t\t\tres = ws;\n\t\t\t}\n\t\t});\n\n\t\treturn res;\n\t}\n\n\tpublic getWSList() {\n\t\tlet res = [];\n\n\t\tthis._wss.clients.forEach((ws: WebSocket) => {\n\t\t\tres.push(ws['id_socket']);\n\t\t});\n\n\t\treturn res;\n\t}\n\n\tpublic getWSUserList() {\n\t\tlet res = [];\n\n\t\tthis._wss.clients.forEach((ws: WebSocket) => {\n\t\t\tres.push(ws['id_user']);\n\t\t});\n\n\t\treturn res;\n\t}\n\n\tpublic getHTTPServer() {\n\t\treturn this._server;\n\t}\n\n\tpublic getCronManager() {\n\t\treturn this._cronManager;\n\t}\n\n\tpublic getMethodManager() {\n\t\treturn this._methodManager;\n\t}\n\n\tpublic getSubscriptionManager() {\n\t\treturn this._subscriptionManager;\n\t}\n\n\tpublic getQueueManager() {\n\t\treturn this._queueManager;\n\t}\n\n\tpublic getSupportManager() {\n\t\treturn this._supportManager;\n\t}\n\n\tprivate createServer(): void {\n\t\t// Start express server\n\t\tthis._server = createServer(this._app);\n\n\t\t// Start websocket server\n\t\t// Verify client with token before opening socket\n\t\tthis._wss = new WebSocket.Server({ \n\t\t\tserver: this._server,\n\t\t\tverifyClient: async (info, cb) => {\n\t\t\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\t\t\tconsole.log('Verify Client', info, cb);\n\t\t\t\t}\n\n\t\t\t\tlet infoData = (<string>info.req.headers['sec-websocket-protocol']).split(/,/);\n\n\t\t\t\tif (info.origin !== this._serverConfig['ROOT_URL'] && info.origin !== this._serverConfig['SEC_ROOT_URL'] && info.origin !== this._serverConfig['RESOLVEIO_URL'] && info.origin !== this._serverConfig['RESOLVEIO_SECONDARY_URL']) {\n\t\t\t\t\tcb(false, 401, 'Unauthorized');\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tif (infoData[1]) { //app version\n\t\t\t\t\t\tlet token = infoData[0];\n\t\t\t\t\t\tif (!token) {\n\t\t\t\t\t\t\tcb(false, 401, 'Unauthorized');\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tjwt.verify(token, this._serverConfig['JWT_SECRET'], async (err, decoded) => {\n\t\t\t\t\t\t\t\tif (err) {\n\t\t\t\t\t\t\t\t\tcb(false, 401, 'Unauthorized');\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tinfo.req['id_user'] = decoded['id_user'];\n\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\tlet user = await Users.findById(decoded['id_user']).exec();\n\t\t\t\t\t\t\t\t\t\tif (user) {\n\t\t\t\t\t\t\t\t\t\t\tinfo.req['user'] = user.fullname;\n\t\t\t\t\t\t\t\t\t\t\tinfo.req['user_readonly'] = user.readonly || false;\n\t\t\t\t\t\t\t\t\t\t\tcb(true);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\t\t\tcb(false);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tcatch (err) {\n\t\t\t\t\t\t\t\t\t\tcb(false);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tcb(false, 401, 'Invalid Version');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\t// Start Mongoose (MongoDB Connection)\n\t\tthis.setUpMongoose();\n\t}\n\n\tprivate setUpMongoose() {\n\t\tthis.setUpPassport();\n\n\t\t// Enable lean by default\n\t\tlet __setOptions = Query.prototype.setOptions;\n\t\tQuery.prototype.setOptions = function(options) {\n\t\t\tif (this._mongooseOptions.lean == null && this.mongooseCollection.collectionName !== 'users') {\n\t\t\t\tthis._mongooseOptions.lean = true;\n\t\t\t}\n\n\t\t\t__setOptions.apply(this, arguments);\n\n\t\t\treturn this;\n\t\t};\n\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('Start Managers');\n\t\t}\n\n\t\t// Start Managers\n\t\tthis._subscriptionManager = new SubscriptionManager(this, this._wss, this._serverConfig);\n\t\tthis._methodManager = new MethodManager(this, this._serverConfig, this._clientDir);\n\t\tthis._supportManager = new SupportManager(this, this._serverConfig, this._clientDir);\n\t\tthis._cronManager = new CronManager(this);\n\t\tthis._queueManager = new QueueMethodManager(this);\n\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('End Managers');\n\t\t}\n\n\t\tthis.listen();\n\n\t\tmongoose.set('useFindAndModify', false);\n\t\t// mongoose.set('useCreateIndexes', true);\n\t}\n\n\tprivate setUpPassport(): void {\n\t\t// Set up login passort\n\t\tthis._app.use(passport.initialize());\n\n\t\t// Start user authentication\n\t\tpassport.use(new passportlocal.Strategy(Users.authenticate()));\n\t\tpassport.serializeUser(Users.serializeUser());\n\t\tpassport.deserializeUser(Users.deserializeUser());\n\t}\n\n\n\t// Listen to port for websocket\n\tprivate listen(): void {\n\t\tthis._server.listen(this._port, () => {\n\t\t\tconsole.log('Running server on port %s', this._port);\n\t\t});\n\n\t\t// On websocket connection (already verified)\n\t\tthis._wss.on('connection', (ws, req) => {\n\n\t\t\t// Get user from token\n\t\t\tws['id_user'] = req.id_user;\n\t\t\tws['user'] = req.user;\n\t\t\tws['user_readonly'] = req.user_readonly;\n\t\t\tws['id_socket'] = uuid();\n\t\t\tws['retryCnt'] = 0;\n\n\t\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\t\tconsole.log('Connection from: ' + req.user);\n\t\t\t}\n\t\t\t\n\t\t\t// Use for keeping connection alive (ping/pong)\n\t\t\tws['isAlive'] = true;\n\t\t\tws.on('pong', () => {\n\t\t\t\tws['isAlive'] = true;\n\t\t\t\tws['pongTime'] = new Date();\n\t\t\t\tws['latency'] = moment.duration(moment(ws['pongTime']).diff(ws['pingTime'])).asMilliseconds();\n\t\t\t\tthis._subscriptionManager.loggedInLatency(ws);\n\t\t\t});\n\n\t\t\tws['versionTimer'] = setTimeout(() => {\n\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t}, 10000);\n\n\t\t\t// On data received (message)\n\t\t\tws.on('message', async (message: string) => {\n\t\t\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\t\t\tconsole.log('Message from: ' + ws['user'], message);\n\t\t\t\t}\n\n\t\t\t\tlet parseErrorFound = false;\n\n\t\t\t\tlet socketData = null;\n\t\t\t\t\n\t\t\t\ttry {\n\t\t\t\t\tsocketData = JSON.parse(message, dateReviver);\n\t\t\t\t}\n\t\t\t\tcatch(e) {\n\t\t\t\t\tconsole.log('Error - JSON.parse', message);\n\t\t\t\t\t\n\t\t\t\t\tthis._methodManager.sendEmail('dev@resolveio.com', 'SERVER - JSON Parse Error - ' + (this._serverConfig['ROOT_URL'] && this._serverConfig['ROOT_URL'].includes('dev.') ? 'DEV - ' : '') + this._serverConfig['CLIENT_NAME'], JSON.stringify([message, e]));\n\n\t\t\t\t\tparseErrorFound = true;\n\t\t\t\t}\n\n\t\t\t\tif (!parseErrorFound) {\n\t\t\t\t\tlet data = deepCopy(socketData);\n\n\t\t\t\t\tif (data[0] === 'ping') {\n\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\tws.send('pong', (error) => {\n\t\t\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\t\t\tconsole.log('Error on WS: ', error);\n\t\t\t\t\t\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tlet messageDate = data.shift();\n\t\t\t\t\tlet messageId = data.shift();\n\t\t\t\t\tlet type = data.shift();\n\n\t\t\t\t\tif (type === 'subscription') {\n\t\t\t\t\t\tlet subType = data.shift();\n\t\t\t\t\t\tlet pub = data.shift();\n\t\t\n\t\t\t\t\t\t// Subscribe\n\t\t\t\t\t\tif (subType === 'sub') {\n\t\t\t\t\t\t\tthis._subscriptionManager.subscribe(messageDate, ws, messageId, pub, ...data);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Unsubscribe\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tthis._subscriptionManager.unsubscribe(messageDate, ws, messageId, pub, ...data);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tthis._msgQueue.splice(0, 0, {\n\t\t\t\t\t\t\tws: ws,\n\t\t\t\t\t\t\tdata: socketData\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tws.on('close', () => {\n\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t});\n\n\t\t\tws.on('error', error => {\n\t\t\t\tconsole.log(error);\n\t\t\t\t\n\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t});\n\t\t});\n\n\t\tprocess.on('unhandledRejection', error => {\n\t\t\tconsole.error('Unhandled Rejection at Promise', error);\n\n\t\t\tthis._methodManager.sendEmail('dev@resolveio.com', 'SERVER - Unhandled Rejection - ' + (this._serverConfig['ROOT_URL'] && this._serverConfig['ROOT_URL'].includes('dev.') ? 'DEV - ' : '') + this._serverConfig['CLIENT_NAME'], JSON.stringify([error]));\n\t\t});\n\t\tprocess.on('uncaughtException', err => {\n\t\t\tconsole.error(err, 'Uncaught Exception thrown');\n\n\t\t\tthis._methodManager.sendEmail('dev@resolveio.com', 'SERVER - Unhandled Exception - ' + (this._serverConfig['ROOT_URL'] && this._serverConfig['ROOT_URL'].includes('dev.') ? 'DEV - ' : '') + this._serverConfig['CLIENT_NAME'], JSON.stringify([err]));\n\n\t\t\tprocess.exit(1);\n\t\t});\n\n\t\t// Keep alive timer to ping/pong\n\t\tsetInterval(() => {\n\t\t\tthis._wss.clients.forEach((ws: WebSocket) => {\n\t\t\t\tif (ws['isAlive'] === false) {\n\t\t\t\t\tws['retryCnt']++;\n\n\t\t\t\t\tif (ws['retryCnt'] >= 60) {\n\t\t\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tws['pingTime'] = new Date();\n\t\t\t\t\t\tws.ping(() => {});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tws['retryCnt'] = 0;\n\t\t\t\t\tws['isAlive'] = false;\n\t\t\t\t\tws['pingTime'] = new Date();\n\t\t\t\t\tws.ping(() => {});\n\t\t\t\t}\n\t\t\t});\n\t\t}, 5000);\n\n\t\tsetInterval(async () => {\n\t\t\t// console.log(data);\n\n\t\t\tif (!this._msgQueueRunning) {\n\t\t\t\tthis._msgQueueRunning = true;\n\t\t\t\t\n\t\t\t\tfor (let i = this._msgQueue.length - 1; i >= 0; i--) {\n\t\t\t\t\tlet msg = this._msgQueue.pop();\n\t\t\t\t\tlet data = msg.data;\n\t\t\t\t\tlet ws = msg.ws;\n\t\t\n\t\t\t\t\tlet messageDate = data.shift();\n\t\t\t\t\tlet messageId = data.shift();\n\t\t\t\t\tlet type = data.shift();\n\t\t\n\t\t\t\t\tlet method = '';\n\t\t\n\t\t\t\t\t// Method call\n\t\t\t\t\tif (type === 'method') {\n\t\t\t\t\t\tmethod = data.shift();\n\t\t\n\t\t\t\t\t\tif (method === 'setWSAppVersion') {\n\t\t\t\t\t\t\tclearTimeout(ws['versionTimer']);\n\t\t\t\t\t\t}\n\t\t\n\t\t\t\t\t\tif (method === 'disconnectWSCommand') {\n\t\t\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t\t\t\t\t}, 5000);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (ws['user_readonly']) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet methodLatency = await LogMethodLatencies.create({\n\t\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\t\tdate_start: new Date(),\n\t\t\t\t\t\t\tdate_end: null,\n\t\t\t\t\t\t\tlatency_ms: 0,\n\t\t\t\t\t\t\tmethod: method\n\t\t\t\t\t\t});\n\t\t\n\t\t\t\t\t\tif (method !== 'reportBuilderGetResults' && method !== 'reportBuilderGetDistinctValue' && method !== 'reportBuilderBuildTree' && method !== 'generatePDF' && method !== 'getWOOfflineData' && method !== 'countQuery' && method !== 'countWithQuery' && method !== 'countCollectionWithQuery' && method !== 'find' && method !== 'findOne' && method !== 'findWithOptions' && method !== 'setWSAppVersion' && method !== 'getDrivers') {\n\t\t\t\t\t\t\tif (getBinarySize(JSON.stringify(data)) < 200000) {\n\t\t\t\t\t\t\t\tLogs.create({\n\t\t\t\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\t\t\t\ttype: 'client-request',\n\t\t\t\t\t\t\t\t\ttitle: 'Client Request - Method',\n\t\t\t\t\t\t\t\t\tmessage: 'User: ' + ws['user'] + ', Type: ' + type + ', MessageId: ' + messageId + ', Method: ' + method,\n\t\t\t\t\t\t\t\t\tpayload: JSON.stringify(data, null, 2),\n\t\t\t\t\t\t\t\t\tmethod: method,\n\t\t\t\t\t\t\t\t\tuser: ws['user'],\n\t\t\t\t\t\t\t\t\tmessageId: messageId\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tLogs.create({\n\t\t\t\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\t\t\t\ttype: 'client-request',\n\t\t\t\t\t\t\t\t\ttitle: 'Client Request - Method',\n\t\t\t\t\t\t\t\t\tmessage: 'User: ' + ws['user'] + ', Type: ' + type + ', MessageId: ' + messageId + ', Method: ' + method,\n\t\t\t\t\t\t\t\t\tpayload: 'Too Big',\n\t\t\t\t\t\t\t\t\tmethod: method,\n\t\t\t\t\t\t\t\t\tuser: ws['user'],\n\t\t\t\t\t\t\t\t\tmessageId: messageId\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\n\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\tdata: 'ACK'\n\t\t\t\t\t\t};\n\t\t\n\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\tws.send(JSON.stringify(serverRes), (error) => {\n\t\t\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\t\t\tconsole.log('Error on WS: ', error);\n\t\t\t\t\t\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\n\t\t\t\t\t\tif (this._methodManager._methods[method]) {\n\t\t\n\t\t\t\t\t\t\tlet query: any = {$and: [\n\t\t\t\t\t\t\t\t{id_user: ws['id_user']}, \n\t\t\t\t\t\t\t\t{message_id: messageId},\n\t\t\t\t\t\t\t\t{date: messageDate}\n\t\t\t\t\t\t\t]};\n\t\t\n\t\t\t\t\t\t\tif (method !== 'updateDocumentOffline' && method !== 'updateDocumentPropsOffline') {\n\t\t\t\t\t\t\t\tquery.$and.push({method: method});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tif (method === 'updateDocumentOffline') {\n\t\t\t\t\t\t\t\t\tquery.$and.push({\n\t\t\t\t\t\t\t\t\t\t$or: [\n\t\t\t\t\t\t\t\t\t\t\t{method: method},\n\t\t\t\t\t\t\t\t\t\t\t{method: 'updateDocument'}\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse if (method === 'updateDocumentPropsOffline') {\n\t\t\t\t\t\t\t\t\tquery.$and.push({\n\t\t\t\t\t\t\t\t\t\t$or: [\n\t\t\t\t\t\t\t\t\t\t\t{method: method},\n\t\t\t\t\t\t\t\t\t\t\t{method: 'updateDocumentProps'}\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\n\t\t\t\t\t\t\tlet methodCall = await MethodCalls.findOne(query).exec();\n\t\t\n\t\t\t\t\t\t\tif (!methodCall) {\n\t\t\t\t\t\t\t\tawait MethodCalls.create({\n\t\t\t\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\t\t\t\tid_user: ws['id_user'],\n\t\t\t\t\t\t\t\t\tmessage_id: messageId,\n\t\t\t\t\t\t\t\t\tmethod: method,\n\t\t\t\t\t\t\t\t\tdate: messageDate\n\t\t\t\t\t\t\t\t});\n\t\t\t\n\t\t\t\t\t\t\t\tif (this._methodManager._methods[method]) {\n\t\t\t\t\t\t\t\t\tif (this._methodManager._methods[method].skipQueue) {\n\t\t\t\t\t\t\t\t\t\tthis._methodManager.callMethod(methodLatency._id, ws, messageDate, messageId, method, ...data);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\t\tthis._queueManager.addMethodToQueue(methodLatency._id, ws['id_socket'], ws['id_user'], ws['user'], messageDate, messageId, method, data);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tconsole.log('Could not find method: ' + method);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tMethodResponses.findOne({$and: [\n\t\t\t\t\t\t\t\t\t{id_user: ws['id_user']}, \n\t\t\t\t\t\t\t\t\t{message_id: messageId},\n\t\t\t\t\t\t\t\t\t{method: method},\n\t\t\t\t\t\t\t\t\t{date: messageDate}\n\t\t\t\t\t\t\t\t]}).exec((err, res) => {\n\t\t\t\t\t\t\t\t\tif (res) {\n\t\t\t\t\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\t\t\t\t\tws.send(JSON.stringify(res.response), (error) => {\n\t\t\t\t\t\t\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\t\t\t\t\t\t\tconsole.log('Error on WS: ', error);\n\t\t\t\t\t\t\t\t\t\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tconsole.log('Could not find method: ' + method);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse if (type === 'methodRetry') {\n\t\t\t\t\t\tmethod = data.shift();\n\t\t\n\t\t\t\t\t\tif (method !== 'reportBuilderGetResults' && method !== 'reportBuilderGetDistinctValue' && method !== 'reportBuilderBuildTree' && method !== 'generatePDF' && method !== 'getWOOfflineData' && method !== 'countQuery' && method !== 'countWithQuery' && method !== 'countCollectionWithQuery' && method !== 'find' && method !== 'findOne' && method !== 'findWithOptions' && method !== 'setWSAppVersion' && method !== 'getDrivers') {\n\t\t\t\t\t\t\tif (getBinarySize(JSON.stringify(data)) < 200000) {\n\t\t\t\t\t\t\t\tLogs.create({\n\t\t\t\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\t\t\t\ttype: 'client-request',\n\t\t\t\t\t\t\t\t\ttitle: 'Client Request - Method Retry',\n\t\t\t\t\t\t\t\t\tmessage: 'User: ' + ws['user'] + ', Type: ' + type + ', MessageId: ' + messageId + ', Method: ' + method,\n\t\t\t\t\t\t\t\t\tpayload: JSON.stringify(data, null, 2),\n\t\t\t\t\t\t\t\t\tmethod: method,\n\t\t\t\t\t\t\t\t\tuser: ws['user'],\n\t\t\t\t\t\t\t\t\tmessageId: messageId\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tLogs.create({\n\t\t\t\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\t\t\t\ttype: 'client-request',\n\t\t\t\t\t\t\t\t\ttitle: 'Client Request - Method Retry',\n\t\t\t\t\t\t\t\t\tmessage: 'User: ' + ws['user'] + ', Type: ' + type + ', MessageId: ' + messageId + ', Method: ' + method,\n\t\t\t\t\t\t\t\t\tpayload: 'Too Big',\n\t\t\t\t\t\t\t\t\tmethod: method,\n\t\t\t\t\t\t\t\t\tuser: ws['user'],\n\t\t\t\t\t\t\t\t\tmessageId: messageId\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\n\t\t\t\t\t\tMethodCalls.findOne({$and: [\n\t\t\t\t\t\t\t{id_user: ws['id_user']}, \n\t\t\t\t\t\t\t{message_id: messageId},\n\t\t\t\t\t\t\t{method: method},\n\t\t\t\t\t\t\t{date: messageDate}\n\t\t\t\t\t\t]}).exec((err, res) => {\n\t\t\t\t\t\t\tif (res) {\n\t\t\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\t\t\tdata: 'ACK'\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\n\t\t\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\t\t\tws.send(JSON.stringify(serverRes), (error) => {\n\t\t\t\t\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\t\t\t\t\tconsole.log('Error on WS: ', error);\n\t\t\t\t\t\t\t\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\t\t\tdata: 'NACK'\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\n\t\t\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\t\t\tws.send(JSON.stringify(serverRes), (error) => {\n\t\t\t\t\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\t\t\t\t\tconsole.log('Error on WS: ', error);\n\t\t\t\t\t\t\t\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\telse if (type === 'methodResponse') {\n\t\t\t\t\t\tmethod = data.shift();\n\t\t\n\t\t\t\t\t\tMethodResponses.findOne({$and: [\n\t\t\t\t\t\t\t{id_user: ws['id_user']}, \n\t\t\t\t\t\t\t{message_id: messageId},\n\t\t\t\t\t\t\t{method: method},\n\t\t\t\t\t\t\t{date: messageDate}\n\t\t\t\t\t\t]}).exec((err, res) => {\n\t\t\t\t\t\t\tif (res) {\n\t\t\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\t\t\tws.send(JSON.stringify(res.response), (error) => {\n\t\t\t\t\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\t\t\t\t\tconsole.log('Error on WS: ', error);\n\t\t\t\t\t\t\t\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\telse if (type === 'support') {\n\t\t\t\t\t\tlet supportMethod = data.shift();\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (getBinarySize(JSON.stringify(data)) < 200000) {\n\t\t\t\t\t\t\tLogs.create({\n\t\t\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\t\t\ttype: 'client-request',\n\t\t\t\t\t\t\t\ttitle: 'Client Request - Support',\n\t\t\t\t\t\t\t\tmessage: 'User: ' + ws['user'] + ', Type: ' + type + ', MessageId: ' + messageId + ', Support Method: ' + supportMethod,\n\t\t\t\t\t\t\t\tpayload: JSON.stringify(data, null, 2),\n\t\t\t\t\t\t\t\tmethod: supportMethod,\n\t\t\t\t\t\t\t\tuser: ws['user'],\n\t\t\t\t\t\t\t\tmessageId: messageId\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tLogs.create({\n\t\t\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\t\t\ttype: 'client-request',\n\t\t\t\t\t\t\t\ttitle: 'Client Request - Support',\n\t\t\t\t\t\t\t\tmessage: 'User: ' + ws['user'] + ', Type: ' + type + ', MessageId: ' + messageId + ', Support Method: ' + supportMethod,\n\t\t\t\t\t\t\t\tpayload: 'Too Big',\n\t\t\t\t\t\t\t\tmethod: supportMethod,\n\t\t\t\t\t\t\t\tuser: ws['user'],\n\t\t\t\t\t\t\t\tmessageId: messageId\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\n\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\tdata: 'ACK'\n\t\t\t\t\t\t};\n\t\t\n\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\tws.send(JSON.stringify(serverRes), (error) => {\n\t\t\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\t\t\tconsole.log('Error on WS: ', error);\n\t\t\t\t\t\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\n\t\t\t\t\t\tif (this._supportManager._supportMethods[supportMethod]) {\n\t\t\n\t\t\t\t\t\t\tthis._supportManager.callSupportMethod(ws, messageId, supportMethod, ...data);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tconsole.log('Could not find support method: ' + supportMethod);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis._msgQueueRunning = false;\n\t\t\t}\n\t\t}, 25);\n\t}\n\n\tpublic unsubscribeWS(ws: WebSocket) {\n\t\tthis._subscriptionManager.unsubscribeAll(ws);\n\t}\n\n\tpublic getApp() {\n\t\treturn this._app;\n\t}\n}"]}
|
|
1
|
+
{"version":3,"sources":["../../src/server-app.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA4C;AAC5C,iCAAmC;AACnC,mCAAqC;AACrC,wCAA0C;AAC1C,kDAAoD;AACpD,mCAAqC;AACrC,8CAAgD;AAChD,8BAAgC;AAChC,kCAAoC;AACpC,8BAAgC;AAEhC,oCAA8C;AAC9C,wCAA2D;AAC3D,wCAAkD;AAGlD,+EAAmE;AAEnE,qCAAwC;AACxC,uFAA2E;AAC3E,+DAAoD;AAEpD,+BAAiC;AACjC,iEAAsD;AACtD,wDAAsD;AACtD,4DAA0D;AAC1D,wEAAsE;AACtE,8DAA4D;AAC5D,wEAAqE;AAErE,wCAAyC;AACzC,6FAAiF;AACjF,oCAA8C;AAE9C;IAqBC,6BAAY,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO;QAd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KAAK,CAAC;;;;;aAE/B,EAAE,EAAE,CAAC,CAAC;IACR,CAAC;IAEM,2CAAa,GAApB,UAAqB,EAAa;QACjC,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;IAC9C,CAAC;IAEM,oCAAM,GAAb;QACC,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IACF,0BAAC;AAAD,CAntBA,AAmtBC,IAAA","file":"server-app.js","sourcesContent":["import { createServer, Server } from 'http';\nimport * as express from 'express';\nimport * as mongoose from 'mongoose';\nimport * as bodyParser from 'body-parser';\nimport * as xmlParser from 'express-xml-bodyparser';\nimport * as passport from 'passport';\nimport * as passportlocal from 'passport-local';\nimport * as WebSocket from 'ws';\nimport * as jwt from 'jsonwebtoken';\nimport * as uuid from 'uuid/v4';\n\nimport { setupAuthRoutes } from './http/auth';\nimport { dateReviver, getBinarySize } from './util/common';\nimport { setupHealthRoutes } from './http/health';\n\nimport { ServerResponseModel } from './models/server-response.model';\nimport { MethodCalls } from './collections/method-call.collection';\n\nimport { Types, Query } from 'mongoose';\nimport { MethodResponses } from './collections/method-response.collection';\nimport { Logs } from './collections/log.collection';\n\nimport * as moment from 'moment';\nimport { Users } from './collections/user.collection';\nimport { CronManager } from './managers/cron.manager';\nimport { MethodManager } from './managers/method.manager';\nimport { SubscriptionManager } from './managers/subscription.manager';\nimport { SupportManager } from './managers/support.manager';\nimport { QueueMethodManager } from './managers/queue-method.manager';\nimport { ResolveIOServer } from '.';\nimport { deepCopy } from './util/common';\nimport { LogMethodLatencies } from './collections/log-method-latency.collection';\nimport { setupHomeRoutes } from './http/home';\n\nexport default class ResolveIOMainServer {\n\tprivate _app: express.Application;\n\tprivate _server: Server;\n\tprivate _port: string | number;\n\tprivate _wss;\n\tprivate _serverConfig;\n\tprivate _clientDir;\n\tprivate _msgQueue = [];\n\tprivate _msgQueueRunning = false;\n\tpublic sesMail = false;\n\n\tprivate LOGGER = 'ERROR'; //ERROR / DEBUG\n\t\n\tprivate _resolveioServer: ResolveIOServer;\n\n\tprivate _subscriptionManager: SubscriptionManager;\n\tprivate _methodManager: MethodManager;\n\tprivate _queueManager: QueueMethodManager;\n\tprivate _cronManager: CronManager;\n\tprivate _supportManager: SupportManager;\n\n\tconstructor(mainServer, serverConfig, clientDir, sesMail) {\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('Starting ResolveIO Server');\n\t\t}\n\t\tthis._resolveioServer = mainServer;\n\t\tthis._serverConfig = serverConfig;\n\t\tthis._clientDir = clientDir;\n\t\tthis.sesMail = sesMail;\n\n\t\t// Start express app\n\t\tthis._app = express();\n\n\t\t// Use body parser for http call (login)\n\t\tthis._app.use(bodyParser.json({limit: '50mb'}));\n\t\tthis._app.use(bodyParser.urlencoded({limit: '50mb', extended: true, parameterLimit: 1000000 }));\n\t\tthis._app.use(xmlParser());\n\t\t\n\t\t// Set port\n\t\tthis._port = process.env.PORT || serverConfig['PORT'];\n\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('Setup ports');\n\t\t}\n\n\t\t// Create http server and websock server\n\t\tthis.createServer();\n\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('Create server');\n\t\t}\n\t\t\n\t\t// Set CORS\n\t\tthis._app.use(function (req, res, next) {\n\n\t\t\t// Website you wish to allow to connect\n\t\t\t// res.setHeader('Access-Control-Allow-Origin', serverConfig['ROOT_URL']);\n\t\t\tres.setHeader('Access-Control-Allow-Origin', '*');\n\t\t\n\t\t\t// Request methods you wish to allow\n\t\t\t// res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');\n\t\t\tres.setHeader('Access-Control-Allow-Methods', 'GET, POST');\n\t\t\n\t\t\t// Request headers you wish to allow\n\t\t\tres.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');\n\t\t\n\t\t\t// Set to true if you need the website to include cookies in the requests sent\n\t\t\t// to the API (e.g. in case you use sessions)\n\t\t\tres.setHeader('Access-Control-Allow-Credentials', 'false');\n\t\t\n\t\t\t// Pass to next layer of middleware\n\t\t\tnext();\n\t\t});\n\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('Setup cors');\n\t\t}\n\n\t\t// Set up http login route\n\t\tsetupAuthRoutes(this, this._app, serverConfig);\n\t\tsetupHealthRoutes(this._app, serverConfig);\n\n\t\tif (serverConfig['CLIENT_NAME'] === 'ResolveIO') {\n\t\t\tsetupHomeRoutes(this, this._app, serverConfig);\n\t\t}\n\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('Setup express routes');\n\t\t}\n\t}\n\n\tpublic getWS(id_ws: string) {\n\t\tlet res = null;\n\n\t\tthis._wss.clients.forEach((ws: WebSocket) => {\n\t\t\tif (ws['id_socket'] === id_ws) {\n\t\t\t\tres = ws;\n\t\t\t}\n\t\t});\n\n\t\treturn res;\n\t}\n\n\tpublic getWSList() {\n\t\tlet res = [];\n\n\t\tthis._wss.clients.forEach((ws: WebSocket) => {\n\t\t\tres.push(ws['id_socket']);\n\t\t});\n\n\t\treturn res;\n\t}\n\n\tpublic getWSUserList() {\n\t\tlet res = [];\n\n\t\tthis._wss.clients.forEach((ws: WebSocket) => {\n\t\t\tres.push(ws['id_user']);\n\t\t});\n\n\t\treturn res;\n\t}\n\n\tpublic getHTTPServer() {\n\t\treturn this._server;\n\t}\n\n\tpublic getCronManager() {\n\t\treturn this._cronManager;\n\t}\n\n\tpublic getMethodManager() {\n\t\treturn this._methodManager;\n\t}\n\n\tpublic getSubscriptionManager() {\n\t\treturn this._subscriptionManager;\n\t}\n\n\tpublic getQueueManager() {\n\t\treturn this._queueManager;\n\t}\n\n\tpublic getSupportManager() {\n\t\treturn this._supportManager;\n\t}\n\n\tprivate createServer(): void {\n\t\t// Start express server\n\t\tthis._server = createServer(this._app);\n\n\t\t// Start websocket server\n\t\t// Verify client with token before opening socket\n\t\tthis._wss = new WebSocket.Server({ \n\t\t\tserver: this._server,\n\t\t\tverifyClient: async (info, cb) => {\n\t\t\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\t\t\tconsole.log('Verify Client', info, cb);\n\t\t\t\t}\n\n\t\t\t\tlet infoData = (<string>info.req.headers['sec-websocket-protocol']).split(/,/);\n\n\t\t\t\tif (info.origin !== this._serverConfig['ROOT_URL'] && info.origin !== this._serverConfig['SEC_ROOT_URL'] && info.origin !== this._serverConfig['RESOLVEIO_URL'] && info.origin !== this._serverConfig['RESOLVEIO_SECONDARY_URL']) {\n\t\t\t\t\tcb(false, 401, 'Unauthorized');\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tif (infoData[1]) { //app version\n\t\t\t\t\t\tlet token = infoData[0];\n\t\t\t\t\t\tif (!token) {\n\t\t\t\t\t\t\tcb(false, 401, 'Unauthorized');\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tjwt.verify(token, this._serverConfig['JWT_SECRET'], async (err, decoded) => {\n\t\t\t\t\t\t\t\tif (err) {\n\t\t\t\t\t\t\t\t\tcb(false, 401, 'Unauthorized');\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tinfo.req['id_user'] = decoded['id_user'];\n\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\tlet user = await Users.findById(decoded['id_user']).exec();\n\t\t\t\t\t\t\t\t\t\tif (user) {\n\t\t\t\t\t\t\t\t\t\t\tinfo.req['user'] = user.fullname;\n\t\t\t\t\t\t\t\t\t\t\tinfo.req['user_readonly'] = user.readonly || false;\n\t\t\t\t\t\t\t\t\t\t\tcb(true);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\t\t\tcb(false);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tcatch (err) {\n\t\t\t\t\t\t\t\t\t\tcb(false);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tcb(false, 401, 'Invalid Version');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\t// Start Mongoose (MongoDB Connection)\n\t\tthis.setUpMongoose();\n\t}\n\n\tprivate setUpMongoose() {\n\t\tthis.setUpPassport();\n\n\t\t// Enable lean by default\n\t\tlet __setOptions = Query.prototype.setOptions;\n\t\tQuery.prototype.setOptions = function(options) {\n\t\t\tif (this._mongooseOptions.lean == null && this.mongooseCollection.collectionName !== 'users') {\n\t\t\t\tthis._mongooseOptions.lean = true;\n\t\t\t}\n\n\t\t\t__setOptions.apply(this, arguments);\n\n\t\t\treturn this;\n\t\t};\n\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('Start Managers');\n\t\t}\n\n\t\t// Start Managers\n\t\tthis._subscriptionManager = new SubscriptionManager(this, this._wss, this._serverConfig);\n\t\tthis._methodManager = new MethodManager(this, this._serverConfig, this._clientDir);\n\t\tthis._supportManager = new SupportManager(this, this._serverConfig, this._clientDir);\n\t\tthis._cronManager = new CronManager(this);\n\t\tthis._queueManager = new QueueMethodManager(this);\n\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('End Managers');\n\t\t}\n\n\t\tthis.listen();\n\n\t\tmongoose.set('useFindAndModify', false);\n\t\t// mongoose.set('useCreateIndexes', true);\n\t}\n\n\tprivate setUpPassport(): void {\n\t\t// Set up login passort\n\t\tthis._app.use(passport.initialize());\n\n\t\t// Start user authentication\n\t\tpassport.use(new passportlocal.Strategy(Users.authenticate()));\n\t\tpassport.serializeUser(Users.serializeUser());\n\t\tpassport.deserializeUser(Users.deserializeUser());\n\t}\n\n\n\t// Listen to port for websocket\n\tprivate listen(): void {\n\t\tthis._server.listen(this._port, () => {\n\t\t\tconsole.log('Running server on port %s', this._port);\n\t\t});\n\n\t\t// On websocket connection (already verified)\n\t\tthis._wss.on('connection', (ws, req) => {\n\n\t\t\t// Get user from token\n\t\t\tws['id_user'] = req.id_user;\n\t\t\tws['user'] = req.user;\n\t\t\tws['user_readonly'] = req.user_readonly;\n\t\t\tws['id_socket'] = uuid();\n\t\t\tws['retryCnt'] = 0;\n\n\t\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\t\tconsole.log('Connection from: ' + req.user);\n\t\t\t}\n\t\t\t\n\t\t\t// Use for keeping connection alive (ping/pong)\n\t\t\tws['isAlive'] = true;\n\t\t\tws.on('pong', () => {\n\t\t\t\tws['isAlive'] = true;\n\t\t\t\tws['pongTime'] = new Date();\n\t\t\t\tws['latency'] = moment.duration(moment(ws['pongTime']).diff(ws['pingTime'])).asMilliseconds();\n\t\t\t\tthis._subscriptionManager.loggedInLatency(ws);\n\t\t\t});\n\n\t\t\tws['versionTimer'] = setTimeout(() => {\n\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t}, 10000);\n\n\t\t\t// On data received (message)\n\t\t\tws.on('message', async (message: string) => {\n\t\t\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\t\t\tconsole.log('Message from: ' + ws['user'], message);\n\t\t\t\t}\n\n\t\t\t\tlet parseErrorFound = false;\n\n\t\t\t\tlet socketData = null;\n\t\t\t\t\n\t\t\t\ttry {\n\t\t\t\t\tsocketData = JSON.parse(message, dateReviver);\n\t\t\t\t}\n\t\t\t\tcatch(e) {\n\t\t\t\t\tconsole.log('Error - JSON.parse', message);\n\t\t\t\t\t\n\t\t\t\t\tthis._methodManager.sendEmail('dev@resolveio.com', 'SERVER - JSON Parse Error - ' + this._serverConfig['CLIENT_NAME'], JSON.stringify([message, e]));\n\n\t\t\t\t\tparseErrorFound = true;\n\t\t\t\t}\n\n\t\t\t\tif (!parseErrorFound) {\n\t\t\t\t\tlet data = deepCopy(socketData);\n\n\t\t\t\t\tif (data[0] === 'ping') {\n\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\tws.send('pong', (error) => {\n\t\t\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\t\t\tconsole.log('Error on WS: ', error);\n\t\t\t\t\t\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tlet messageDate = data.shift();\n\t\t\t\t\tlet messageId = data.shift();\n\t\t\t\t\tlet type = data.shift();\n\n\t\t\t\t\tif (type === 'subscription') {\n\t\t\t\t\t\tlet subType = data.shift();\n\t\t\t\t\t\tlet pub = data.shift();\n\t\t\n\t\t\t\t\t\t// Subscribe\n\t\t\t\t\t\tif (subType === 'sub') {\n\t\t\t\t\t\t\tthis._subscriptionManager.subscribe(messageDate, ws, messageId, pub, ...data);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Unsubscribe\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tthis._subscriptionManager.unsubscribe(messageDate, ws, messageId, pub, ...data);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tthis._msgQueue.splice(0, 0, {\n\t\t\t\t\t\t\tws: ws,\n\t\t\t\t\t\t\tdata: socketData\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tws.on('close', () => {\n\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t});\n\n\t\t\tws.on('error', error => {\n\t\t\t\tconsole.log(error);\n\t\t\t\t\n\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t});\n\t\t});\n\n\t\tprocess.on('unhandledRejection', error => {\n\t\t\tconsole.error('Unhandled Rejection at Promise', error);\n\n\t\t\tthis._methodManager.sendEmail('dev@resolveio.com', 'SERVER - Unhandled Rejection - ' + this._serverConfig['CLIENT_NAME'], JSON.stringify([error]));\n\t\t});\n\t\tprocess.on('uncaughtException', err => {\n\t\t\tconsole.error(err, 'Uncaught Exception thrown');\n\n\t\t\tthis._methodManager.sendEmail('dev@resolveio.com', 'SERVER - Unhandled Exception - ' + this._serverConfig['CLIENT_NAME'], JSON.stringify([err]));\n\n\t\t\tprocess.exit(1);\n\t\t});\n\n\t\t// Keep alive timer to ping/pong\n\t\tsetInterval(() => {\n\t\t\tthis._wss.clients.forEach((ws: WebSocket) => {\n\t\t\t\tif (ws['isAlive'] === false) {\n\t\t\t\t\tws['retryCnt']++;\n\n\t\t\t\t\tif (ws['retryCnt'] >= 60) {\n\t\t\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tws['pingTime'] = new Date();\n\t\t\t\t\t\tws.ping(() => {});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tws['retryCnt'] = 0;\n\t\t\t\t\tws['isAlive'] = false;\n\t\t\t\t\tws['pingTime'] = new Date();\n\t\t\t\t\tws.ping(() => {});\n\t\t\t\t}\n\t\t\t});\n\t\t}, 5000);\n\n\t\tsetInterval(async () => {\n\t\t\t// console.log(data);\n\n\t\t\tif (!this._msgQueueRunning) {\n\t\t\t\tthis._msgQueueRunning = true;\n\t\t\t\t\n\t\t\t\tfor (let i = this._msgQueue.length - 1; i >= 0; i--) {\n\t\t\t\t\tlet msg = this._msgQueue.pop();\n\t\t\t\t\tlet data = msg.data;\n\t\t\t\t\tlet ws = msg.ws;\n\t\t\n\t\t\t\t\tlet messageDate = data.shift();\n\t\t\t\t\tlet messageId = data.shift();\n\t\t\t\t\tlet type = data.shift();\n\t\t\n\t\t\t\t\tlet method = '';\n\t\t\n\t\t\t\t\t// Method call\n\t\t\t\t\tif (type === 'method') {\n\t\t\t\t\t\tmethod = data.shift();\n\t\t\n\t\t\t\t\t\tif (method === 'setWSAppVersion') {\n\t\t\t\t\t\t\tclearTimeout(ws['versionTimer']);\n\t\t\t\t\t\t}\n\t\t\n\t\t\t\t\t\tif (method === 'disconnectWSCommand') {\n\t\t\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t\t\t\t\t}, 5000);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (ws['user_readonly']) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet methodLatency = await LogMethodLatencies.create({\n\t\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\t\tdate_start: new Date(),\n\t\t\t\t\t\t\tdate_end: null,\n\t\t\t\t\t\t\tlatency_ms: 0,\n\t\t\t\t\t\t\tmethod: method\n\t\t\t\t\t\t});\n\t\t\n\t\t\t\t\t\tif (method !== 'reportBuilderGetResults' && method !== 'reportBuilderGetDistinctValue' && method !== 'reportBuilderBuildTree' && method !== 'generatePDF' && method !== 'getWOOfflineData' && method !== 'countQuery' && method !== 'countWithQuery' && method !== 'countCollectionWithQuery' && method !== 'find' && method !== 'findOne' && method !== 'findWithOptions' && method !== 'setWSAppVersion' && method !== 'getDrivers') {\n\t\t\t\t\t\t\tif (getBinarySize(JSON.stringify(data)) < 200000) {\n\t\t\t\t\t\t\t\tLogs.create({\n\t\t\t\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\t\t\t\ttype: 'client-request',\n\t\t\t\t\t\t\t\t\ttitle: 'Client Request - Method',\n\t\t\t\t\t\t\t\t\tmessage: 'User: ' + ws['user'] + ', Type: ' + type + ', MessageId: ' + messageId + ', Method: ' + method,\n\t\t\t\t\t\t\t\t\tpayload: JSON.stringify(data, null, 2),\n\t\t\t\t\t\t\t\t\tmethod: method,\n\t\t\t\t\t\t\t\t\tuser: ws['user'],\n\t\t\t\t\t\t\t\t\tmessageId: messageId\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tLogs.create({\n\t\t\t\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\t\t\t\ttype: 'client-request',\n\t\t\t\t\t\t\t\t\ttitle: 'Client Request - Method',\n\t\t\t\t\t\t\t\t\tmessage: 'User: ' + ws['user'] + ', Type: ' + type + ', MessageId: ' + messageId + ', Method: ' + method,\n\t\t\t\t\t\t\t\t\tpayload: 'Too Big',\n\t\t\t\t\t\t\t\t\tmethod: method,\n\t\t\t\t\t\t\t\t\tuser: ws['user'],\n\t\t\t\t\t\t\t\t\tmessageId: messageId\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\n\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\tdata: 'ACK'\n\t\t\t\t\t\t};\n\t\t\n\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\tws.send(JSON.stringify(serverRes), (error) => {\n\t\t\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\t\t\tconsole.log('Error on WS: ', error);\n\t\t\t\t\t\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\n\t\t\t\t\t\tif (this._methodManager._methods[method]) {\n\t\t\n\t\t\t\t\t\t\tlet query: any = {$and: [\n\t\t\t\t\t\t\t\t{id_user: ws['id_user']}, \n\t\t\t\t\t\t\t\t{message_id: messageId},\n\t\t\t\t\t\t\t\t{date: messageDate}\n\t\t\t\t\t\t\t]};\n\t\t\n\t\t\t\t\t\t\tif (method !== 'updateDocumentOffline' && method !== 'updateDocumentPropsOffline') {\n\t\t\t\t\t\t\t\tquery.$and.push({method: method});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tif (method === 'updateDocumentOffline') {\n\t\t\t\t\t\t\t\t\tquery.$and.push({\n\t\t\t\t\t\t\t\t\t\t$or: [\n\t\t\t\t\t\t\t\t\t\t\t{method: method},\n\t\t\t\t\t\t\t\t\t\t\t{method: 'updateDocument'}\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse if (method === 'updateDocumentPropsOffline') {\n\t\t\t\t\t\t\t\t\tquery.$and.push({\n\t\t\t\t\t\t\t\t\t\t$or: [\n\t\t\t\t\t\t\t\t\t\t\t{method: method},\n\t\t\t\t\t\t\t\t\t\t\t{method: 'updateDocumentProps'}\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\n\t\t\t\t\t\t\tlet methodCall = await MethodCalls.findOne(query).exec();\n\t\t\n\t\t\t\t\t\t\tif (!methodCall) {\n\t\t\t\t\t\t\t\tawait MethodCalls.create({\n\t\t\t\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\t\t\t\tid_user: ws['id_user'],\n\t\t\t\t\t\t\t\t\tmessage_id: messageId,\n\t\t\t\t\t\t\t\t\tmethod: method,\n\t\t\t\t\t\t\t\t\tdate: messageDate\n\t\t\t\t\t\t\t\t});\n\t\t\t\n\t\t\t\t\t\t\t\tif (this._methodManager._methods[method]) {\n\t\t\t\t\t\t\t\t\tif (this._methodManager._methods[method].skipQueue) {\n\t\t\t\t\t\t\t\t\t\tthis._methodManager.callMethod(methodLatency._id, ws, messageDate, messageId, method, ...data);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\t\tthis._queueManager.addMethodToQueue(methodLatency._id, ws['id_socket'], ws['id_user'], ws['user'], messageDate, messageId, method, data);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tconsole.log('Could not find method: ' + method);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tMethodResponses.findOne({$and: [\n\t\t\t\t\t\t\t\t\t{id_user: ws['id_user']}, \n\t\t\t\t\t\t\t\t\t{message_id: messageId},\n\t\t\t\t\t\t\t\t\t{method: method},\n\t\t\t\t\t\t\t\t\t{date: messageDate}\n\t\t\t\t\t\t\t\t]}).exec((err, res) => {\n\t\t\t\t\t\t\t\t\tif (res) {\n\t\t\t\t\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\t\t\t\t\tws.send(JSON.stringify(res.response), (error) => {\n\t\t\t\t\t\t\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\t\t\t\t\t\t\tconsole.log('Error on WS: ', error);\n\t\t\t\t\t\t\t\t\t\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tconsole.log('Could not find method: ' + method);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse if (type === 'methodRetry') {\n\t\t\t\t\t\tmethod = data.shift();\n\t\t\n\t\t\t\t\t\tif (method !== 'reportBuilderGetResults' && method !== 'reportBuilderGetDistinctValue' && method !== 'reportBuilderBuildTree' && method !== 'generatePDF' && method !== 'getWOOfflineData' && method !== 'countQuery' && method !== 'countWithQuery' && method !== 'countCollectionWithQuery' && method !== 'find' && method !== 'findOne' && method !== 'findWithOptions' && method !== 'setWSAppVersion' && method !== 'getDrivers') {\n\t\t\t\t\t\t\tif (getBinarySize(JSON.stringify(data)) < 200000) {\n\t\t\t\t\t\t\t\tLogs.create({\n\t\t\t\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\t\t\t\ttype: 'client-request',\n\t\t\t\t\t\t\t\t\ttitle: 'Client Request - Method Retry',\n\t\t\t\t\t\t\t\t\tmessage: 'User: ' + ws['user'] + ', Type: ' + type + ', MessageId: ' + messageId + ', Method: ' + method,\n\t\t\t\t\t\t\t\t\tpayload: JSON.stringify(data, null, 2),\n\t\t\t\t\t\t\t\t\tmethod: method,\n\t\t\t\t\t\t\t\t\tuser: ws['user'],\n\t\t\t\t\t\t\t\t\tmessageId: messageId\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tLogs.create({\n\t\t\t\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\t\t\t\ttype: 'client-request',\n\t\t\t\t\t\t\t\t\ttitle: 'Client Request - Method Retry',\n\t\t\t\t\t\t\t\t\tmessage: 'User: ' + ws['user'] + ', Type: ' + type + ', MessageId: ' + messageId + ', Method: ' + method,\n\t\t\t\t\t\t\t\t\tpayload: 'Too Big',\n\t\t\t\t\t\t\t\t\tmethod: method,\n\t\t\t\t\t\t\t\t\tuser: ws['user'],\n\t\t\t\t\t\t\t\t\tmessageId: messageId\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\n\t\t\t\t\t\tMethodCalls.findOne({$and: [\n\t\t\t\t\t\t\t{id_user: ws['id_user']}, \n\t\t\t\t\t\t\t{message_id: messageId},\n\t\t\t\t\t\t\t{method: method},\n\t\t\t\t\t\t\t{date: messageDate}\n\t\t\t\t\t\t]}).exec((err, res) => {\n\t\t\t\t\t\t\tif (res) {\n\t\t\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\t\t\tdata: 'ACK'\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\n\t\t\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\t\t\tws.send(JSON.stringify(serverRes), (error) => {\n\t\t\t\t\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\t\t\t\t\tconsole.log('Error on WS: ', error);\n\t\t\t\t\t\t\t\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\t\t\tdata: 'NACK'\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\n\t\t\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\t\t\tws.send(JSON.stringify(serverRes), (error) => {\n\t\t\t\t\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\t\t\t\t\tconsole.log('Error on WS: ', error);\n\t\t\t\t\t\t\t\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\telse if (type === 'methodResponse') {\n\t\t\t\t\t\tmethod = data.shift();\n\t\t\n\t\t\t\t\t\tMethodResponses.findOne({$and: [\n\t\t\t\t\t\t\t{id_user: ws['id_user']}, \n\t\t\t\t\t\t\t{message_id: messageId},\n\t\t\t\t\t\t\t{method: method},\n\t\t\t\t\t\t\t{date: messageDate}\n\t\t\t\t\t\t]}).exec((err, res) => {\n\t\t\t\t\t\t\tif (res) {\n\t\t\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\t\t\tws.send(JSON.stringify(res.response), (error) => {\n\t\t\t\t\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\t\t\t\t\tconsole.log('Error on WS: ', error);\n\t\t\t\t\t\t\t\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\telse if (type === 'support') {\n\t\t\t\t\t\tlet supportMethod = data.shift();\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (getBinarySize(JSON.stringify(data)) < 200000) {\n\t\t\t\t\t\t\tLogs.create({\n\t\t\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\t\t\ttype: 'client-request',\n\t\t\t\t\t\t\t\ttitle: 'Client Request - Support',\n\t\t\t\t\t\t\t\tmessage: 'User: ' + ws['user'] + ', Type: ' + type + ', MessageId: ' + messageId + ', Support Method: ' + supportMethod,\n\t\t\t\t\t\t\t\tpayload: JSON.stringify(data, null, 2),\n\t\t\t\t\t\t\t\tmethod: supportMethod,\n\t\t\t\t\t\t\t\tuser: ws['user'],\n\t\t\t\t\t\t\t\tmessageId: messageId\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tLogs.create({\n\t\t\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\t\t\ttype: 'client-request',\n\t\t\t\t\t\t\t\ttitle: 'Client Request - Support',\n\t\t\t\t\t\t\t\tmessage: 'User: ' + ws['user'] + ', Type: ' + type + ', MessageId: ' + messageId + ', Support Method: ' + supportMethod,\n\t\t\t\t\t\t\t\tpayload: 'Too Big',\n\t\t\t\t\t\t\t\tmethod: supportMethod,\n\t\t\t\t\t\t\t\tuser: ws['user'],\n\t\t\t\t\t\t\t\tmessageId: messageId\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\n\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\tdata: 'ACK'\n\t\t\t\t\t\t};\n\t\t\n\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\tws.send(JSON.stringify(serverRes), (error) => {\n\t\t\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\t\t\tconsole.log('Error on WS: ', error);\n\t\t\t\t\t\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\n\t\t\t\t\t\tif (this._supportManager._supportMethods[supportMethod]) {\n\t\t\n\t\t\t\t\t\t\tthis._supportManager.callSupportMethod(ws, messageId, supportMethod, ...data);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tconsole.log('Could not find support method: ' + supportMethod);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis._msgQueueRunning = false;\n\t\t\t}\n\t\t}, 25);\n\t}\n\n\tpublic unsubscribeWS(ws: WebSocket) {\n\t\tthis._subscriptionManager.unsubscribeAll(ws);\n\t}\n\n\tpublic getApp() {\n\t\treturn this._app;\n\t}\n}"]}
|