@resolveio/server-lib 1.0.20 → 1.0.22
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.
|
@@ -19,6 +19,7 @@ export declare class MethodManager {
|
|
|
19
19
|
callMethodQueue(update: QueueMethodModel): void;
|
|
20
20
|
callMethod(ws: WebSocket, messageId: any, method: any, ...methodData: any[]): void;
|
|
21
21
|
callMethodInternal(method: any, ...methodData: any[]): Promise<any>;
|
|
22
|
+
callSupportMethodInternal(supportMethod: any, ...methodData: any[]): Promise<any>;
|
|
22
23
|
private sendWS;
|
|
23
24
|
sendEmail(sendTo: string, subject: string, text?: string, html?: string, attachments?: any[]): void;
|
|
24
25
|
getAWS(): aws.S3;
|
|
@@ -20,6 +20,7 @@ var mongoose_1 = require("mongoose");
|
|
|
20
20
|
var common_1 = require("../util/common");
|
|
21
21
|
var log_collection_1 = require("../collections/log.collection");
|
|
22
22
|
var cron_jobs_3 = require("../support-methods/cron-jobs");
|
|
23
|
+
var support_manager_1 = require("./support.manager");
|
|
23
24
|
var MethodManager = /** @class */ (function () {
|
|
24
25
|
function MethodManager(mainServer, serverConfig, clientDir) {
|
|
25
26
|
var _this = this;
|
|
@@ -474,6 +475,33 @@ var MethodManager = /** @class */ (function () {
|
|
|
474
475
|
}
|
|
475
476
|
return promise;
|
|
476
477
|
};
|
|
478
|
+
MethodManager.prototype.callSupportMethodInternal = function (supportMethod) {
|
|
479
|
+
var methodData = [];
|
|
480
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
481
|
+
methodData[_i - 1] = arguments[_i];
|
|
482
|
+
}
|
|
483
|
+
var _a;
|
|
484
|
+
var that = this;
|
|
485
|
+
if (!that.getMainServer().getSupportManager()._supportMethods[supportMethod]) {
|
|
486
|
+
console.log('No Support Method: ' + supportMethod);
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
if ((methodData.length > 1 || (methodData[0] && typeof (methodData[0]) !== 'function')) && !that.getMainServer().getSupportManager()._supportMethods[supportMethod].skipValidation) {
|
|
490
|
+
if (!that.getMainServer().getSupportManager()._supportMethods[supportMethod].check) {
|
|
491
|
+
console.error('No Check Function For Method ' + supportMethod);
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
else if (!that.getMainServer().getSupportManager()._supportMethods[supportMethod].check._schema) {
|
|
495
|
+
console.error('No Check Schema For Method ' + supportMethod);
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
var promise = (_a = that.getMainServer().getSupportManager()._supportMethods[supportMethod].function).call.apply(_a, [Object.assign({}, that, support_manager_1.SupportManager.prototype)].concat(methodData));
|
|
500
|
+
if (methodData[methodData.length - 1] && typeof (methodData[methodData.length - 1]) === 'function') {
|
|
501
|
+
promise.then(function (res) { return methodData[methodData.length - 1](null, res); }, function (err) { return methodData[methodData.length - 1](err, null); });
|
|
502
|
+
}
|
|
503
|
+
return promise;
|
|
504
|
+
};
|
|
477
505
|
MethodManager.prototype.sendWS = function (ws, method, methodData, data) {
|
|
478
506
|
this._sendQueue.splice(0, 0, {
|
|
479
507
|
id_ws: ws['id_socket'],
|
package/package.json
CHANGED
|
@@ -38,8 +38,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
38
38
|
var simpl_schema_1 = require("simpl-schema");
|
|
39
39
|
var file_collection_1 = require("../collections/file.collection");
|
|
40
40
|
var handlebars = require("handlebars");
|
|
41
|
-
var user_collection_1 = require("../collections/user.collection");
|
|
42
|
-
var notification_collection_1 = require("../collections/notification.collection");
|
|
43
41
|
function loadSupportMethods(supportManager) {
|
|
44
42
|
supportManager.supportMethods({
|
|
45
43
|
sendSupportTicketEmail: {
|
|
@@ -70,51 +68,32 @@ function loadSupportMethods(supportManager) {
|
|
|
70
68
|
this.callMethodInternal.call(this, 'getSignedUrls', files.map(function (a) { return a.key; }), 900, function (err, res) {
|
|
71
69
|
if (res) {
|
|
72
70
|
_this.readFile('email-templates/support-ticket.html').then(function (html) { return __awaiter(_this, void 0, void 0, function () {
|
|
73
|
-
var template, filesAttached, fileCnt
|
|
71
|
+
var template, filesAttached, fileCnt;
|
|
74
72
|
var _this = this;
|
|
75
73
|
return __generator(this, function (_a) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
supportTicket['logo'] = 'data:image/png;base64,' + logoData;
|
|
100
|
-
users_1.forEach(function (user) {
|
|
101
|
-
supportTicket['user'] = user.fullname;
|
|
102
|
-
supportTicket['fileAttached'] = filesAttached;
|
|
103
|
-
_this.sendEmail(user.email, 'ResolveIO - ' + supportTicket.support_ticket_number_string + ' Priority: ' + supportTicket.priority, '', template(supportTicket), filesAttached);
|
|
104
|
-
});
|
|
105
|
-
if (supportTicket.client_user && supportTicket.client_user.email) {
|
|
106
|
-
supportTicket['user'] = supportTicket.client_user.user;
|
|
107
|
-
supportTicket['fileAttached'] = filesAttached;
|
|
108
|
-
_this.sendEmail(supportTicket.client_user.email, 'ResolveIO - ' + supportTicket.support_ticket_number_string + ' Priority: ' + supportTicket.priority, '', template(supportTicket), filesAttached);
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
resolve(true);
|
|
112
|
-
return [3 /*break*/, 4];
|
|
113
|
-
case 3:
|
|
114
|
-
reject('No Notification');
|
|
115
|
-
_a.label = 4;
|
|
116
|
-
case 4: return [2 /*return*/];
|
|
117
|
-
}
|
|
74
|
+
template = handlebars.compile(html);
|
|
75
|
+
handlebars.registerHelper('greaterThan', function (a, b) {
|
|
76
|
+
return a > b;
|
|
77
|
+
});
|
|
78
|
+
handlebars.registerHelper('equals', function (a, b) {
|
|
79
|
+
return a === b;
|
|
80
|
+
});
|
|
81
|
+
filesAttached = [];
|
|
82
|
+
fileCnt = 0;
|
|
83
|
+
res.forEach(function (url) {
|
|
84
|
+
filesAttached.push({ filename: files[fileCnt].name, path: url });
|
|
85
|
+
fileCnt++;
|
|
86
|
+
});
|
|
87
|
+
this.readImage('images/ResolveIO.png').then(function (logoData) {
|
|
88
|
+
supportTicket['logo'] = 'data:image/png;base64,' + logoData;
|
|
89
|
+
if (supportTicket.client_user && supportTicket.client_user.email) {
|
|
90
|
+
supportTicket['user'] = supportTicket.client_user.user;
|
|
91
|
+
supportTicket['fileAttached'] = filesAttached;
|
|
92
|
+
_this.sendEmail(supportTicket.client_user.email, 'ResolveIO - ' + supportTicket.support_ticket_number_string + ' Priority: ' + supportTicket.priority, '', template(supportTicket), filesAttached);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
resolve(true);
|
|
96
|
+
return [2 /*return*/];
|
|
118
97
|
});
|
|
119
98
|
}); });
|
|
120
99
|
resolve(true);
|
|
@@ -223,39 +202,19 @@ function loadSupportMethods(supportManager) {
|
|
|
223
202
|
this.callMethodInternal.call(this, 'getSignedUrls', [], 900, function (err, res) {
|
|
224
203
|
if (res) {
|
|
225
204
|
_this.readFile('email-templates/support-ticket-deleted.html').then(function (html) { return __awaiter(_this, void 0, void 0, function () {
|
|
226
|
-
var template
|
|
227
|
-
var _this = this;
|
|
205
|
+
var template;
|
|
228
206
|
return __generator(this, function (_a) {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
return [4 /*yield*/, notification_collection_1.Notifications.findOne({ name: 'Support Ticket Deleted' })];
|
|
239
|
-
case 1:
|
|
240
|
-
notification = _a.sent();
|
|
241
|
-
if (!notification) return [3 /*break*/, 3];
|
|
242
|
-
return [4 /*yield*/, user_collection_1.Users.find({ roles: 'notify-' + notification.name })];
|
|
243
|
-
case 2:
|
|
244
|
-
users = _a.sent();
|
|
245
|
-
users.forEach(function (user) {
|
|
246
|
-
_this.sendEmail(user.email, 'ResolveIO - a ticket has been deleted: ' + supportTicket.support_ticket_number_string, '', template(null), []);
|
|
247
|
-
});
|
|
248
|
-
resolve(true);
|
|
249
|
-
return [3 /*break*/, 4];
|
|
250
|
-
case 3:
|
|
251
|
-
reject('No Notification');
|
|
252
|
-
_a.label = 4;
|
|
253
|
-
case 4:
|
|
254
|
-
if (supportTicket.client_user && supportTicket.client_user.email) {
|
|
255
|
-
this.sendEmail(supportTicket.client_user.email, 'ResolveIO - ' + supportTicket.support_ticket_number_string + ' Priority: ' + supportTicket.priority, '', template(supportTicket), []);
|
|
256
|
-
}
|
|
257
|
-
return [2 /*return*/];
|
|
207
|
+
template = handlebars.compile(html);
|
|
208
|
+
handlebars.registerHelper('greaterThan', function (a, b) {
|
|
209
|
+
return a > b;
|
|
210
|
+
});
|
|
211
|
+
handlebars.registerHelper('equals', function (a, b) {
|
|
212
|
+
return a === b;
|
|
213
|
+
});
|
|
214
|
+
if (supportTicket.client_user && supportTicket.client_user.email) {
|
|
215
|
+
this.sendEmail(supportTicket.client_user.email, 'ResolveIO - ' + supportTicket.support_ticket_number_string + ' Priority: ' + supportTicket.priority, '', template(supportTicket), []);
|
|
258
216
|
}
|
|
217
|
+
return [2 /*return*/];
|
|
259
218
|
});
|
|
260
219
|
}); });
|
|
261
220
|
resolve(true);
|