@resolveio/server-lib 9.0.33 → 9.0.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client-server-app.js +7 -48
- package/client-server-app.js.map +1 -1
- package/collections/app-status.collection.js +8 -11
- package/collections/app-status.collection.js.map +1 -1
- package/collections/app-version.collection.js +8 -11
- package/collections/app-version.collection.js.map +1 -1
- package/collections/counter.collection.js +8 -11
- package/collections/counter.collection.js.map +1 -1
- package/collections/cron-job-history.collection.js +9 -12
- package/collections/cron-job-history.collection.js.map +1 -1
- package/collections/cron-job.collection.js +8 -11
- package/collections/cron-job.collection.js.map +1 -1
- package/collections/email-history.collection.js +8 -11
- package/collections/email-history.collection.js.map +1 -1
- package/collections/email-verified.collection.js +9 -12
- package/collections/email-verified.collection.js.map +1 -1
- package/collections/file.collection.js +8 -11
- package/collections/file.collection.js.map +1 -1
- package/collections/flag.collection.js +8 -11
- package/collections/flag.collection.js.map +1 -1
- package/collections/log-method-latency.collection.js +11 -14
- package/collections/log-method-latency.collection.js.map +1 -1
- package/collections/log-subscription.collection.js +13 -16
- package/collections/log-subscription.collection.js.map +1 -1
- package/collections/log.collection.js +16 -19
- package/collections/log.collection.js.map +1 -1
- package/collections/logged-in-users.collection.js +9 -12
- package/collections/logged-in-users.collection.js.map +1 -1
- package/collections/method-call.collection.js +10 -13
- package/collections/method-call.collection.js.map +1 -1
- package/collections/method-response.collection.js +10 -13
- package/collections/method-response.collection.js.map +1 -1
- package/collections/monitor-cpu.collection.js +13 -16
- package/collections/monitor-cpu.collection.js.map +1 -1
- package/collections/monitor-https-inbound.collection.js +13 -16
- package/collections/monitor-https-inbound.collection.js.map +1 -1
- package/collections/monitor-https-outbound.collection.js +15 -18
- package/collections/monitor-https-outbound.collection.js.map +1 -1
- package/collections/monitor-memory.collection.js +12 -15
- package/collections/monitor-memory.collection.js.map +1 -1
- package/collections/monitor-mongo.collection.js +12 -15
- package/collections/monitor-mongo.collection.js.map +1 -1
- package/collections/notification.collection.js +8 -11
- package/collections/notification.collection.js.map +1 -1
- package/collections/queue-flag.collection.js +9 -12
- package/collections/queue-flag.collection.js.map +1 -1
- package/collections/queue-method.collection.js +9 -12
- package/collections/queue-method.collection.js.map +1 -1
- package/collections/queue-response.collection.js +9 -12
- package/collections/queue-response.collection.js.map +1 -1
- package/collections/report-builder-dashboard-builder.collection.js +10 -13
- package/collections/report-builder-dashboard-builder.collection.js.map +1 -1
- package/collections/report-builder-library.collection.js +11 -14
- package/collections/report-builder-library.collection.js.map +1 -1
- package/collections/report-builder-report.collection.js +11 -14
- package/collections/report-builder-report.collection.js.map +1 -1
- package/collections/user-group.collection.js +11 -14
- package/collections/user-group.collection.js.map +1 -1
- package/collections/user-guide.collection.js +8 -11
- package/collections/user-guide.collection.js.map +1 -1
- package/collections/user.collection.js +12 -15
- package/collections/user.collection.js.map +1 -1
- package/cron/cron.js +25 -25
- package/cron/cron.js.map +1 -1
- package/fixtures/cron-jobs.js +30 -80
- package/fixtures/cron-jobs.js.map +1 -1
- package/fixtures/init.js +9 -59
- package/fixtures/init.js.map +1 -1
- package/http/auth.js +344 -460
- package/http/auth.js.map +1 -1
- package/http/health.js +1 -5
- package/http/health.js.map +1 -1
- package/http/home.js +7 -11
- package/http/home.js.map +1 -1
- package/index.js +36 -98
- package/index.js.map +1 -1
- package/managers/cron.manager.js +78 -157
- package/managers/cron.manager.js.map +1 -1
- package/managers/method.manager.js +323 -303
- package/managers/method.manager.js.map +1 -1
- package/managers/mongo.manager.d.ts +14 -14
- package/managers/mongo.manager.js +794 -865
- package/managers/mongo.manager.js.map +1 -1
- package/managers/monitor.manager.js +171 -254
- package/managers/monitor.manager.js.map +1 -1
- package/managers/queue-method.manager.js +69 -166
- package/managers/queue-method.manager.js.map +1 -1
- package/managers/subscription.manager.js +515 -708
- package/managers/subscription.manager.js.map +1 -1
- package/methods/accounts.js +111 -183
- package/methods/accounts.js.map +1 -1
- package/methods/aws.js +156 -262
- package/methods/aws.js.map +1 -1
- package/methods/cloudconvert.js +100 -180
- package/methods/cloudconvert.js.map +1 -1
- package/methods/collections.js +114 -530
- package/methods/collections.js.map +1 -1
- package/methods/counters.js +29 -79
- package/methods/counters.js.map +1 -1
- package/methods/cron-jobs.js +819 -884
- package/methods/cron-jobs.js.map +1 -1
- package/methods/flags.js +1 -5
- package/methods/flags.js.map +1 -1
- package/methods/logs.js +258 -313
- package/methods/logs.js.map +1 -1
- package/methods/monitor.js +289 -348
- package/methods/monitor.js.map +1 -1
- package/methods/pdf.js +341 -340
- package/methods/pdf.js.map +1 -1
- package/methods/report-builder.js +565 -657
- package/methods/report-builder.js.map +1 -1
- package/methods/support.js +67 -185
- package/methods/support.js.map +1 -1
- package/models/app-status.model.js +1 -2
- package/models/app-version.model.js +1 -2
- package/models/billing-logged-in-users.model.js +1 -2
- package/models/collection-document.model.js +1 -2
- package/models/counter.model.js +1 -2
- package/models/cron-job-history.model.js +1 -2
- package/models/cron-job.model.js +1 -2
- package/models/dialog.model.js +1 -2
- package/models/email-history.model.js +1 -2
- package/models/email-verified.model.js +1 -2
- package/models/file.model.js +1 -2
- package/models/flag.model.js +1 -2
- package/models/log-method-latency.model.js +1 -2
- package/models/log-subscription.model.js +1 -2
- package/models/log.model.js +1 -2
- package/models/logged-in-users.model.js +1 -2
- package/models/method-call.model.js +1 -2
- package/models/method-response.model.js +1 -2
- package/models/method.model.js +1 -2
- package/models/monitor-cpu.model.js +1 -2
- package/models/monitor-https-inbound.model.js +1 -2
- package/models/monitor-https-outbound.model.js +1 -2
- package/models/monitor-memory.model.js +1 -2
- package/models/monitor-mongo.model.js +1 -2
- package/models/notification.model.js +1 -2
- package/models/pagination.model.js +2 -5
- package/models/pagination.model.js.map +1 -1
- package/models/permission.model.js +1 -2
- package/models/queue-method.model.js +1 -2
- package/models/queue-response.model.js +1 -2
- package/models/report-builder-dashboard-builder.model.js +1 -2
- package/models/report-builder-library.model.js +1 -2
- package/models/report-builder-report.model.js +1 -2
- package/models/report-builder.model.js +1 -2
- package/models/select-data-label.model.js +1 -2
- package/models/server-response.model.js +1 -2
- package/models/subscription.model.js +1 -2
- package/models/support-ticket.model.js +1 -2
- package/models/user-group.model.js +1 -2
- package/models/user-guide.model.js +1 -2
- package/models/user.model.js +1 -2
- package/package.json +1 -1
- package/public_api.js +70 -82
- package/public_api.js.map +1 -1
- package/publications/app-status.js +4 -8
- package/publications/app-status.js.map +1 -1
- package/publications/app-version.js +4 -8
- package/publications/app-version.js.map +1 -1
- package/publications/cron-jobs.js +9 -13
- package/publications/cron-jobs.js.map +1 -1
- package/publications/files.js +11 -15
- package/publications/files.js.map +1 -1
- package/publications/flags.js +7 -11
- package/publications/flags.js.map +1 -1
- package/publications/logs.js +31 -35
- package/publications/logs.js.map +1 -1
- package/publications/method-calls.js +4 -8
- package/publications/method-calls.js.map +1 -1
- package/publications/method-responses.js +4 -8
- package/publications/method-responses.js.map +1 -1
- package/publications/notifications.js +4 -8
- package/publications/notifications.js.map +1 -1
- package/publications/report-builder-dashboard-builders.js +8 -12
- package/publications/report-builder-dashboard-builders.js.map +1 -1
- package/publications/report-builder-libraries.js +16 -66
- package/publications/report-builder-libraries.js.map +1 -1
- package/publications/report-builder-reports.js +17 -21
- package/publications/report-builder-reports.js.map +1 -1
- package/publications/super-admin.js +3 -7
- package/publications/super-admin.js.map +1 -1
- package/publications/user-groups.js +4 -8
- package/publications/user-groups.js.map +1 -1
- package/publications/user-guides.js +4 -8
- package/publications/user-guides.js.map +1 -1
- package/server-app.js +393 -534
- package/server-app.js.map +1 -1
- package/util/common.js +55 -92
- package/util/common.js.map +1 -1
- package/util/schema-report-builder.js +76 -134
- package/util/schema-report-builder.js.map +1 -1
|
@@ -1,78 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
39
|
-
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
40
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
41
|
-
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
42
|
-
r[k] = a[j];
|
|
43
|
-
return r;
|
|
44
|
-
};
|
|
45
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
-
exports.MethodManager = void 0;
|
|
47
|
-
var collections_1 = require("../methods/collections");
|
|
48
|
-
var logs_1 = require("../methods/logs");
|
|
49
|
-
var counters_1 = require("../methods/counters");
|
|
50
|
-
var pdf_1 = require("../methods/pdf");
|
|
51
|
-
var aws_1 = require("../methods/aws");
|
|
52
|
-
var cloudconvert_1 = require("../methods/cloudconvert");
|
|
53
|
-
var path = require("path");
|
|
54
|
-
var fs = require("fs");
|
|
55
|
-
var nodemailer = require("nodemailer");
|
|
56
|
-
var aws = require("aws-sdk");
|
|
57
|
-
var accounts_1 = require("../methods/accounts");
|
|
58
|
-
var init_1 = require("../fixtures/init");
|
|
59
|
-
var cron_jobs_1 = require("../fixtures/cron-jobs");
|
|
60
|
-
var cron_jobs_2 = require("../methods/cron-jobs");
|
|
61
|
-
var flags_1 = require("../methods/flags");
|
|
62
|
-
var method_response_collection_1 = require("../collections/method-response.collection");
|
|
63
|
-
var common_1 = require("../util/common");
|
|
64
|
-
var log_collection_1 = require("../collections/log.collection");
|
|
65
|
-
var log_method_latency_collection_1 = require("../collections/log-method-latency.collection");
|
|
66
|
-
var moment = require("moment");
|
|
67
|
-
var report_builder_1 = require("../methods/report-builder");
|
|
68
|
-
var support_1 = require("../methods/support");
|
|
69
|
-
var monitor_1 = require("../methods/monitor");
|
|
70
|
-
var email_history_collection_1 = require("../collections/email-history.collection");
|
|
71
|
-
var mongo_manager_1 = require("./mongo.manager");
|
|
72
|
-
var Verifier = require('email-verifier');
|
|
73
|
-
var MethodManager = /** @class */ (function () {
|
|
74
|
-
function MethodManager(mainServer, serverConfig, clientDir) {
|
|
75
|
-
var _this = this;
|
|
1
|
+
import { loadCollectionMethods } from '../methods/collections';
|
|
2
|
+
import { loadLogMethods } from '../methods/logs';
|
|
3
|
+
import { loadCounterMethods } from '../methods/counters';
|
|
4
|
+
import { loadPDFMethods } from '../methods/pdf';
|
|
5
|
+
import { loadAWSMethods } from '../methods/aws';
|
|
6
|
+
import { loadCloudConvertMethods } from '../methods/cloudconvert';
|
|
7
|
+
import * as path from 'path';
|
|
8
|
+
import * as fs from 'fs';
|
|
9
|
+
import * as nodemailer from 'nodemailer';
|
|
10
|
+
import * as aws from 'aws-sdk';
|
|
11
|
+
import { loadAccountMethods } from '../methods/accounts';
|
|
12
|
+
import { loadServerInit } from '../fixtures/init';
|
|
13
|
+
import { loadServerCronJobs } from '../fixtures/cron-jobs';
|
|
14
|
+
import { loadCronJobMethods } from '../methods/cron-jobs';
|
|
15
|
+
import { loadFlagMethods } from '../methods/flags';
|
|
16
|
+
import { MethodResponses } from '../collections/method-response.collection';
|
|
17
|
+
import { deepCopy, getBinarySize } from '../util/common';
|
|
18
|
+
import { Logs } from '../collections/log.collection';
|
|
19
|
+
import { LogMethodLatencies } from '../collections/log-method-latency.collection';
|
|
20
|
+
import * as moment from 'moment';
|
|
21
|
+
import { loadReportBuilderMethods } from '../methods/report-builder';
|
|
22
|
+
import { loadSupportMethods } from '../methods/support';
|
|
23
|
+
import { loadMonitorMethods } from '../methods/monitor';
|
|
24
|
+
import { EmailHistories } from '../collections/email-history.collection';
|
|
25
|
+
import { objectIdHexString } from './mongo.manager';
|
|
26
|
+
const Verifier = require('email-verifier');
|
|
27
|
+
export class MethodManager {
|
|
28
|
+
constructor(mainServer, serverConfig, clientDir) {
|
|
76
29
|
this._methods = {};
|
|
77
30
|
this._sendQueue = [];
|
|
78
31
|
this._runningQueue = false;
|
|
@@ -80,21 +33,21 @@ var MethodManager = /** @class */ (function () {
|
|
|
80
33
|
this.serverConfig = serverConfig;
|
|
81
34
|
this.clientDir = clientDir;
|
|
82
35
|
// Fixtures
|
|
83
|
-
|
|
84
|
-
|
|
36
|
+
loadServerInit();
|
|
37
|
+
loadServerCronJobs();
|
|
85
38
|
// Methods
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
39
|
+
loadAccountMethods(this);
|
|
40
|
+
loadAWSMethods(this);
|
|
41
|
+
loadCloudConvertMethods(this);
|
|
42
|
+
loadCollectionMethods(this);
|
|
43
|
+
loadCounterMethods(this);
|
|
44
|
+
loadLogMethods(this);
|
|
45
|
+
loadPDFMethods(this);
|
|
46
|
+
loadCronJobMethods(this);
|
|
47
|
+
loadFlagMethods(this);
|
|
48
|
+
loadReportBuilderMethods(this);
|
|
49
|
+
loadSupportMethods(this);
|
|
50
|
+
loadMonitorMethods(this);
|
|
98
51
|
if (mainServer.sesMail) {
|
|
99
52
|
this._mailer = nodemailer.createTransport({
|
|
100
53
|
SES: new aws.SES({
|
|
@@ -218,28 +171,28 @@ var MethodManager = /** @class */ (function () {
|
|
|
218
171
|
secretAccessKey: serverConfig.AWSSECRETACCESSKEY,
|
|
219
172
|
region: serverConfig.AWSREGION
|
|
220
173
|
});
|
|
221
|
-
setInterval(
|
|
222
|
-
if (!
|
|
223
|
-
if (
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
174
|
+
setInterval(() => {
|
|
175
|
+
if (!this._runningQueue) {
|
|
176
|
+
if (this._sendQueue.length) {
|
|
177
|
+
this._runningQueue = true;
|
|
178
|
+
for (let i = this._sendQueue.length - 1; i >= 0; i--) {
|
|
179
|
+
let ws = this._mainServer.getWS(this._sendQueue[i].id_ws);
|
|
227
180
|
if (ws && ws.readyState === ws.OPEN) {
|
|
228
181
|
if (ws.bufferedAmount < 20480) {
|
|
229
|
-
|
|
230
|
-
ws.send(JSON.stringify(sendItem.data),
|
|
182
|
+
let sendItem = this._sendQueue.pop();
|
|
183
|
+
ws.send(JSON.stringify(sendItem.data), (error) => {
|
|
231
184
|
if (error) {
|
|
232
185
|
console.log('Error on WS: ', error);
|
|
233
|
-
|
|
186
|
+
this._mainServer.unsubscribeWS(ws);
|
|
234
187
|
}
|
|
235
188
|
});
|
|
236
189
|
if (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') {
|
|
237
|
-
|
|
238
|
-
_id:
|
|
190
|
+
Logs.create({
|
|
191
|
+
_id: objectIdHexString(),
|
|
239
192
|
type: 'client-response',
|
|
240
193
|
collection: '',
|
|
241
194
|
id_document: '',
|
|
242
|
-
payload:
|
|
195
|
+
payload: getBinarySize(JSON.stringify([sendItem.methodData, sendItem.data])) < 200000 ? JSON.stringify([sendItem.methodData, sendItem.data], null, 2) : 'Too Big',
|
|
243
196
|
method: sendItem.method,
|
|
244
197
|
id_user: ws['id_user'],
|
|
245
198
|
user: ws['user'],
|
|
@@ -247,43 +200,35 @@ var MethodManager = /** @class */ (function () {
|
|
|
247
200
|
route: ''
|
|
248
201
|
});
|
|
249
202
|
}
|
|
250
|
-
|
|
251
|
-
_id:
|
|
203
|
+
MethodResponses.create({
|
|
204
|
+
_id: objectIdHexString(),
|
|
252
205
|
__v: 0,
|
|
253
206
|
id_user: ws['id_user'],
|
|
254
207
|
message_id: sendItem.data.messageId,
|
|
255
|
-
response:
|
|
208
|
+
response: getBinarySize(JSON.stringify(sendItem.data)) < 200000 ? sendItem.data : 'Too Big',
|
|
256
209
|
method: sendItem.method,
|
|
257
210
|
date: sendItem.date
|
|
258
211
|
});
|
|
259
212
|
}
|
|
260
213
|
}
|
|
261
214
|
else {
|
|
262
|
-
|
|
215
|
+
this._sendQueue.splice(i, 1);
|
|
263
216
|
}
|
|
264
|
-
};
|
|
265
|
-
for (var i = _this._sendQueue.length - 1; i >= 0; i--) {
|
|
266
|
-
_loop_1(i);
|
|
267
217
|
}
|
|
268
|
-
|
|
218
|
+
this._runningQueue = false;
|
|
269
219
|
}
|
|
270
220
|
}
|
|
271
221
|
}, 10);
|
|
272
222
|
}
|
|
273
|
-
|
|
223
|
+
getMainServer() {
|
|
274
224
|
return this._mainServer;
|
|
275
|
-
}
|
|
225
|
+
}
|
|
276
226
|
// Add methods to private methods object
|
|
277
|
-
|
|
227
|
+
methods(method) {
|
|
278
228
|
this._methods = Object.assign(this._methods, method);
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
var methodData = [];
|
|
283
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
284
|
-
methodData[_i - 1] = arguments[_i];
|
|
285
|
-
}
|
|
286
|
-
var that = this;
|
|
229
|
+
}
|
|
230
|
+
callMethodCron(method, ...methodData) {
|
|
231
|
+
let that = this;
|
|
287
232
|
if (!that._methods[method]) {
|
|
288
233
|
console.log('No Method: ' + method);
|
|
289
234
|
that.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Method: ' + method);
|
|
@@ -301,10 +246,10 @@ var MethodManager = /** @class */ (function () {
|
|
|
301
246
|
return;
|
|
302
247
|
}
|
|
303
248
|
else {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
for (
|
|
249
|
+
let valObj = {};
|
|
250
|
+
let valKeys = Object.keys(that._methods[method].check._schema);
|
|
251
|
+
let rootKeys = valKeys.filter(a => !a.includes('.'));
|
|
252
|
+
for (let i = 0; i < methodData.length; i++) {
|
|
308
253
|
valObj[rootKeys[i]] = methodData[i];
|
|
309
254
|
}
|
|
310
255
|
try {
|
|
@@ -319,57 +264,57 @@ var MethodManager = /** @class */ (function () {
|
|
|
319
264
|
}
|
|
320
265
|
}
|
|
321
266
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
267
|
+
that._methods[method].function.call(Object.assign({}, that, MethodManager.prototype, { id_user: '', user: '', id_ws: '' }), ...methodData).catch(methodErrs => {
|
|
268
|
+
that.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'Error Detected During Method ' + method + ' - (callMethodCron)\n\nData \n' + JSON.stringify(methodData, null, 2) + '\n\nErrors\n' + JSON.stringify(methodErrs, null, 2));
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
callMethodQueue(update) {
|
|
326
272
|
// console.log('Call Method Queue', update);
|
|
327
|
-
return new Promise(
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
var that = _this;
|
|
273
|
+
return new Promise((resolve, reject) => {
|
|
274
|
+
let updateCopy = deepCopy(update);
|
|
275
|
+
let that = this;
|
|
331
276
|
if (!that._methods[update.method]) {
|
|
332
277
|
console.log('No Method: ' + update.method);
|
|
333
278
|
that.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Method: ' + update.method);
|
|
334
|
-
|
|
279
|
+
let serverRes = {
|
|
335
280
|
messageId: update.messageId,
|
|
336
281
|
hasError: true,
|
|
337
282
|
data: 'Internal Error'
|
|
338
283
|
};
|
|
339
|
-
|
|
340
|
-
|
|
284
|
+
this._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);
|
|
285
|
+
LogMethodLatencies.deleteOne({ _id: update.id_methodLatency });
|
|
341
286
|
return resolve('No Method: ' + update.method);
|
|
342
287
|
}
|
|
343
288
|
if ((update.method_data.length > 1 || update.method_data[0]) && !that._methods[update.method].skipValidation) {
|
|
344
289
|
if (!that._methods[update.method].check) {
|
|
345
290
|
console.error('No Check Function For Method ' + update.method);
|
|
346
291
|
that.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + update.method);
|
|
347
|
-
|
|
292
|
+
let serverRes = {
|
|
348
293
|
messageId: update.messageId,
|
|
349
294
|
hasError: true,
|
|
350
295
|
data: 'Internal Error'
|
|
351
296
|
};
|
|
352
|
-
|
|
353
|
-
|
|
297
|
+
this._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);
|
|
298
|
+
LogMethodLatencies.deleteOne({ _id: update.id_methodLatency });
|
|
354
299
|
return resolve('No Check Function For Method ' + update.method);
|
|
355
300
|
}
|
|
356
301
|
else if (!that._methods[update.method].check._schema) {
|
|
357
302
|
console.error('No Check Schema For Method ' + update.method);
|
|
358
303
|
that.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + update.method);
|
|
359
|
-
|
|
304
|
+
let serverRes = {
|
|
360
305
|
messageId: update.messageId,
|
|
361
306
|
hasError: true,
|
|
362
307
|
data: 'Internal Error'
|
|
363
308
|
};
|
|
364
|
-
|
|
365
|
-
|
|
309
|
+
this._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);
|
|
310
|
+
LogMethodLatencies.deleteOne({ _id: update.id_methodLatency });
|
|
366
311
|
return resolve('No Check Schema For Method ' + update.method);
|
|
367
312
|
}
|
|
368
313
|
else {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
for (
|
|
314
|
+
let valObj = {};
|
|
315
|
+
let valKeys = Object.keys(that._methods[update.method].check._schema);
|
|
316
|
+
let rootKeys = valKeys.filter(a => !a.includes('.'));
|
|
317
|
+
for (let i = 0; i < update.method_data.length; i++) {
|
|
373
318
|
valObj[rootKeys[i]] = update.method_data[i];
|
|
374
319
|
}
|
|
375
320
|
try {
|
|
@@ -379,110 +324,97 @@ var MethodManager = /** @class */ (function () {
|
|
|
379
324
|
if (errors) {
|
|
380
325
|
console.error('Error in Method Check (' + update.method + ')', errors);
|
|
381
326
|
that.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));
|
|
382
|
-
|
|
327
|
+
let serverRes = {
|
|
383
328
|
messageId: update.messageId,
|
|
384
329
|
hasError: true,
|
|
385
330
|
data: 'Internal Error'
|
|
386
331
|
};
|
|
387
|
-
|
|
388
|
-
|
|
332
|
+
this._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);
|
|
333
|
+
LogMethodLatencies.deleteOne({ _id: update.id_methodLatency });
|
|
389
334
|
return resolve('Error in Method Check (' + update.method + ')');
|
|
390
335
|
}
|
|
391
336
|
}
|
|
392
337
|
}
|
|
393
338
|
}
|
|
394
|
-
|
|
339
|
+
let timeout = setTimeout(() => {
|
|
395
340
|
console.error('Timeout on method', update);
|
|
396
|
-
|
|
341
|
+
this.callMethodInternal('insertErrorLog', 'Timeout on method: ', [update]);
|
|
397
342
|
resolve('Timeout');
|
|
398
343
|
}, 5000);
|
|
399
344
|
// console.log('Run Method', update.method);
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
}
|
|
418
|
-
resolve(serverRes);
|
|
419
|
-
return [2 /*return*/];
|
|
420
|
-
}
|
|
421
|
-
});
|
|
422
|
-
}); }, function (err) {
|
|
423
|
-
var serverRes = {
|
|
345
|
+
that._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).catch(methodErrs => {
|
|
346
|
+
that.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'Error Detected During Method ' + update.method + ' - (callMethodQueue)\n\nData \n' + JSON.stringify(update.method_data, null, 2) + '\n\nErrors\n' + JSON.stringify(methodErrs, null, 2));
|
|
347
|
+
}).then(async (res) => {
|
|
348
|
+
let serverRes = {
|
|
349
|
+
messageId: update.messageId,
|
|
350
|
+
hasError: false,
|
|
351
|
+
data: res
|
|
352
|
+
};
|
|
353
|
+
this._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);
|
|
354
|
+
clearTimeout(timeout);
|
|
355
|
+
let latency = await LogMethodLatencies.findById(update.id_methodLatency);
|
|
356
|
+
if (latency) {
|
|
357
|
+
LogMethodLatencies.updateOne({ _id: update.id_methodLatency }, { $set: { date_end: new Date(), latency_ms: moment().diff(moment(latency.date_start), 'milliseconds', true) } });
|
|
358
|
+
}
|
|
359
|
+
resolve(serverRes);
|
|
360
|
+
}, err => {
|
|
361
|
+
let serverRes = {
|
|
424
362
|
messageId: update.messageId,
|
|
425
363
|
hasError: true,
|
|
426
364
|
data: err
|
|
427
365
|
};
|
|
428
|
-
|
|
366
|
+
this._mainServer.getQueueManager().addMethodResponse(updateCopy, serverRes);
|
|
429
367
|
clearTimeout(timeout);
|
|
430
|
-
|
|
368
|
+
LogMethodLatencies.deleteOne({ _id: update.id_methodLatency });
|
|
431
369
|
resolve(serverRes);
|
|
432
370
|
});
|
|
433
371
|
});
|
|
434
|
-
}
|
|
372
|
+
}
|
|
435
373
|
// Call/run method (Emit on Socket)
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
var _this = this;
|
|
439
|
-
var methodData = [];
|
|
440
|
-
for (var _i = 5; _i < arguments.length; _i++) {
|
|
441
|
-
methodData[_i - 5] = arguments[_i];
|
|
442
|
-
}
|
|
443
|
-
var that = this;
|
|
374
|
+
callMethod(id_methodLatency, ws, messageDate, messageId, method, ...methodData) {
|
|
375
|
+
let that = this;
|
|
444
376
|
if (!that._methods[method]) {
|
|
445
377
|
console.log('No Method: ' + method);
|
|
446
378
|
that.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Method: ' + method);
|
|
447
|
-
|
|
379
|
+
let serverRes = {
|
|
448
380
|
messageId: messageId,
|
|
449
381
|
hasError: true,
|
|
450
382
|
data: 'Internal Error'
|
|
451
383
|
};
|
|
452
384
|
this.sendWS(ws, messageDate, method, methodData, serverRes);
|
|
453
|
-
|
|
385
|
+
LogMethodLatencies.deleteOne({ _id: id_methodLatency });
|
|
454
386
|
return;
|
|
455
387
|
}
|
|
456
388
|
if ((methodData.length > 1 || methodData[0]) && !that._methods[method].skipValidation) {
|
|
457
389
|
if (!that._methods[method].check) {
|
|
458
390
|
console.error('No Check Function For Method ' + method);
|
|
459
391
|
that.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + method);
|
|
460
|
-
|
|
392
|
+
let serverRes = {
|
|
461
393
|
messageId: messageId,
|
|
462
394
|
hasError: true,
|
|
463
395
|
data: 'Internal Error'
|
|
464
396
|
};
|
|
465
397
|
this.sendWS(ws, messageDate, method, methodData, serverRes);
|
|
466
|
-
|
|
398
|
+
LogMethodLatencies.deleteOne({ _id: id_methodLatency });
|
|
467
399
|
return;
|
|
468
400
|
}
|
|
469
401
|
else if (!that._methods[method].check._schema) {
|
|
470
402
|
console.error('No Check Schema For Method ' + method);
|
|
471
403
|
that.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'No Check Function For Method ' + method);
|
|
472
|
-
|
|
404
|
+
let serverRes = {
|
|
473
405
|
messageId: messageId,
|
|
474
406
|
hasError: true,
|
|
475
407
|
data: 'Internal Error'
|
|
476
408
|
};
|
|
477
|
-
|
|
409
|
+
LogMethodLatencies.deleteOne({ _id: id_methodLatency });
|
|
478
410
|
this.sendWS(ws, messageDate, method, methodData, serverRes);
|
|
479
411
|
return;
|
|
480
412
|
}
|
|
481
413
|
else {
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
for (
|
|
414
|
+
let valObj = {};
|
|
415
|
+
let valKeys = Object.keys(that._methods[method].check._schema);
|
|
416
|
+
let rootKeys = valKeys.filter(a => !a.includes('.'));
|
|
417
|
+
for (let i = 0; i < methodData.length; i++) {
|
|
486
418
|
valObj[rootKeys[i]] = methodData[i];
|
|
487
419
|
}
|
|
488
420
|
try {
|
|
@@ -492,77 +424,67 @@ var MethodManager = /** @class */ (function () {
|
|
|
492
424
|
if (errors) {
|
|
493
425
|
console.error('Error in Method Check (' + method + ')', errors);
|
|
494
426
|
that.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));
|
|
495
|
-
|
|
427
|
+
let serverRes = {
|
|
496
428
|
messageId: messageId,
|
|
497
429
|
hasError: true,
|
|
498
430
|
data: 'Internal Error'
|
|
499
431
|
};
|
|
500
432
|
this.sendWS(ws, messageDate, method, methodData, serverRes);
|
|
501
|
-
|
|
433
|
+
LogMethodLatencies.deleteOne({ _id: id_methodLatency });
|
|
502
434
|
return;
|
|
503
435
|
}
|
|
504
436
|
}
|
|
505
437
|
}
|
|
506
438
|
}
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
log_method_latency_collection_1.LogMethodLatencies.updateOne({ _id: id_methodLatency }, { $set: { date_end: new Date(), latency_ms: moment().diff(moment(latency.date_start), 'milliseconds', true) } });
|
|
523
|
-
}
|
|
524
|
-
return [2 /*return*/];
|
|
525
|
-
}
|
|
526
|
-
});
|
|
527
|
-
}); }, function (err) {
|
|
528
|
-
var serverRes = {
|
|
439
|
+
that._methods[method].function.call(Object.assign({}, that, MethodManager.prototype, { id_user: ws['id_user'], user: ws['user'], id_ws: ws['id_socket'] }), ...methodData).catch(methodErrs => {
|
|
440
|
+
that.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'Error Detected During Method ' + method + ' - (callMethod)\n\nData \n' + JSON.stringify(methodData, null, 2) + '\n\nErrors\n' + JSON.stringify(methodErrs, null, 2));
|
|
441
|
+
}).then(async (res) => {
|
|
442
|
+
let serverRes = {
|
|
443
|
+
messageId: messageId,
|
|
444
|
+
hasError: false,
|
|
445
|
+
data: res
|
|
446
|
+
};
|
|
447
|
+
this.sendWS(ws, messageDate, method, methodData, serverRes);
|
|
448
|
+
let latency = await LogMethodLatencies.findById(id_methodLatency);
|
|
449
|
+
if (latency) {
|
|
450
|
+
LogMethodLatencies.updateOne({ _id: id_methodLatency }, { $set: { date_end: new Date(), latency_ms: moment().diff(moment(latency.date_start), 'milliseconds', true) } });
|
|
451
|
+
}
|
|
452
|
+
}, err => {
|
|
453
|
+
let serverRes = {
|
|
529
454
|
messageId: messageId,
|
|
530
455
|
hasError: true,
|
|
531
456
|
data: err
|
|
532
457
|
};
|
|
533
|
-
|
|
534
|
-
|
|
458
|
+
this.sendWS(ws, messageDate, method, methodData, serverRes);
|
|
459
|
+
LogMethodLatencies.deleteOne({ _id: id_methodLatency });
|
|
535
460
|
});
|
|
536
|
-
}
|
|
461
|
+
}
|
|
537
462
|
// Call/run method internal (No Emit on Socket)
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
var methodData = [];
|
|
541
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
542
|
-
methodData[_i - 1] = arguments[_i];
|
|
543
|
-
}
|
|
544
|
-
var that = this;
|
|
463
|
+
callMethodInternal(method, ...methodData) {
|
|
464
|
+
let that = this;
|
|
545
465
|
if (!that._methods[method]) {
|
|
546
466
|
console.log('No Method: ' + method);
|
|
547
|
-
return;
|
|
467
|
+
return null;
|
|
548
468
|
}
|
|
549
469
|
if ((methodData.length > 1 || (methodData[0] && typeof (methodData[0]) !== 'function')) && !that._methods[method].skipValidation) {
|
|
550
470
|
if (!that._methods[method].check) {
|
|
551
471
|
console.error('No Check Function For Method ' + method);
|
|
552
|
-
return;
|
|
472
|
+
return null;
|
|
553
473
|
}
|
|
554
474
|
else if (!that._methods[method].check._schema) {
|
|
555
475
|
console.error('No Check Schema For Method ' + method);
|
|
556
|
-
return;
|
|
476
|
+
return null;
|
|
557
477
|
}
|
|
558
478
|
}
|
|
559
|
-
|
|
479
|
+
let promise = that._methods[method].function.call(Object.assign({}, that, MethodManager.prototype), ...methodData).catch(methodErrs => {
|
|
480
|
+
that.sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + that.serverConfig['CLIENT_NAME'], 'Error Detected During Method ' + method + ' - (callMethodInternal)\n\nData \n' + JSON.stringify(methodData, null, 2) + '\n\nErrors\n' + JSON.stringify(methodErrs, null, 2));
|
|
481
|
+
});
|
|
560
482
|
if (methodData[methodData.length - 1] && typeof (methodData[methodData.length - 1]) === 'function') {
|
|
561
|
-
promise.then(
|
|
483
|
+
promise.then(res => methodData[methodData.length - 1](null, res), err => methodData[methodData.length - 1](err, null));
|
|
562
484
|
}
|
|
563
485
|
return promise;
|
|
564
|
-
}
|
|
565
|
-
|
|
486
|
+
}
|
|
487
|
+
sendWS(ws, messageDate, method, methodData, data) {
|
|
566
488
|
this._sendQueue.splice(0, 0, {
|
|
567
489
|
id_ws: ws['id_socket'],
|
|
568
490
|
method: method,
|
|
@@ -570,64 +492,165 @@ var MethodManager = /** @class */ (function () {
|
|
|
570
492
|
data: data,
|
|
571
493
|
date: messageDate
|
|
572
494
|
});
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
495
|
+
}
|
|
496
|
+
sendEmail(sendTo, subject, text, html, attachments, send_from) {
|
|
497
|
+
return new Promise(async (resolve, reject) => {
|
|
498
|
+
if ((this.serverConfig['ROOT_URL'].match(new RegExp(/https\:\/\/dev\./)) || this.serverConfig['ROOT_URL'].match(new RegExp(/https\:\/\/www\.dev\./)) || this.serverConfig['ROOT_URL'] === 'http://localhost:4200') && !sendTo.match(new RegExp(/\@resolveio\.com/))) {
|
|
499
|
+
sendTo = 'dev@resolveio.com';
|
|
500
|
+
}
|
|
501
|
+
// if (this.serverConfig['ROOT_URL'].match(new RegExp(/https\:\/\/dev\./)) || this.serverConfig['ROOT_URL'].match(new RegExp(/https\:\/\/www\.dev\./)) || this.serverConfig['ROOT_URL'] === 'http://localhost:4200' || sendTo.endsWith('@resolveio.com')) {
|
|
502
|
+
this._mailer.sendMail({
|
|
503
|
+
replyTo: undefined,
|
|
504
|
+
from: send_from ? send_from : this.serverConfig.MAIL_FROM,
|
|
505
|
+
to: sendTo,
|
|
506
|
+
subject: (this.serverConfig['ROOT_URL'].match(new RegExp(/https\:\/\/dev\./)) || this.serverConfig['ROOT_URL'].match(new RegExp(/https\:\/\/www\.dev\./)) ? '(DEV SERVER) - ' : '') + subject,
|
|
507
|
+
text: text,
|
|
508
|
+
html: html,
|
|
509
|
+
attachments: attachments
|
|
510
|
+
}, (err, info) => {
|
|
511
|
+
if (err) {
|
|
512
|
+
console.log(err);
|
|
513
|
+
EmailHistories.create({
|
|
514
|
+
_id: objectIdHexString(),
|
|
515
|
+
__v: 0,
|
|
516
|
+
date: new Date(),
|
|
517
|
+
id_user: this['id_user'],
|
|
518
|
+
user: this['user'],
|
|
519
|
+
email: sendTo,
|
|
520
|
+
success: false,
|
|
521
|
+
verified: false
|
|
522
|
+
});
|
|
581
523
|
}
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
_id: mongo_manager_1.objectIdHexString(),
|
|
596
|
-
__v: 0,
|
|
597
|
-
date: new Date(),
|
|
598
|
-
id_user: _this['id_user'],
|
|
599
|
-
user: _this['user'],
|
|
600
|
-
email: sendTo,
|
|
601
|
-
success: false,
|
|
602
|
-
verified: false
|
|
603
|
-
});
|
|
604
|
-
}
|
|
605
|
-
else {
|
|
606
|
-
email_history_collection_1.EmailHistories.create({
|
|
607
|
-
_id: mongo_manager_1.objectIdHexString(),
|
|
608
|
-
__v: 0,
|
|
609
|
-
date: new Date(),
|
|
610
|
-
id_user: _this['id_user'],
|
|
611
|
-
user: _this['user'],
|
|
612
|
-
email: sendTo,
|
|
613
|
-
success: true,
|
|
614
|
-
verified: false
|
|
615
|
-
});
|
|
616
|
-
}
|
|
617
|
-
resolve();
|
|
618
|
-
});
|
|
619
|
-
return [2 /*return*/];
|
|
524
|
+
else {
|
|
525
|
+
EmailHistories.create({
|
|
526
|
+
_id: objectIdHexString(),
|
|
527
|
+
__v: 0,
|
|
528
|
+
date: new Date(),
|
|
529
|
+
id_user: this['id_user'],
|
|
530
|
+
user: this['user'],
|
|
531
|
+
email: sendTo,
|
|
532
|
+
success: true,
|
|
533
|
+
verified: false
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
resolve();
|
|
620
537
|
});
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
538
|
+
// }
|
|
539
|
+
// else {
|
|
540
|
+
// let oldVerfication = await EmailVerifies.findOne({email: sendTo});
|
|
541
|
+
// if (oldVerfication) {
|
|
542
|
+
// this._mailer.sendMail({
|
|
543
|
+
// replyTo: undefined,
|
|
544
|
+
// from: send_from ? send_from : this.serverConfig.MAIL_FROM,
|
|
545
|
+
// to: sendTo,
|
|
546
|
+
// subject: (this.serverConfig['ROOT_URL'].match(new RegExp(/https\:\/\/dev\./)) ? '(DEV SERVER) - ' : '') + subject,
|
|
547
|
+
// text: text,
|
|
548
|
+
// html: html,
|
|
549
|
+
// attachments: attachments
|
|
550
|
+
// }, (err, info) => {
|
|
551
|
+
// if (err) {
|
|
552
|
+
// console.log(err);
|
|
553
|
+
// EmailHistories.create({
|
|
554
|
+
// _id: objectIdHexString(),
|
|
555
|
+
// __v: 0,
|
|
556
|
+
// date: new Date(),
|
|
557
|
+
// id_user: this['id_user'],
|
|
558
|
+
// user: this['user'],
|
|
559
|
+
// email: sendTo,
|
|
560
|
+
// success: false,
|
|
561
|
+
// verified: true
|
|
562
|
+
// });
|
|
563
|
+
// }
|
|
564
|
+
// else {
|
|
565
|
+
// EmailHistories.create({
|
|
566
|
+
// _id: objectIdHexString(),
|
|
567
|
+
// __v: 0,
|
|
568
|
+
// date: new Date(),
|
|
569
|
+
// id_user: this['id_user'],
|
|
570
|
+
// user: this['user'],
|
|
571
|
+
// email: sendTo,
|
|
572
|
+
// success: true,
|
|
573
|
+
// verified: true
|
|
574
|
+
// });
|
|
575
|
+
// }
|
|
576
|
+
// resolve();
|
|
577
|
+
// });
|
|
578
|
+
// }
|
|
579
|
+
// else {
|
|
580
|
+
// let verifier = new Verifier(this.serverConfig['WHOISXMLAPI']);
|
|
581
|
+
// verifier.verify(sendTo, {hardRefresh: true}, (errVerify, resVerify) => {
|
|
582
|
+
// if (errVerify) {
|
|
583
|
+
// console.log(errVerify);
|
|
584
|
+
// EmailHistories.create({
|
|
585
|
+
// _id: objectIdHexString(),
|
|
586
|
+
// __v: 0,
|
|
587
|
+
// date: new Date(),
|
|
588
|
+
// id_user: this['id_user'],
|
|
589
|
+
// user: this['user'],
|
|
590
|
+
// email: sendTo,
|
|
591
|
+
// success: false,
|
|
592
|
+
// verified: false
|
|
593
|
+
// });
|
|
594
|
+
// resolve();
|
|
595
|
+
// }
|
|
596
|
+
// else {
|
|
597
|
+
// EmailVerifies.create({
|
|
598
|
+
// _id: objectIdHexString(),
|
|
599
|
+
// __v: 0,
|
|
600
|
+
// date: new Date(),
|
|
601
|
+
// id_user: this['id_user'],
|
|
602
|
+
// user: this['user'],
|
|
603
|
+
// email: sendTo
|
|
604
|
+
// });
|
|
605
|
+
// this._mailer.sendMail({
|
|
606
|
+
// replyTo: undefined,
|
|
607
|
+
// from: send_from ? send_from : this.serverConfig.MAIL_FROM,
|
|
608
|
+
// to: sendTo,
|
|
609
|
+
// subject: (this.serverConfig['ROOT_URL'].match(new RegExp(/https\:\/\/dev\./)) ? '(DEV SERVER) - ' : '') + subject,
|
|
610
|
+
// text: text,
|
|
611
|
+
// html: html,
|
|
612
|
+
// attachments: attachments
|
|
613
|
+
// }, (err, info) => {
|
|
614
|
+
// if (err) {
|
|
615
|
+
// console.log(err);
|
|
616
|
+
// EmailHistories.create({
|
|
617
|
+
// _id: objectIdHexString(),
|
|
618
|
+
// __v: 0,
|
|
619
|
+
// date: new Date(),
|
|
620
|
+
// id_user: this['id_user'],
|
|
621
|
+
// user: this['user'],
|
|
622
|
+
// email: sendTo,
|
|
623
|
+
// success: false,
|
|
624
|
+
// verified: true
|
|
625
|
+
// });
|
|
626
|
+
// }
|
|
627
|
+
// else {
|
|
628
|
+
// EmailHistories.create({
|
|
629
|
+
// _id: objectIdHexString(),
|
|
630
|
+
// __v: 0,
|
|
631
|
+
// date: new Date(),
|
|
632
|
+
// id_user: this['id_user'],
|
|
633
|
+
// user: this['user'],
|
|
634
|
+
// email: sendTo,
|
|
635
|
+
// success: true,
|
|
636
|
+
// verified: true
|
|
637
|
+
// });
|
|
638
|
+
// }
|
|
639
|
+
// resolve();
|
|
640
|
+
// });
|
|
641
|
+
// }
|
|
642
|
+
// });
|
|
643
|
+
// }
|
|
644
|
+
// }
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
getAWS() {
|
|
624
648
|
return this._aws;
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
return new Promise(function (resolve, reject) {
|
|
649
|
+
}
|
|
650
|
+
readFile(fileName) {
|
|
651
|
+
return new Promise((resolve, reject) => {
|
|
629
652
|
if (fs.existsSync(path.join(__dirname, ('../private/' + fileName)))) {
|
|
630
|
-
fs.readFile(path.join(__dirname, ('../private/' + fileName)), 'utf-8',
|
|
653
|
+
fs.readFile(path.join(__dirname, ('../private/' + fileName)), 'utf-8', (err, res) => {
|
|
631
654
|
if (err) {
|
|
632
655
|
reject(err);
|
|
633
656
|
}
|
|
@@ -637,8 +660,8 @@ var MethodManager = /** @class */ (function () {
|
|
|
637
660
|
});
|
|
638
661
|
}
|
|
639
662
|
else {
|
|
640
|
-
if (fs.existsSync(path.join(
|
|
641
|
-
fs.readFile(path.join(
|
|
663
|
+
if (fs.existsSync(path.join(this.clientDir, ('./private/' + fileName)))) {
|
|
664
|
+
fs.readFile(path.join(this.clientDir, ('./private/' + fileName)), 'utf-8', (err, res) => {
|
|
642
665
|
if (err) {
|
|
643
666
|
reject(err);
|
|
644
667
|
}
|
|
@@ -649,12 +672,11 @@ var MethodManager = /** @class */ (function () {
|
|
|
649
672
|
}
|
|
650
673
|
}
|
|
651
674
|
});
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
return new Promise(function (resolve, reject) {
|
|
675
|
+
}
|
|
676
|
+
readImage(fileName) {
|
|
677
|
+
return new Promise((resolve, reject) => {
|
|
656
678
|
if (fs.existsSync(path.join(__dirname, ('../private/' + fileName)))) {
|
|
657
|
-
fs.readFile(path.join(__dirname, ('../private/' + fileName)), 'base64',
|
|
679
|
+
fs.readFile(path.join(__dirname, ('../private/' + fileName)), 'base64', (err, res) => {
|
|
658
680
|
if (err) {
|
|
659
681
|
reject(err);
|
|
660
682
|
}
|
|
@@ -664,8 +686,8 @@ var MethodManager = /** @class */ (function () {
|
|
|
664
686
|
});
|
|
665
687
|
}
|
|
666
688
|
else {
|
|
667
|
-
if (fs.existsSync(path.join(
|
|
668
|
-
fs.readFile(path.join(
|
|
689
|
+
if (fs.existsSync(path.join(this.clientDir, ('./private/' + fileName)))) {
|
|
690
|
+
fs.readFile(path.join(this.clientDir, ('./private/' + fileName)), 'base64', (err, res) => {
|
|
669
691
|
if (err) {
|
|
670
692
|
reject(err);
|
|
671
693
|
}
|
|
@@ -676,9 +698,7 @@ var MethodManager = /** @class */ (function () {
|
|
|
676
698
|
}
|
|
677
699
|
}
|
|
678
700
|
});
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
}());
|
|
682
|
-
exports.MethodManager = MethodManager;
|
|
701
|
+
}
|
|
702
|
+
}
|
|
683
703
|
|
|
684
704
|
//# sourceMappingURL=method.manager.js.map
|