@resolveio/server-lib 6.4.23 → 7.0.1
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/collections/counter.collection.d.ts +0 -2
- package/collections/counter.collection.js +0 -14
- package/collections/counter.collection.js.map +1 -1
- package/collections/file.collection.d.ts +0 -2
- package/collections/file.collection.js +0 -14
- package/collections/file.collection.js.map +1 -1
- package/collections/user.collection.d.ts +0 -1
- package/collections/user.collection.js +0 -4
- package/collections/user.collection.js.map +1 -1
- package/fixtures/cron-jobs.js +0 -17
- package/fixtures/cron-jobs.js.map +1 -1
- package/http/auth.js +176 -20
- package/http/auth.js.map +1 -1
- package/http/home.js +37 -0
- package/http/home.js.map +1 -1
- package/index.d.ts +1 -4
- package/index.js +22 -71
- package/index.js.map +1 -1
- package/managers/method.manager.d.ts +0 -1
- package/managers/method.manager.js +2 -28
- package/managers/method.manager.js.map +1 -1
- package/managers/subscription.manager.d.ts +0 -3
- package/managers/subscription.manager.js +19 -142
- package/managers/subscription.manager.js.map +1 -1
- package/methods/cron-jobs.js +0 -68
- package/methods/cron-jobs.js.map +1 -1
- package/methods/support.d.ts +2 -0
- package/methods/support.js +439 -0
- package/methods/support.js.map +1 -0
- package/package.json +1 -1
- package/publications/files.js +0 -31
- package/publications/files.js.map +1 -1
- package/server-app.d.ts +0 -4
- package/server-app.js +11 -71
- package/server-app.js.map +1 -1
- package/client-server-app.d.ts +0 -1
- package/client-server-app.js +0 -48
- package/client-server-app.js.map +0 -1
- package/collections/billing-logged-in-users.collection.d.ts +0 -7
- package/collections/billing-logged-in-users.collection.js +0 -75
- package/collections/billing-logged-in-users.collection.js.map +0 -1
- package/collections/support-ticket.collection.d.ts +0 -7
- package/collections/support-ticket.collection.js +0 -226
- package/collections/support-ticket.collection.js.map +0 -1
- package/managers/support.manager.d.ts +0 -22
- package/managers/support.manager.js +0 -329
- package/managers/support.manager.js.map +0 -1
- package/models/support-method.model.d.ts +0 -9
- package/models/support-method.model.js +0 -4
- package/models/support-method.model.js.map +0 -1
- package/publications/billing-logged-in-users.d.ts +0 -1
- package/publications/billing-logged-in-users.js +0 -65
- package/publications/billing-logged-in-users.js.map +0 -1
- package/publications/support-tickets.d.ts +0 -1
- package/publications/support-tickets.js +0 -203
- package/publications/support-tickets.js.map +0 -1
- package/support-methods/aws.d.ts +0 -2
- package/support-methods/aws.js +0 -279
- package/support-methods/aws.js.map +0 -1
- package/support-methods/collections.d.ts +0 -2
- package/support-methods/collections.js +0 -475
- package/support-methods/collections.js.map +0 -1
- package/support-methods/counters.d.ts +0 -2
- package/support-methods/counters.js +0 -192
- package/support-methods/counters.js.map +0 -1
- package/support-methods/support.d.ts +0 -2
- package/support-methods/support.js +0 -282
- package/support-methods/support.js.map +0 -1
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
var mongoose_1 = require("mongoose");
|
|
40
|
-
var counter_collection_1 = require("../collections/counter.collection");
|
|
41
|
-
var simpl_schema_1 = require("simpl-schema");
|
|
42
|
-
var __1 = require("..");
|
|
43
|
-
function loadCounterMethods(supportManager) {
|
|
44
|
-
supportManager.supportMethods({
|
|
45
|
-
incCounter: {
|
|
46
|
-
check: new simpl_schema_1.default({
|
|
47
|
-
counterType: {
|
|
48
|
-
type: String
|
|
49
|
-
}
|
|
50
|
-
}),
|
|
51
|
-
function: function (counterType) {
|
|
52
|
-
var _this = this;
|
|
53
|
-
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
54
|
-
var counter, newCount;
|
|
55
|
-
return __generator(this, function (_a) {
|
|
56
|
-
switch (_a.label) {
|
|
57
|
-
case 0: return [4 /*yield*/, counter_collection_1.SupportCounters.findOne({ type: counterType })];
|
|
58
|
-
case 1:
|
|
59
|
-
counter = _a.sent();
|
|
60
|
-
if (!!counter) return [3 /*break*/, 2];
|
|
61
|
-
counter_collection_1.SupportCounters.create({
|
|
62
|
-
_id: mongoose_1.Types.ObjectId().toHexString(),
|
|
63
|
-
count: 2,
|
|
64
|
-
type: counterType
|
|
65
|
-
});
|
|
66
|
-
resolve(1);
|
|
67
|
-
return [3 /*break*/, 4];
|
|
68
|
-
case 2: return [4 /*yield*/, counter_collection_1.SupportCounters.findOneAndUpdate({ type: counterType }, { $inc: { count: 1 } }).exec()];
|
|
69
|
-
case 3:
|
|
70
|
-
newCount = _a.sent();
|
|
71
|
-
resolve(newCount.count);
|
|
72
|
-
_a.label = 4;
|
|
73
|
-
case 4: return [2 /*return*/];
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}); });
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
countCollectionWithQuery: {
|
|
80
|
-
check: new simpl_schema_1.default({
|
|
81
|
-
collectionType: {
|
|
82
|
-
type: String
|
|
83
|
-
},
|
|
84
|
-
query: {
|
|
85
|
-
type: Object,
|
|
86
|
-
blackbox: true
|
|
87
|
-
}
|
|
88
|
-
}),
|
|
89
|
-
function: function (collectionType, query) {
|
|
90
|
-
return __1.ResolveIOServer.getSupportDB().model(collectionType).collection.countDocuments(query);
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
countQuery: {
|
|
94
|
-
check: new simpl_schema_1.default({
|
|
95
|
-
collectionType: {
|
|
96
|
-
type: String
|
|
97
|
-
},
|
|
98
|
-
search: {
|
|
99
|
-
type: String,
|
|
100
|
-
optional: true
|
|
101
|
-
},
|
|
102
|
-
filters: simpl_schema_1.default.oneOf({
|
|
103
|
-
type: Array,
|
|
104
|
-
optional: true
|
|
105
|
-
}, {
|
|
106
|
-
type: Object,
|
|
107
|
-
blackbox: true,
|
|
108
|
-
optional: true
|
|
109
|
-
}),
|
|
110
|
-
'filters.$': {
|
|
111
|
-
type: Object,
|
|
112
|
-
optional: true,
|
|
113
|
-
blackbox: true
|
|
114
|
-
},
|
|
115
|
-
subType: {
|
|
116
|
-
type: String,
|
|
117
|
-
optional: true
|
|
118
|
-
}
|
|
119
|
-
}),
|
|
120
|
-
function: function (collectionType, search, filters) {
|
|
121
|
-
if (search === void 0) { search = ''; }
|
|
122
|
-
if (filters === void 0) { filters = []; }
|
|
123
|
-
var query = {};
|
|
124
|
-
if (!search && (!filters || !filters.length)) {
|
|
125
|
-
query = {};
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
if (filters && filters.length) {
|
|
129
|
-
query['$and'] = [];
|
|
130
|
-
filters.forEach(function (filter) {
|
|
131
|
-
var _a;
|
|
132
|
-
query['$and'].push((_a = {}, _a[filter['prop']] = filter['data'], _a));
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
if (search && collectionType === 'support-tickets') {
|
|
136
|
-
var searchRegEx = { '$regex': '.*' + (search || '') + '.*', '$options': 'i' };
|
|
137
|
-
if (query['$and']) {
|
|
138
|
-
query['$and'].push({
|
|
139
|
-
$or: [
|
|
140
|
-
{
|
|
141
|
-
support_ticket_number_string: searchRegEx
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
date_created_string: searchRegEx
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
status: searchRegEx
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
user_created: searchRegEx
|
|
151
|
-
}
|
|
152
|
-
]
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
query = {
|
|
157
|
-
$or: [
|
|
158
|
-
{
|
|
159
|
-
support_ticket_number_string: searchRegEx
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
date_created_string: searchRegEx
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
status: searchRegEx
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
user_created: searchRegEx
|
|
169
|
-
}
|
|
170
|
-
]
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
return __1.ResolveIOServer.getSupportDB().model(collectionType).collection.countDocuments(query);
|
|
176
|
-
}
|
|
177
|
-
},
|
|
178
|
-
countCollection: {
|
|
179
|
-
check: new simpl_schema_1.default({
|
|
180
|
-
collectionType: {
|
|
181
|
-
type: String
|
|
182
|
-
}
|
|
183
|
-
}),
|
|
184
|
-
function: function (collectionType) {
|
|
185
|
-
return __1.ResolveIOServer.getSupportDB().model(collectionType).collection.countDocuments();
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
exports.loadCounterMethods = loadCounterMethods;
|
|
191
|
-
|
|
192
|
-
//# sourceMappingURL=counters.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/support-methods/counters.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAiC;AACjC,wEAAoE;AACpE,6CAAwC;AAExC,wBAAqC;AAErC,SAAgB,kBAAkB,CAAC,cAA8B;IAChE,cAAc,CAAC,cAAc,CAAC;QAC7B,UAAU,EAAE;YACX,KAAK,EAAE,IAAI,sBAAY,CAAC;gBACvB,WAAW,EAAE;oBACZ,IAAI,EAAE,MAAM;iBACZ;aACD,CAAC;YACF,QAAQ,EAAE,UAAS,WAAmB;gBAA5B,iBAmBT;gBAlBA,OAAO,IAAI,OAAO,CAAC,UAAO,OAAO,EAAE,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BAA4B,EAAE,WAAW;qCACzC;oCACD;wCACC,mBAAmB,EAAE,WAAW;qCAChC;oCACD;wCACC,MAAM,EAAE,WAAW;qCACnB;oCACD;wCACC,YAAY,EAAE,WAAW;qCACzB;iCACD;6BACD,CAAC,CAAC;yBACH;6BACI;4BACJ,KAAK,GAAG;gCACP,GAAG,EAAE;oCACJ;wCACC,4BAA4B,EAAE,WAAW;qCACzC;oCACD;wCACC,mBAAmB,EAAE,WAAW;qCAChC;oCACD;wCACC,MAAM,EAAE,WAAW;qCACnB;oCACD;wCACC,YAAY,EAAE,WAAW;qCACzB;iCACD;6BACD,CAAC;yBACF;qBACD;iBACD;gBAED,OAAO,mBAAe,CAAC,YAAY,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,UAAU,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YAC9F,CAAC;SACD;QACD,eAAe,EAAE;YAChB,KAAK,EAAE,IAAI,sBAAY,CAAC;gBACvB,cAAc,EAAE;oBACf,IAAI,EAAE,MAAM;iBACZ;aACD,CAAC;YACF,QAAQ,EAAE,UAAS,cAAsB;gBACxC,OAAO,mBAAe,CAAC,YAAY,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC;YACzF,CAAC;SACD;KACD,CAAC,CAAC;AACJ,CAAC;AAhJD,gDAgJC","file":"counters.js","sourcesContent":["import { Types } from 'mongoose';\nimport { SupportCounters } from '../collections/counter.collection';\nimport SimpleSchema from 'simpl-schema';\nimport { SupportManager } from '../managers/support.manager';\nimport { ResolveIOServer } from '..';\n\nexport function loadCounterMethods(supportManager: SupportManager) {\n\tsupportManager.supportMethods({\n\t\tincCounter: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcounterType: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(counterType: string) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tlet counter = await SupportCounters.findOne({type: counterType});\n\n\t\t\t\t\tif (!counter) {\n\t\t\t\t\t\tSupportCounters.create({\n\t\t\t\t\t\t\t_id: Types.ObjectId().toHexString(),\n\t\t\t\t\t\t\tcount: 2,\n\t\t\t\t\t\t\ttype: counterType\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tresolve(1);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tlet newCount = await SupportCounters.findOneAndUpdate({type: counterType}, {$inc: {count: 1}}).exec();\n\n\t\t\t\t\t\tresolve(newCount.count);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tcountCollectionWithQuery: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollectionType: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tquery: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(collectionType: string, query: Object) {\t\n\t\t\t\treturn ResolveIOServer.getSupportDB().model(collectionType).collection.countDocuments(query);\n\t\t\t}\n\t\t},\n\t\tcountQuery: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollectionType: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tsearch: {\n\t\t\t\t\ttype: String,\n\t\t\t\t\toptional: true\n\t\t\t\t},\n\t\t\t\tfilters: SimpleSchema.oneOf(\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: Array,\n\t\t\t\t\t\toptional: true\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: Object,\n\t\t\t\t\t\tblackbox: true,\n\t\t\t\t\t\toptional: true\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t\t'filters.$': {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\toptional: true,\n\t\t\t\t\tblackbox: true\n\t\t\t\t}, \n\t\t\t\tsubType: {\n\t\t\t\t\ttype: String,\n\t\t\t\t\toptional: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(collectionType: string, search = '', filters = []) {\n\t\t\t\tlet query = {};\n\n\t\t\t\tif (!search && (!filters || !filters.length)) {\n\t\t\t\t\tquery = {};\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tif (filters && filters.length) {\n\t\t\t\t\t\tquery['$and'] = [];\n\n\t\t\t\t\t\tfilters.forEach(filter => {\n\t\t\t\t\t\t\tquery['$and'].push({[filter['prop']]: filter['data']});\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tif (search && collectionType === 'support-tickets') {\n\t\t\t\t\t\tconst searchRegEx = { '$regex': '.*' + (search || '') + '.*', '$options': 'i' };\n\n\t\t\t\t\t\tif (query['$and']) {\n\t\t\t\t\t\t\tquery['$and'].push({\n\t\t\t\t\t\t\t\t$or: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tsupport_ticket_number_string: searchRegEx\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\tdate_created_string: searchRegEx\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\tstatus: searchRegEx\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\tuser_created: searchRegEx\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\tquery = {\n\t\t\t\t\t\t\t\t$or: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tsupport_ticket_number_string: searchRegEx\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\tdate_created_string: searchRegEx\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\tstatus: searchRegEx\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\tuser_created: searchRegEx\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\t\t\n\t\t\t\treturn ResolveIOServer.getSupportDB().model(collectionType).collection.countDocuments(query);\n\t\t\t}\n\t\t},\n\t\tcountCollection: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tcollectionType: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(collectionType: string) {\t\n\t\t\t\treturn ResolveIOServer.getSupportDB().model(collectionType).collection.countDocuments();\n\t\t\t}\n\t\t}\n\t});\n}"]}
|
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
var simpl_schema_1 = require("simpl-schema");
|
|
40
|
-
var file_collection_1 = require("../collections/file.collection");
|
|
41
|
-
var handlebars = require("handlebars");
|
|
42
|
-
function loadSupportMethods(supportManager) {
|
|
43
|
-
supportManager.supportMethods({
|
|
44
|
-
sendSupportTicketEmail: {
|
|
45
|
-
check: new simpl_schema_1.default({
|
|
46
|
-
supportTicket: {
|
|
47
|
-
type: Object,
|
|
48
|
-
blackbox: true
|
|
49
|
-
},
|
|
50
|
-
id_files: {
|
|
51
|
-
type: Array,
|
|
52
|
-
optional: true
|
|
53
|
-
},
|
|
54
|
-
'id_files.$': {
|
|
55
|
-
type: String
|
|
56
|
-
}
|
|
57
|
-
}),
|
|
58
|
-
function: function (supportTicket, id_files) {
|
|
59
|
-
var _this = this;
|
|
60
|
-
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
61
|
-
var files_1;
|
|
62
|
-
var _this = this;
|
|
63
|
-
return __generator(this, function (_a) {
|
|
64
|
-
switch (_a.label) {
|
|
65
|
-
case 0:
|
|
66
|
-
if (!(id_files && id_files.length)) return [3 /*break*/, 2];
|
|
67
|
-
return [4 /*yield*/, file_collection_1.Files.find({
|
|
68
|
-
_id: { $in: id_files }
|
|
69
|
-
})];
|
|
70
|
-
case 1:
|
|
71
|
-
files_1 = _a.sent();
|
|
72
|
-
this.callMethodInternal.call(this, 'getSignedUrls', files_1.map(function (a) { return a.key; }), 900, function (err, res) {
|
|
73
|
-
if (res) {
|
|
74
|
-
_this.readFile('email-templates/support-ticket.html').then(function (html) { return __awaiter(_this, void 0, void 0, function () {
|
|
75
|
-
var template, filesAttached, fileCnt;
|
|
76
|
-
var _this = this;
|
|
77
|
-
return __generator(this, function (_a) {
|
|
78
|
-
template = handlebars.compile(html);
|
|
79
|
-
handlebars.registerHelper('greaterThan', function (a, b) {
|
|
80
|
-
return a > b;
|
|
81
|
-
});
|
|
82
|
-
handlebars.registerHelper('equals', function (a, b) {
|
|
83
|
-
return a === b;
|
|
84
|
-
});
|
|
85
|
-
filesAttached = [];
|
|
86
|
-
fileCnt = 0;
|
|
87
|
-
res.forEach(function (url) {
|
|
88
|
-
filesAttached.push({ filename: files_1[fileCnt].name, path: url });
|
|
89
|
-
fileCnt++;
|
|
90
|
-
});
|
|
91
|
-
this.readImage('images/ResolveIO.png').then(function (logoData) {
|
|
92
|
-
supportTicket['logo'] = 'data:image/png;base64,' + logoData;
|
|
93
|
-
if (supportTicket.client_user && supportTicket.client_user.email) {
|
|
94
|
-
supportTicket['user'] = supportTicket.client_user.user;
|
|
95
|
-
supportTicket['fileAttached'] = filesAttached;
|
|
96
|
-
_this.sendEmail(supportTicket.client_user.email, 'ResolveIO - ' + supportTicket.support_ticket_number_string + ' Priority: ' + supportTicket.priority, '', template(supportTicket), filesAttached);
|
|
97
|
-
}
|
|
98
|
-
}, function (err) {
|
|
99
|
-
console.log(err);
|
|
100
|
-
});
|
|
101
|
-
resolve(true);
|
|
102
|
-
return [2 /*return*/];
|
|
103
|
-
});
|
|
104
|
-
}); }, function (err) {
|
|
105
|
-
console.log(err);
|
|
106
|
-
});
|
|
107
|
-
resolve(true);
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
_this.callMethodInternal.call(_this, 'insertErrorLog', 'supportTicketsmethod - getsignedurl', [
|
|
111
|
-
files_1.map(function (a) { return a.key; }), err
|
|
112
|
-
]);
|
|
113
|
-
reject(err);
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
return [3 /*break*/, 3];
|
|
117
|
-
case 2:
|
|
118
|
-
this.readFile('email-templates/support-ticket.html').then(function (html) { return __awaiter(_this, void 0, void 0, function () {
|
|
119
|
-
var template;
|
|
120
|
-
var _this = this;
|
|
121
|
-
return __generator(this, function (_a) {
|
|
122
|
-
template = handlebars.compile(html);
|
|
123
|
-
handlebars.registerHelper('greaterThan', function (a, b) {
|
|
124
|
-
return a > b;
|
|
125
|
-
});
|
|
126
|
-
handlebars.registerHelper('equals', function (a, b) {
|
|
127
|
-
return a === b;
|
|
128
|
-
});
|
|
129
|
-
this.readImage('images/ResolveIO.png').then(function (logoData) {
|
|
130
|
-
supportTicket['logo'] = 'data:image/png;base64,' + logoData;
|
|
131
|
-
if (supportTicket.client_user && supportTicket.client_user.email) {
|
|
132
|
-
supportTicket['user'] = supportTicket.client_user.user;
|
|
133
|
-
_this.sendEmail(supportTicket.client_user.email, 'ResolveIO - ' + supportTicket.support_ticket_number_string + ' Priority: ' + supportTicket.priority, '', template(supportTicket), null);
|
|
134
|
-
}
|
|
135
|
-
}, function (err) {
|
|
136
|
-
console.log(err);
|
|
137
|
-
});
|
|
138
|
-
resolve(true);
|
|
139
|
-
return [2 /*return*/];
|
|
140
|
-
});
|
|
141
|
-
}); }, function (err) {
|
|
142
|
-
console.log(err);
|
|
143
|
-
});
|
|
144
|
-
resolve(true);
|
|
145
|
-
_a.label = 3;
|
|
146
|
-
case 3: return [2 /*return*/];
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
}); });
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
sendSupportTicketModifiedEmail: {
|
|
153
|
-
check: new simpl_schema_1.default({
|
|
154
|
-
supportTicket: {
|
|
155
|
-
type: Object,
|
|
156
|
-
blackbox: true
|
|
157
|
-
},
|
|
158
|
-
id_files: {
|
|
159
|
-
type: Array
|
|
160
|
-
},
|
|
161
|
-
'id_files.$': {
|
|
162
|
-
type: String
|
|
163
|
-
}
|
|
164
|
-
}),
|
|
165
|
-
function: function (supportTicket, id_files) {
|
|
166
|
-
var _this = this;
|
|
167
|
-
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
168
|
-
var files;
|
|
169
|
-
var _this = this;
|
|
170
|
-
return __generator(this, function (_a) {
|
|
171
|
-
switch (_a.label) {
|
|
172
|
-
case 0: return [4 /*yield*/, file_collection_1.Files.find({
|
|
173
|
-
_id: { $in: id_files }
|
|
174
|
-
})];
|
|
175
|
-
case 1:
|
|
176
|
-
files = _a.sent();
|
|
177
|
-
this.callMethodInternal.call(this, 'getSignedUrls', files.map(function (a) { return a.key; }), 900, function (err, res) {
|
|
178
|
-
if (res) {
|
|
179
|
-
_this.readFile('email-templates/support-ticket-modified.html').then(function (html) { return __awaiter(_this, void 0, void 0, function () {
|
|
180
|
-
var template, filesAttached, fileCnt;
|
|
181
|
-
var _this = this;
|
|
182
|
-
return __generator(this, function (_a) {
|
|
183
|
-
template = handlebars.compile(html);
|
|
184
|
-
handlebars.registerHelper('greaterThan', function (a, b) {
|
|
185
|
-
return a > b;
|
|
186
|
-
});
|
|
187
|
-
handlebars.registerHelper('equals', function (a, b) {
|
|
188
|
-
return a === b;
|
|
189
|
-
});
|
|
190
|
-
filesAttached = [];
|
|
191
|
-
fileCnt = 0;
|
|
192
|
-
res.forEach(function (url) {
|
|
193
|
-
filesAttached.push({ filename: files[fileCnt].name, path: url });
|
|
194
|
-
fileCnt++;
|
|
195
|
-
});
|
|
196
|
-
this.readImage('images/ResolveIO.png').then(function (logoData) {
|
|
197
|
-
supportTicket['logo'] = 'data:image/png;base64,' + logoData;
|
|
198
|
-
supportTicket.current_watchers.forEach(function (user) {
|
|
199
|
-
supportTicket['user'] = user.user;
|
|
200
|
-
supportTicket['fileAttached'] = filesAttached;
|
|
201
|
-
_this.sendEmail(user.email, 'ResolveIO - a ticket has been modified: ' + supportTicket.support_ticket_number_string + ' Priority: ' + supportTicket.priority, '', template(supportTicket), filesAttached);
|
|
202
|
-
});
|
|
203
|
-
if (supportTicket.client_user && supportTicket.client_user.email) {
|
|
204
|
-
supportTicket['user'] = supportTicket.client_user.user;
|
|
205
|
-
supportTicket['fileAttached'] = filesAttached;
|
|
206
|
-
_this.sendEmail(supportTicket.client_user.email, 'ResolveIO - ' + supportTicket.support_ticket_number_string + ' Priority: ' + supportTicket.priority, '', template(supportTicket), filesAttached);
|
|
207
|
-
}
|
|
208
|
-
}, function (err) {
|
|
209
|
-
console.log(err);
|
|
210
|
-
});
|
|
211
|
-
resolve(true);
|
|
212
|
-
return [2 /*return*/];
|
|
213
|
-
});
|
|
214
|
-
}); }, function (err) {
|
|
215
|
-
console.log(err);
|
|
216
|
-
});
|
|
217
|
-
resolve(true);
|
|
218
|
-
}
|
|
219
|
-
else {
|
|
220
|
-
_this.callMethodInternal.call(_this, 'insertErrorLog', 'supportTicketsmethod - getsignedurl', [
|
|
221
|
-
files.map(function (a) { return a.key; }), err
|
|
222
|
-
]);
|
|
223
|
-
reject(err);
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
return [2 /*return*/];
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
}); });
|
|
230
|
-
}
|
|
231
|
-
},
|
|
232
|
-
sendSupportTicketDeletedEmail: {
|
|
233
|
-
check: new simpl_schema_1.default({
|
|
234
|
-
supportTicket: {
|
|
235
|
-
type: Object,
|
|
236
|
-
blackbox: true
|
|
237
|
-
}
|
|
238
|
-
}),
|
|
239
|
-
function: function (supportTicket) {
|
|
240
|
-
var _this = this;
|
|
241
|
-
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
242
|
-
var _this = this;
|
|
243
|
-
return __generator(this, function (_a) {
|
|
244
|
-
this.callMethodInternal.call(this, 'getSignedUrls', [], 900, function (err, res) {
|
|
245
|
-
if (res) {
|
|
246
|
-
_this.readFile('email-templates/support-ticket-deleted.html').then(function (html) { return __awaiter(_this, void 0, void 0, function () {
|
|
247
|
-
var template;
|
|
248
|
-
return __generator(this, function (_a) {
|
|
249
|
-
template = handlebars.compile(html);
|
|
250
|
-
handlebars.registerHelper('greaterThan', function (a, b) {
|
|
251
|
-
return a > b;
|
|
252
|
-
});
|
|
253
|
-
handlebars.registerHelper('equals', function (a, b) {
|
|
254
|
-
return a === b;
|
|
255
|
-
});
|
|
256
|
-
if (supportTicket.client_user && supportTicket.client_user.email) {
|
|
257
|
-
this.sendEmail(supportTicket.client_user.email, 'ResolveIO - ' + supportTicket.support_ticket_number_string + ' Priority: ' + supportTicket.priority, '', template(supportTicket), []);
|
|
258
|
-
}
|
|
259
|
-
return [2 /*return*/];
|
|
260
|
-
});
|
|
261
|
-
}); }, function (err) {
|
|
262
|
-
console.log(err);
|
|
263
|
-
});
|
|
264
|
-
resolve(true);
|
|
265
|
-
}
|
|
266
|
-
else {
|
|
267
|
-
_this.callMethodInternal.call(_this, 'insertErrorLog', 'supportTicketsmethod - getsignedurl', [
|
|
268
|
-
[], err
|
|
269
|
-
]);
|
|
270
|
-
reject(err);
|
|
271
|
-
}
|
|
272
|
-
});
|
|
273
|
-
return [2 /*return*/];
|
|
274
|
-
});
|
|
275
|
-
}); });
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
exports.loadSupportMethods = loadSupportMethods;
|
|
281
|
-
|
|
282
|
-
//# sourceMappingURL=support.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/support-methods/support.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAwC;AAGxC,kEAAuD;AACvD,uCAA0C;AAE1C,SAAgB,kBAAkB,CAAC,cAA8B;IAChE,cAAc,CAAC,cAAc,CAAC;QAC7B,sBAAsB,EAAE;YACvB,KAAK,EAAE,IAAI,sBAAY,CAAC;gBACvB,aAAa,EAAE;oBACd,IAAI,EAAE,MAAM;oBACZ,QAAQ,EAAE,IAAI;iBACd;gBACD,QAAQ,EAAE;oBACT,IAAI,EAAE,KAAK;oBACX,QAAQ,EAAE,IAAI;iBACd;gBACD,YAAY,EAAE;oBACb,IAAI,EAAE,MAAM;iBACZ;aACD,CAAC;YACF,QAAQ,EAAE,UAAS,aAAiC,EAAE,QAAmB;gBAA/D,iBAsGT;gBArGA,OAAO,IAAI,OAAO,CAAC,UAAO,OAAO,EAAE,MAAM;;;;;;qCACpC,CAAA,QAAQ,IAAI,QAAQ,CAAC,MAAM,CAAA,EAA3B,wBAA2B;gCAClB,qBAAM,uBAAK,CAAC,IAAI,CAAC;wCAC5B,GAAG,EAAE,EAAC,GAAG,EAAE,QAAQ,EAAC;qCACpB,CAAC,EAAA;;gCAFE,UAAQ,SAEV;gCAEF,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,EA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,KAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,KAAI,EAAE,gBAAgB,EAAE,qCAAqC,EAAE;oCAC3F,EAAE,EAAE,GAAG;iCACP,CAAC,CAAC;gCACH,MAAM,CAAC,GAAG,CAAC,CAAC;6BACZ;wBACF,CAAC,CAAC,CAAC;;;qBACH,CAAC,CAAC;YACJ,CAAC;SACD;KACD,CAAC,CAAC;AACJ,CAAC;AArQD,gDAqQC","file":"support.js","sourcesContent":["import SimpleSchema from 'simpl-schema';\nimport { SupportManager } from '../managers/support.manager';\nimport { SupportTicketModel } from '../models/support-ticket.model';\nimport { Files } from '../collections/file.collection';\nimport handlebars = require('handlebars');\n\nexport function loadSupportMethods(supportManager: SupportManager) {\n\tsupportManager.supportMethods({\n\t\tsendSupportTicketEmail: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tsupportTicket: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t},\n\t\t\t\tid_files: {\n\t\t\t\t\ttype: Array,\n\t\t\t\t\toptional: true\t\t\t\n\t\t\t\t},\n\t\t\t\t'id_files.$': {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(supportTicket: SupportTicketModel, id_files?: string[]) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\t\t\t\t\t\n\t\t\t\t\tif (id_files && id_files.length) {\n\t\t\t\t\t\tlet files = await Files.find({\n\t\t\t\t\t\t\t_id: {$in: id_files}\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tthis.callMethodInternal.call(this, 'getSignedUrls', files.map(a => a.key), 900, (err, res) => {\n\t\t\t\t\t\t\tif (res) {\n\t\t\t\t\t\t\t\tthis.readFile('email-templates/support-ticket.html').then(async html => {\n\t\t\t\t\t\t\t\t\tlet template = handlebars.compile(html);\n\t\n\t\t\t\t\t\t\t\t\thandlebars.registerHelper('greaterThan', (a, b) => {\n\t\t\t\t\t\t\t\t\t\treturn a > b;\n\t\t\t\t\t\t\t\t\t});\n\t\n\t\t\t\t\t\t\t\t\thandlebars.registerHelper('equals', (a, b) => {\n\t\t\t\t\t\t\t\t\t\treturn a === b;\n\t\t\t\t\t\t\t\t\t});\n\t\n\t\t\t\t\t\t\t\t\tlet filesAttached = [];\n\t\n\t\t\t\t\t\t\t\t\tlet fileCnt = 0;\n\t\t\t\t\t\t\t\t\tres.forEach(url => {\n\t\t\t\t\t\t\t\t\t\tfilesAttached.push({filename: files[fileCnt].name, path: url});\n\t\t\t\t\t\t\t\t\t\tfileCnt++;\n\t\t\t\t\t\t\t\t\t});\n\t\n\t\t\t\t\t\t\t\t\tthis.readImage('images/ResolveIO.png').then(logoData => {\n\t\t\t\t\t\t\t\t\t\tsupportTicket['logo'] = 'data:image/png;base64,' + logoData;\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\tif (supportTicket.client_user && supportTicket.client_user.email) {\n\t\n\t\t\t\t\t\t\t\t\t\t\tsupportTicket['user'] = supportTicket.client_user.user;\n\t\t\t\t\t\t\t\t\t\t\tsupportTicket['fileAttached'] = filesAttached;\n\t\n\t\t\t\t\t\t\t\t\t\t\tthis.sendEmail(\n\t\t\t\t\t\t\t\t\t\t\t\tsupportTicket.client_user.email, \n\t\t\t\t\t\t\t\t\t\t\t\t'ResolveIO - ' + supportTicket.support_ticket_number_string + ' Priority: ' + supportTicket.priority, \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\ttemplate(supportTicket),\n\t\t\t\t\t\t\t\t\t\t\t\tfilesAttached\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}, err => {\n\t\t\t\t\t\t\t\t\t\tconsole.log(err);\n\t\t\t\t\t\t\t\t\t});\n\t\n\t\t\t\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t\t\t\t}, err => {\n\t\t\t\t\t\t\t\t\tconsole.log(err);\n\t\t\t\t\t\t\t\t});\n\t\n\t\t\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tthis.callMethodInternal.call(this, 'insertErrorLog', 'supportTicketsmethod - getsignedurl', [\n\t\t\t\t\t\t\t\t\tfiles.map(a => a.key), err\n\t\t\t\t\t\t\t\t]);\n\t\t\t\t\t\t\t\treject(err);\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\tthis.readFile('email-templates/support-ticket.html').then(async html => {\n\t\t\t\t\t\t\tlet template = handlebars.compile(html);\n\n\t\t\t\t\t\t\thandlebars.registerHelper('greaterThan', (a, b) => {\n\t\t\t\t\t\t\t\treturn a > b;\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\thandlebars.registerHelper('equals', (a, b) => {\n\t\t\t\t\t\t\t\treturn a === b;\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tthis.readImage('images/ResolveIO.png').then(logoData => {\n\t\t\t\t\t\t\t\tsupportTicket['logo'] = 'data:image/png;base64,' + logoData;\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tif (supportTicket.client_user && supportTicket.client_user.email) {\n\n\t\t\t\t\t\t\t\t\tsupportTicket['user'] = supportTicket.client_user.user;\n\n\t\t\t\t\t\t\t\t\tthis.sendEmail(\n\t\t\t\t\t\t\t\t\t\tsupportTicket.client_user.email, \n\t\t\t\t\t\t\t\t\t\t'ResolveIO - ' + supportTicket.support_ticket_number_string + ' Priority: ' + supportTicket.priority, \n\t\t\t\t\t\t\t\t\t\t'', \n\t\t\t\t\t\t\t\t\t\ttemplate(supportTicket),\n\t\t\t\t\t\t\t\t\t\tnull\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}, err => {\n\t\t\t\t\t\t\t\tconsole.log(err);\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t\t}, err => {\n\t\t\t\t\t\t\tconsole.log(err);\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tsendSupportTicketModifiedEmail: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tsupportTicket: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t},\n\t\t\t\tid_files: {\n\t\t\t\t\ttype: Array\t\t\t\t\t\n\t\t\t\t},\n\t\t\t\t'id_files.$': {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(supportTicket: SupportTicketModel, id_files: string[]) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\n\t\t\t\t\tlet files = await Files.find({\n\t\t\t\t\t\t_id: {$in: id_files}\n\t\t\t\t\t});\n\n\t\t\t\t\tthis.callMethodInternal.call(this, 'getSignedUrls', files.map(a => a.key), 900, (err, res) => {\n\t\t\t\t\t\tif (res) {\n\t\t\t\t\t\t\tthis.readFile('email-templates/support-ticket-modified.html').then(async html => {\n\t\t\t\t\t\t\t\tlet template = handlebars.compile(html);\n\n\t\t\t\t\t\t\t\thandlebars.registerHelper('greaterThan', (a, b) => {\n\t\t\t\t\t\t\t\t\treturn a > b;\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\thandlebars.registerHelper('equals', (a, b) => {\n\t\t\t\t\t\t\t\t\treturn a === b;\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tlet filesAttached = [];\n\n\t\t\t\t\t\t\t\tlet fileCnt = 0;\n\t\t\t\t\t\t\t\tres.forEach(url => {\n\t\t\t\t\t\t\t\t\tfilesAttached.push({filename: files[fileCnt].name, path: url});\n\t\t\t\t\t\t\t\t\tfileCnt++;\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tthis.readImage('images/ResolveIO.png').then(logoData => {\n\t\t\t\t\t\t\t\t\tsupportTicket['logo'] = 'data:image/png;base64,' + logoData;\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tsupportTicket.current_watchers.forEach(user => {\n\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\tsupportTicket['user'] = user.user;\n\t\t\t\t\t\t\t\t\t\tsupportTicket['fileAttached'] = filesAttached;\n\n\t\t\t\t\t\t\t\t\t\tthis.sendEmail(\n\t\t\t\t\t\t\t\t\t\t\tuser.email, \n\t\t\t\t\t\t\t\t\t\t\t'ResolveIO - a ticket has been modified: ' + supportTicket.support_ticket_number_string + ' Priority: ' + supportTicket.priority, \n\t\t\t\t\t\t\t\t\t\t\t'', \n\t\t\t\t\t\t\t\t\t\t\ttemplate(supportTicket),\n\t\t\t\t\t\t\t\t\t\t\tfilesAttached\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\tif (supportTicket.client_user && supportTicket.client_user.email) {\n\n\t\t\t\t\t\t\t\t\t\tsupportTicket['user'] = supportTicket.client_user.user;\n\t\t\t\t\t\t\t\t\t\tsupportTicket['fileAttached'] = filesAttached;\n\n\t\t\t\t\t\t\t\t\t\tthis.sendEmail(\n\t\t\t\t\t\t\t\t\t\t\tsupportTicket.client_user.email, \n\t\t\t\t\t\t\t\t\t\t\t'ResolveIO - ' + supportTicket.support_ticket_number_string + ' Priority: ' + supportTicket.priority, \n\t\t\t\t\t\t\t\t\t\t\t'', \n\t\t\t\t\t\t\t\t\t\t\ttemplate(supportTicket),\n\t\t\t\t\t\t\t\t\t\t\tfilesAttached\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}, err => {\n\t\t\t\t\t\t\t\t\tconsole.log(err);\n\t\t\t\t\t\t\t\t});\n\t\t\n\t\t\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t}, err => {\n\t\t\t\t\t\t\t\tconsole.log(err);\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tthis.callMethodInternal.call(this, 'insertErrorLog', 'supportTicketsmethod - getsignedurl', [\n\t\t\t\t\t\t\t\tfiles.map(a => a.key), err\n\t\t\t\t\t\t\t]);\n\t\t\t\t\t\t\treject(err);\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\tsendSupportTicketDeletedEmail: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tsupportTicket: {\n\t\t\t\t\ttype: Object,\n\t\t\t\t\tblackbox: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(supportTicket: SupportTicketModel) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tthis.callMethodInternal.call(this, 'getSignedUrls', [], 900, (err, res) => {\n\t\t\t\t\t\tif (res) {\n\t\t\t\t\t\t\tthis.readFile('email-templates/support-ticket-deleted.html').then(async html => {\n\t\t\t\t\t\t\t\tlet template = handlebars.compile(html);\n\n\t\t\t\t\t\t\t\thandlebars.registerHelper('greaterThan', (a, b) => {\n\t\t\t\t\t\t\t\t\treturn a > b;\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\thandlebars.registerHelper('equals', (a, b) => {\n\t\t\t\t\t\t\t\t\treturn a === b;\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tif (supportTicket.client_user && supportTicket.client_user.email) {\n\t\t\t\t\t\t\t\t\tthis.sendEmail(\n\t\t\t\t\t\t\t\t\t\tsupportTicket.client_user.email, \n\t\t\t\t\t\t\t\t\t\t'ResolveIO - ' + supportTicket.support_ticket_number_string + ' Priority: ' + supportTicket.priority, \n\t\t\t\t\t\t\t\t\t\t'', \n\t\t\t\t\t\t\t\t\t\ttemplate(supportTicket),\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}, err => {\n\t\t\t\t\t\t\t\tconsole.log(err);\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tthis.callMethodInternal.call(this, 'insertErrorLog', 'supportTicketsmethod - getsignedurl', [\n\t\t\t\t\t\t\t\t[], err\n\t\t\t\t\t\t\t]);\n\t\t\t\t\t\t\treject(err);\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}"]}
|