@tiledesk/tiledesk-server 2.3.26 → 2.3.27
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +9 -1
- package/package.json +1 -1
- package/pubmodules/cache/mongoose-cachegoose-fn.js +29 -28
- package/pubmodules/trigger/rulesTrigger.js +2 -5
- package/routes/campaigns.js +3 -3
- package/services/requestService.js +7 -6
- package/utils/cacheUtil.js +2 -2
- package/utils/stringUtil.js +12 -0
- package/utils/uidGenerator.js +18 -0
package/CHANGELOG.md
CHANGED
@@ -1,4 +1,9 @@
|
|
1
1
|
|
2
|
+
# 2.3.27
|
3
|
+
- CacheUtil fix with new values
|
4
|
+
- UIDGenerator class replacement
|
5
|
+
- Disabled cache for requestService route. Bug: No matching document found for id "XYZ"
|
6
|
+
|
2
7
|
# 2.3.26
|
3
8
|
- DialogFlow connector fix /tdbot
|
4
9
|
|
@@ -47,7 +52,10 @@
|
|
47
52
|
- Moved route-queue to public module
|
48
53
|
- Disable queue module if JOB_WORKER_ENABLED is true
|
49
54
|
|
50
|
-
# 2.3.18.
|
55
|
+
# 2.3.18.7 -> PROD
|
56
|
+
- filter request by smartAssignment
|
57
|
+
|
58
|
+
# 2.3.18.6
|
51
59
|
- logfix
|
52
60
|
|
53
61
|
# 2.3.18.1
|
package/package.json
CHANGED
@@ -13,7 +13,8 @@
|
|
13
13
|
|
14
14
|
var cachegoose = require('cachegoose');
|
15
15
|
|
16
|
-
var
|
16
|
+
var cacheUtil = require('../../utils/cacheUtil');
|
17
|
+
|
17
18
|
|
18
19
|
|
19
20
|
function listen(client) {
|
@@ -22,7 +23,7 @@
|
|
22
23
|
setImmediate(() => {
|
23
24
|
var key = "projects:id:"+project.id;
|
24
25
|
winston.verbose("Creating cache for project.create with key: " + key);
|
25
|
-
client.set(key, project,
|
26
|
+
client.set(key, project, cacheUtil.longTTL, (err, reply) => {
|
26
27
|
winston.verbose("Created cache for project.create",{err:err});
|
27
28
|
winston.debug("Created cache for project.create reply",reply);
|
28
29
|
});
|
@@ -41,7 +42,7 @@
|
|
41
42
|
setImmediate(() => {
|
42
43
|
var key = "projects:id:"+project.id;
|
43
44
|
winston.verbose("Updating cache for project.update with key: " + key);
|
44
|
-
client.set(key, project,
|
45
|
+
client.set(key, project, cacheUtil.longTTL, (err, reply) => {
|
45
46
|
winston.verbose("Updated cache for project.update",{err:err});
|
46
47
|
winston.debug("Updated cache for project.update",reply);
|
47
48
|
|
@@ -80,7 +81,7 @@
|
|
80
81
|
var key = "projects:id:"+project.id;
|
81
82
|
winston.verbose("Updating cache for project.downgrade with key: " + key);
|
82
83
|
|
83
|
-
client.set(key, project,
|
84
|
+
client.set(key, project, cacheUtil.longTTL, (err, reply) => {
|
84
85
|
winston.debug("Updated cache for project.downgrade",reply);
|
85
86
|
winston.verbose("Updated cache for project.downgrade",{err:err});
|
86
87
|
});
|
@@ -106,7 +107,7 @@
|
|
106
107
|
|
107
108
|
var key = project_user.id_project+":project_users:id:"+project_user.id;
|
108
109
|
winston.verbose("Updating cache for project_user.update with key: " + key);
|
109
|
-
client.set(key, project_user, defaultTTL, (err, reply) => {
|
110
|
+
client.set(key, project_user, cacheUtil.defaultTTL, (err, reply) => {
|
110
111
|
winston.debug("Updated cache for project_user.update",reply);
|
111
112
|
winston.verbose("Updated cache for project_user.update",{err:err});
|
112
113
|
});
|
@@ -127,7 +128,7 @@
|
|
127
128
|
|
128
129
|
var key = project_user.id_project+":project_users:role:teammate:"+project_user.id;
|
129
130
|
winston.verbose("Updating cache for project_user.update with key: " + key);
|
130
|
-
client.set(key, project_user, defaultTTL, (err, reply) => {
|
131
|
+
client.set(key, project_user, cacheUtil.defaultTTL, (err, reply) => {
|
131
132
|
winston.debug("Updated cache for project_user.update",reply);
|
132
133
|
winston.verbose("Updated cache for project_user.update",{err:err});
|
133
134
|
});
|
@@ -145,14 +146,14 @@
|
|
145
146
|
|
146
147
|
var key = "users:id:"+user.id;
|
147
148
|
winston.verbose("Creating cache for user.signup with key: " + key);
|
148
|
-
client.set(key, user, defaultTTL, (err, reply) => {
|
149
|
+
client.set(key, user, cacheUtil.defaultTTL, (err, reply) => {
|
149
150
|
winston.debug("Created cache for user.signup",reply);
|
150
151
|
winston.verbose("Created cache for user.signup",{err:err});
|
151
152
|
});
|
152
153
|
|
153
154
|
var key = "users:email:"+user.email;
|
154
155
|
winston.verbose("Creating cache for user.signup with key: " + key);
|
155
|
-
client.set(key, user, defaultTTL, (err, reply) => {
|
156
|
+
client.set(key, user, cacheUtil.defaultTTL, (err, reply) => {
|
156
157
|
winston.debug("Created cache for user.signup",reply);
|
157
158
|
winston.verbose("Created cache for user.signup",{err:err});
|
158
159
|
});
|
@@ -166,14 +167,14 @@
|
|
166
167
|
|
167
168
|
var key = "users:id:"+user.id;
|
168
169
|
winston.verbose("Updating cache for user.update with key: " + key);
|
169
|
-
client.set(key, user, defaultTTL, (err, reply) => {
|
170
|
+
client.set(key, user, cacheUtil.defaultTTL, (err, reply) => {
|
170
171
|
winston.debug("Updated cache for user.update",reply);
|
171
172
|
winston.verbose("Updated cache for user.update",{err:err});
|
172
173
|
});
|
173
174
|
|
174
175
|
var key = "users:email:"+user.email;
|
175
176
|
winston.verbose("Updating cache for user.update with key: " + key);
|
176
|
-
client.set(key, user, defaultTTL, (err, reply) => {
|
177
|
+
client.set(key, user, cacheUtil.defaultTTL, (err, reply) => {
|
177
178
|
winston.debug("Updated cache for user.update",reply);
|
178
179
|
winston.verbose("Updated cache for user.update",{err:err});
|
179
180
|
});
|
@@ -208,7 +209,7 @@
|
|
208
209
|
var key = request.id_project+":requests:id:"+request.id+":simple";
|
209
210
|
winston.verbose("Creating cache for request.create.simple with key: " + key);
|
210
211
|
|
211
|
-
client.set(key, request, defaultTTL, (err, reply) => {
|
212
|
+
client.set(key, request, cacheUtil.defaultTTL, (err, reply) => {
|
212
213
|
winston.debug("Created cache for request.create.simple",reply);
|
213
214
|
winston.verbose("Created cache for request.create.simple",{err:err});
|
214
215
|
});
|
@@ -217,14 +218,14 @@
|
|
217
218
|
var key = "requests:id:"+request.request_id+":simple"; //without project for chat21 webhook
|
218
219
|
winston.verbose("Creating cache for request.create.simple with key: " + key);
|
219
220
|
|
220
|
-
client.set(key, request, defaultTTL, (err, reply) => {
|
221
|
+
client.set(key, request, cacheUtil.defaultTTL, (err, reply) => {
|
221
222
|
winston.debug("Created cache for request.create.simple",reply);
|
222
223
|
winston.verbose("Created cache for request.create.simple",{err:err});
|
223
224
|
});
|
224
225
|
|
225
226
|
var key = request.id_project+":requests:request_id:"+request.request_id+":simple";
|
226
227
|
winston.verbose("Creating cache for request.create.simple with key: " + key);
|
227
|
-
client.set(key, request, defaultTTL, (err, reply) => {
|
228
|
+
client.set(key, request, cacheUtil.defaultTTL, (err, reply) => {
|
228
229
|
winston.debug("Created cache for request.create.simple",reply);
|
229
230
|
winston.verbose("Created cache for request.create.simple",{err:err});
|
230
231
|
});
|
@@ -237,14 +238,14 @@
|
|
237
238
|
var key = request.id_project+":requests:id:"+request.id;
|
238
239
|
winston.verbose("Creating cache for request.create with key: " + key);
|
239
240
|
|
240
|
-
client.set(key, request, defaultTTL, (err, reply) => {
|
241
|
+
client.set(key, request, cacheUtil.defaultTTL, (err, reply) => {
|
241
242
|
winston.debug("Created cache for request.create",reply);
|
242
243
|
winston.verbose("Created cache for request.create",{err:err});
|
243
244
|
});
|
244
245
|
|
245
246
|
var key = request.id_project+":requests:request_id:"+request.request_id;
|
246
247
|
winston.verbose("Creating cache for request.create with key: " + key);
|
247
|
-
client.set(key, request, defaultTTL, (err, reply) => {
|
248
|
+
client.set(key, request, cacheUtil.defaultTTL, (err, reply) => {
|
248
249
|
winston.debug("Created cache for request.create",reply);
|
249
250
|
winston.verbose("Created cache for request.create",{err:err});
|
250
251
|
});
|
@@ -264,14 +265,14 @@
|
|
264
265
|
setImmediate(() => {
|
265
266
|
var key = request.id_project+":requests:id:"+request.id;
|
266
267
|
winston.verbose("Creating cache for request.update with key: " + key);
|
267
|
-
client.set(key, request, defaultTTL, (err, reply) => {
|
268
|
+
client.set(key, request, cacheUtil.defaultTTL, (err, reply) => {
|
268
269
|
winston.debug("Created cache for request.update",reply);
|
269
270
|
winston.verbose("Created cache for request.update",{err:err});
|
270
271
|
});
|
271
272
|
|
272
273
|
var key = request.id_project+":requests:request_id:"+request.request_id;
|
273
274
|
winston.verbose("Creating cache for request.update with key: " + key);
|
274
|
-
client.set(key, request, defaultTTL, (err, reply) => {
|
275
|
+
client.set(key, request, cacheUtil.defaultTTL, (err, reply) => {
|
275
276
|
winston.debug("Created cache for request.update",reply);
|
276
277
|
winston.verbose("Created cache for request.update",{err:err});
|
277
278
|
});
|
@@ -290,14 +291,14 @@
|
|
290
291
|
setImmediate(() => {
|
291
292
|
var key = request.id_project+":requests:id:"+request.id;
|
292
293
|
winston.verbose("Creating cache for request.close with key: " + key);
|
293
|
-
client.set(key, request, defaultTTL, (err, reply) => {
|
294
|
+
client.set(key, request, cacheUtil.defaultTTL, (err, reply) => {
|
294
295
|
winston.debug("Created cache for request.close",reply);
|
295
296
|
winston.verbose("Created cache for request.close",{err:err});
|
296
297
|
});
|
297
298
|
|
298
299
|
var key = request.id_project+":requests:request_id:"+request.request_id;
|
299
300
|
winston.verbose("Creating cache for request.close with key: " + key);
|
300
|
-
client.set(key, request, defaultTTL, (err, reply) => {
|
301
|
+
client.set(key, request, cacheUtil.defaultTTL, (err, reply) => {
|
301
302
|
winston.debug("Created cache for request.close",reply);
|
302
303
|
winston.verbose("Created cache for request.close",{err:err});
|
303
304
|
});
|
@@ -319,13 +320,13 @@
|
|
319
320
|
// setImmediate(() => {
|
320
321
|
// var key = message.id_project+":requests:id:"+message.request._id + ":messages:id:" + message._id;
|
321
322
|
// winston.verbose("Creating cache for message.create with key: " + key);
|
322
|
-
// client.set(key, message, defaultTTL, (err, reply) => {
|
323
|
+
// client.set(key, message, cacheUtil.defaultTTL, (err, reply) => {
|
323
324
|
// winston.verbose("Created cache for message.create",{err:err, reply:reply});
|
324
325
|
// });
|
325
326
|
|
326
327
|
// var key = message.id_project+":requests:request_id:"+message.request.request_id + ":messages:id:" + message._id;
|
327
328
|
// winston.verbose("Creating cache for message.create with key: " + key);
|
328
|
-
// client.set(key, message, defaultTTL, (err, reply) => {
|
329
|
+
// client.set(key, message, cacheUtil.defaultTTL, (err, reply) => {
|
329
330
|
// winston.verbose("Created cache for message.create",{err:err, reply:reply});
|
330
331
|
// });
|
331
332
|
// });
|
@@ -337,7 +338,7 @@
|
|
337
338
|
setImmediate(() => {
|
338
339
|
var key = faq_kb.id_project+":faq_kbs:id:"+faq_kb._id;
|
339
340
|
winston.verbose("Creating cache for faq_kb.create with key: " + key);
|
340
|
-
client.set(key, faq_kb, defaultTTL, (err, reply) => {
|
341
|
+
client.set(key, faq_kb, cacheUtil.defaultTTL, (err, reply) => {
|
341
342
|
winston.debug("Created cache for faq_kb.create",reply);
|
342
343
|
winston.verbose("Created cache for faq_kb.create",{err:err});
|
343
344
|
});
|
@@ -350,7 +351,7 @@
|
|
350
351
|
setImmediate(() => {
|
351
352
|
var key = faq_kb.id_project+":faq_kbs:id:"+faq_kb._id;
|
352
353
|
winston.verbose("Creating cache for faq_kb.update with key: " + key);
|
353
|
-
client.set(key, faq_kb, defaultTTL, (err, reply) => {
|
354
|
+
client.set(key, faq_kb, cacheUtil.defaultTTL, (err, reply) => {
|
354
355
|
winston.debug("Created cache for faq_kb.create",reply);
|
355
356
|
winston.verbose("Created cache for faq_kb.update",{err:err});
|
356
357
|
});
|
@@ -362,7 +363,7 @@
|
|
362
363
|
setImmediate(() => {
|
363
364
|
var key = faq_kb.id_project+":faq_kbs:id:"+faq_kb._id;
|
364
365
|
winston.verbose("Creating cache for faqbot.delete with key: " + key);
|
365
|
-
client.set(key, faq_kb, defaultTTL, (err, reply) => {
|
366
|
+
client.set(key, faq_kb, cacheUtil.defaultTTL, (err, reply) => {
|
366
367
|
winston.debug("Created cache for faqbot.delete",reply);
|
367
368
|
winston.verbose("Created cache for faqbot.delete",{err:err});
|
368
369
|
});
|
@@ -374,7 +375,7 @@
|
|
374
375
|
setImmediate(() => {
|
375
376
|
var key = department.id_project+":departments:id:"+department._id;
|
376
377
|
winston.verbose("Creating cache for department.create with key: " + key);
|
377
|
-
client.set(key, department, defaultTTL, (err, reply) => {
|
378
|
+
client.set(key, department, cacheUtil.defaultTTL, (err, reply) => {
|
378
379
|
winston.debug("Created cache for department.create",reply);
|
379
380
|
winston.verbose("Created cache for department.create",{err:err});
|
380
381
|
});
|
@@ -394,7 +395,7 @@
|
|
394
395
|
setImmediate(() => {
|
395
396
|
var key = department.id_project+":departments:id:"+department._id;
|
396
397
|
winston.verbose("Creating cache for department.update with key: " + key);
|
397
|
-
client.set(key, department, defaultTTL, (err, reply) => {
|
398
|
+
client.set(key, department, cacheUtil.defaultTTL, (err, reply) => {
|
398
399
|
winston.debug("Created cache for department.update",reply);
|
399
400
|
winston.verbose("Created cache for department.update",{err:err});
|
400
401
|
});
|
@@ -413,7 +414,7 @@
|
|
413
414
|
setImmediate(() => {
|
414
415
|
var key = department.id_project+":departments:id:"+department._id;
|
415
416
|
winston.verbose("Creating cache for department.delete with key: " + key);
|
416
|
-
client.set(key, department, defaultTTL, (err, reply) => {
|
417
|
+
client.set(key, department, cacheUtil.defaultTTL, (err, reply) => {
|
417
418
|
winston.debug("Created cache for department.delete",reply);
|
418
419
|
winston.verbose("Created cache for department.delete",{err:err});
|
419
420
|
});
|
@@ -578,7 +579,7 @@ module.exports = function (mongoose, option) {
|
|
578
579
|
var password = process.env.CACHE_REDIS_PASSWORD;
|
579
580
|
winston.debug("Redis password: "+ password);
|
580
581
|
|
581
|
-
winston.info("Mongoose Cachegoose fn initialized, engine: " + engine + ", port: "+ port + ", host: "+ host + " defaultTTL: " +defaultTTL + ", password: "+ password);
|
582
|
+
winston.info("Mongoose Cachegoose fn initialized, engine: " + engine + ", port: "+ port + ", host: "+ host + " defaultTTL: " +cacheUtil.defaultTTL + ", password: "+ password);
|
582
583
|
// winston.info("Mongoose Cachegoose fn initialized, engine: " + engine + ", endpoint: "+endPoint +", port: "+ port + ", host: "+ host + ", password: "+ password);
|
583
584
|
|
584
585
|
|
@@ -20,10 +20,7 @@ var operatingHoursService = require("../../services/operatingHoursService");
|
|
20
20
|
var sendMessageUtil = require("../../utils/sendMessageUtil");
|
21
21
|
var cacheUtil = require("../../utils/cacheUtil");
|
22
22
|
var cacheEnabler = require("../../services/cacheEnabler");
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
const uuidv4 = require('uuid/v4');
|
23
|
+
var UIDGenerator = require("../../utils/UIDGenerator");
|
27
24
|
|
28
25
|
|
29
26
|
class RulesTrigger {
|
@@ -683,7 +680,7 @@ class RulesTrigger {
|
|
683
680
|
|
684
681
|
|
685
682
|
|
686
|
-
var request_id = 'support-group-'+id_project+"-"+
|
683
|
+
var request_id = 'support-group-'+id_project+"-"+UIDGenerator.generate();
|
687
684
|
var id_user;
|
688
685
|
var fullname;
|
689
686
|
var email;
|
package/routes/campaigns.js
CHANGED
@@ -6,8 +6,7 @@ var winston = require('../config/winston');
|
|
6
6
|
var requestService = require("../services/requestService");
|
7
7
|
var messageService = require("../services/messageService");
|
8
8
|
var MessageConstants = require("../models/messageConstants");
|
9
|
-
|
10
|
-
|
9
|
+
var UIDGenerator = require("../utils/UIDGenerator");
|
11
10
|
|
12
11
|
|
13
12
|
|
@@ -19,7 +18,7 @@ router.post('/', function (req, res) {
|
|
19
18
|
|
20
19
|
winston.debug(req.body);
|
21
20
|
winston.debug("req.user", req.user);
|
22
|
-
var request_id = req.body.request_id || 'support-group-' + req.projectid + "-" +
|
21
|
+
var request_id = req.body.request_id || 'support-group-' + req.projectid + "-" + UIDGenerator.generate();
|
23
22
|
|
24
23
|
// TODO cicla su segment
|
25
24
|
|
@@ -73,6 +72,7 @@ router.post('/direct', async function (req, res) {
|
|
73
72
|
|
74
73
|
}
|
75
74
|
|
75
|
+
|
76
76
|
winston.info("recipients", recipients);
|
77
77
|
winston.info("recipients.length: " + recipients.length);
|
78
78
|
|
@@ -7,12 +7,12 @@ var messageService = require('../services/messageService');
|
|
7
7
|
const requestEvent = require('../event/requestEvent');
|
8
8
|
const leadEvent = require('../event/leadEvent');
|
9
9
|
var winston = require('../config/winston');
|
10
|
-
const uuidv4 = require('uuid/v4');
|
11
10
|
var RequestConstants = require("../models/requestConstants");
|
12
11
|
var requestUtil = require("../utils/requestUtil");
|
13
12
|
var cacheUtil = require("../utils/cacheUtil");
|
14
13
|
var arrayUtil = require("../utils/arrayUtil");
|
15
14
|
var cacheEnabler = require("../services/cacheEnabler");
|
15
|
+
var UIDGenerator = require("../utils/UIDGenerator");
|
16
16
|
|
17
17
|
class RequestService {
|
18
18
|
|
@@ -230,10 +230,10 @@ class RequestService {
|
|
230
230
|
let q= Request
|
231
231
|
.findOne({request_id: request_id, id_project: id_project});
|
232
232
|
|
233
|
-
if (cacheEnabler.request) {
|
234
|
-
|
235
|
-
|
236
|
-
}
|
233
|
+
// if (cacheEnabler.request) { //(node:60837) UnhandledPromiseRejectionWarning: VersionError: No matching document found for id "633efe246a6cc0eda5732684" version 0 modifiedPaths "status, participants, participantsAgents, department, assigned_at, snapshot, snapshot.department, snapshot.department.updatedAt, snapshot.agents"
|
234
|
+
// q.cache(cacheUtil.defaultTTL, id_project+":requests:request_id:"+request_id+":simple") //request_cache
|
235
|
+
// winston.debug('request cache enabled');
|
236
|
+
// }
|
237
237
|
return q.exec( function(err, request) {
|
238
238
|
|
239
239
|
if (err) {
|
@@ -241,6 +241,7 @@ class RequestService {
|
|
241
241
|
return reject(err);
|
242
242
|
}
|
243
243
|
|
244
|
+
winston.debug('request return',request);
|
244
245
|
|
245
246
|
// cambia var in let
|
246
247
|
|
@@ -417,7 +418,7 @@ class RequestService {
|
|
417
418
|
|
418
419
|
createWithRequester(project_user_id, lead_id, id_project, first_text, departmentid, sourcePage, language, userAgent, status, createdBy, attributes, subject, preflight) {
|
419
420
|
|
420
|
-
var request_id = 'support-group-'+ id_project + "-" +
|
421
|
+
var request_id = 'support-group-'+ id_project + "-" + UIDGenerator.generate();
|
421
422
|
winston.debug("request_id: "+request_id);
|
422
423
|
|
423
424
|
return this.createWithIdAndRequester(request_id, project_user_id, lead_id, id_project, first_text, departmentid, sourcePage, language, userAgent, status, createdBy, attributes, subject, preflight);
|
package/utils/cacheUtil.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module.exports = {
|
2
|
-
defaultTTL: Number(process.env.CACHE_DEFAULT_TTL) ||
|
2
|
+
defaultTTL: Number(process.env.CACHE_DEFAULT_TTL) || 300, //5 minutes
|
3
3
|
queryTTL: Number(process.env.CACHE_QUERY_TTL) || 30,
|
4
|
-
longTTL: Number(process.env.CACHE_LONG_TTL) ||
|
4
|
+
longTTL: Number(process.env.CACHE_LONG_TTL) || 3600, //1 hour
|
5
5
|
};
|
6
6
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
let stringUtil = require("../utils/stringUtil");
|
2
|
+
const uuidv4 = require('uuid/v4');
|
3
|
+
|
4
|
+
class UIDGenerator {
|
5
|
+
|
6
|
+
generate() {
|
7
|
+
let uid = uuidv4();
|
8
|
+
// console.log("uid",uid);
|
9
|
+
let uidWithoutChar = stringUtil.replaceAll(uid, "-", "");
|
10
|
+
// console.log("uidWithoutChar",uidWithoutChar);
|
11
|
+
return uidWithoutChar;
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
var uidGenerator = new UIDGenerator();
|
16
|
+
|
17
|
+
module.exports = uidGenerator;
|
18
|
+
|