@tiledesk/tiledesk-server 2.3.72 → 2.3.73
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +24 -0
- package/middleware/passport.js +5 -4
- package/models/faq_kb.js +5 -0
- package/models/presence.js +1 -1
- package/models/project.js +3 -0
- package/models/user.js +1 -0
- package/package.json +2 -2
- package/pubmodules/activities/models/activity.js +2 -0
- package/pubmodules/cache/mongoose-cachegoose-fn.js +133 -24
- package/pubmodules/emailNotification/requestNotification.js +15 -5
- package/pubmodules/pubModulesManager.js +6 -6
- package/routes/auth.js +24 -8
- package/routes/faq.js +6 -1
- package/routes/faq_kb.js +50 -1
- package/routes/message.js +7 -4
- package/routes/project.js +49 -1
- package/routes/widget.js +95 -13
- package/services/BotSubscriptionNotifier.js +3 -0
- package/services/cacheEnabler.js +5 -0
- package/services/departmentService.js +1 -1
- package/services/operatingHoursService.js +1 -1
- package/services/subscriptionNotifier.js +8 -2
- package/template/email/emailDirect.html +2 -0
- package/template/email/newMessage.html +1 -1
- package/test/messageRoute.js +1 -1
- package/websocket/webSocketServer.js +4 -4
package/CHANGELOG.md
CHANGED
@@ -5,6 +5,30 @@
|
|
5
5
|
🚀 IN PRODUCTION 🚀
|
6
6
|
(https://www.npmjs.com/package/@tiledesk/tiledesk-server/v/2.3.71)
|
7
7
|
|
8
|
+
# 2.3.73
|
9
|
+
- Removed unused mongoose-auto-increment dependency
|
10
|
+
- Removed version versions files
|
11
|
+
- Added attributes field to the project model and relative patch endpoint
|
12
|
+
- Message text validation only for the first message
|
13
|
+
- Updated tiledesk/tiledesk-tybot-connector@0.1.46
|
14
|
+
- Added an endpoint to patch the bot attributes
|
15
|
+
- Added Faq_kbSchema index({certified: 1, public: 1});
|
16
|
+
- Added ActivitySchema index({id_project: 1, createdAt: -1});
|
17
|
+
- Changed from .remove to findByIdAndRemove for faq remove endpoint to fix event emitter payload
|
18
|
+
- Updated tiledesk/tiledesk-tybot-connector@0.1.47
|
19
|
+
- Added caching for /widgets endpoint with invalidations
|
20
|
+
- Added bot rules to /widgets endpoint
|
21
|
+
- Select false for resetpswrequestid field of user model
|
22
|
+
- Added support for Public Private Key for JWT Auth with GLOBAL_SECRET_OR_PRIVATE_KEY and GLOBAL_SECRET_OR_PUB_KEY and GLOBAL_SECRET_ALGORITHM environments variables. If these properties are configured Public Private Key method is enabled otherwise if GLOBAL_SECRET env varible is configured the shared secret method is used. algorithm (default: HS256)
|
23
|
+
- Updated tiledesk/tiledesk-tybot-connector@0.1.48
|
24
|
+
- Removed “snapshot” from request payload for external chatbot
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
# 2.3.72
|
29
|
+
- Added Kaleyra module
|
30
|
+
- Updated tiledesk-apps to 1.0.12
|
31
|
+
|
8
32
|
# 2.3.71
|
9
33
|
- Email service send email direct fit without request_id
|
10
34
|
- Removed strong from transcript email template
|
package/middleware/passport.js
CHANGED
@@ -34,7 +34,8 @@ const maskOptions = {
|
|
34
34
|
};
|
35
35
|
|
36
36
|
|
37
|
-
var configSecret = process.env.GLOBAL_SECRET || config.secret;
|
37
|
+
var configSecret = process.env.GLOBAL_SECRET_OR_PUB_KEY || process.env.GLOBAL_SECRET || config.secret;
|
38
|
+
|
38
39
|
|
39
40
|
var maskedconfigSecret = MaskData.maskPhone(configSecret, maskOptions);
|
40
41
|
winston.info('Authentication Global Secret : ' + maskedconfigSecret);
|
@@ -179,17 +180,17 @@ module.exports = function(passport) {
|
|
179
180
|
|
180
181
|
else if (decoded.aud == "https://tiledesk.com") {
|
181
182
|
winston.debug("configSecret: "+ maskedconfigSecret );
|
182
|
-
done(null, configSecret);
|
183
|
+
done(null, configSecret); //pub_jwt pp_jwt
|
183
184
|
}
|
184
185
|
|
185
186
|
else {
|
186
187
|
winston.debug("configSecret: "+ maskedconfigSecret );
|
187
|
-
done(null, configSecret);
|
188
|
+
done(null, configSecret); //pub_jwt pp_jwt
|
188
189
|
}
|
189
190
|
}
|
190
191
|
else {
|
191
192
|
winston.debug("configSecret: "+ maskedconfigSecret );
|
192
|
-
done(null, configSecret);
|
193
|
+
done(null, configSecret); //pub_jwt pp_jwt
|
193
194
|
}
|
194
195
|
}
|
195
196
|
}
|
package/models/faq_kb.js
CHANGED
@@ -95,6 +95,11 @@ Faq_kbSchema.virtual('fullName').get(function () {
|
|
95
95
|
return (this.name);
|
96
96
|
});
|
97
97
|
|
98
|
+
Faq_kbSchema.index({certified: 1, public: 1}); //suggested by atlas
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
98
103
|
var faq_kb = mongoose.model('faq_kb', Faq_kbSchema);
|
99
104
|
|
100
105
|
if (process.env.MONGOOSE_SYNCINDEX) {
|
package/models/presence.js
CHANGED
package/models/project.js
CHANGED
@@ -68,6 +68,9 @@ var ProjectSchema = new Schema({
|
|
68
68
|
type: String,
|
69
69
|
select: false
|
70
70
|
},
|
71
|
+
attributes: {
|
72
|
+
type: Object,
|
73
|
+
},
|
71
74
|
// apiKey: { //You do want to block anonymous traffic. https://cloud.google.com/endpoints/docs/openapi/when-why-api-key#:~:text=API%20keys%20identify%20an%20application's,patterns%20in%20your%20API's%20traffic
|
72
75
|
// type: String,
|
73
76
|
// select: false,
|
package/models/user.js
CHANGED
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@tiledesk/tiledesk-server",
|
3
3
|
"description": "The Tiledesk server module",
|
4
|
-
"version": "2.3.
|
4
|
+
"version": "2.3.73",
|
5
5
|
"scripts": {
|
6
6
|
"start": "node ./bin/www",
|
7
7
|
"pretest": "mongodb-runner start",
|
@@ -43,7 +43,7 @@
|
|
43
43
|
"@tiledesk/tiledesk-chatbot-util": "^0.8.33",
|
44
44
|
"@tiledesk/tiledesk-json-rules-engine": "^4.0.3",
|
45
45
|
"@tiledesk/tiledesk-rasa-connector": "^1.0.10",
|
46
|
-
"@tiledesk/tiledesk-tybot-connector": "^0.1.
|
46
|
+
"@tiledesk/tiledesk-tybot-connector": "^0.1.49",
|
47
47
|
"@tiledesk/tiledesk-dialogflow-connector": "^1.8.3",
|
48
48
|
"app-root-path": "^3.0.0",
|
49
49
|
"bcrypt-nodejs": "0.0.3",
|
@@ -2,6 +2,7 @@
|
|
2
2
|
var messageEvent = require("../../event/messageEvent");
|
3
3
|
var projectEvent = require("../../event/projectEvent");
|
4
4
|
var botEvent = require("../../event/botEvent");
|
5
|
+
const faqBotEvent = require('../../event/faqBotEvent');
|
5
6
|
var departmentEvent = require("../../event/departmentEvent");
|
6
7
|
var authEvent = require("../../event/authEvent");
|
7
8
|
var labelEvent = require("../../event/labelEvent");
|
@@ -14,6 +15,7 @@
|
|
14
15
|
var cachegoose = require('cachegoose');
|
15
16
|
|
16
17
|
var cacheUtil = require('../../utils/cacheUtil');
|
18
|
+
var RoleConstants = require("../../models/roleConstants");
|
17
19
|
|
18
20
|
|
19
21
|
|
@@ -28,6 +30,7 @@
|
|
28
30
|
winston.debug("Created cache for project.create reply",reply);
|
29
31
|
});
|
30
32
|
|
33
|
+
// TODO COMMENTA NON USATO
|
31
34
|
key = "projects:query:*";
|
32
35
|
winston.verbose("Deleting cache for project.create with key: " + key);
|
33
36
|
client.del(key, function (err, reply) {
|
@@ -48,12 +51,17 @@
|
|
48
51
|
|
49
52
|
});
|
50
53
|
|
54
|
+
// TODO COMMENTA NON USATO
|
51
55
|
key = "projects:query:*";
|
52
|
-
winston.verbose("Deleting cache for project.
|
56
|
+
winston.verbose("Deleting cache for project.update with key: " + key);
|
53
57
|
client.del(key, function (err, reply) {
|
54
|
-
winston.debug("Deleted cache for project.
|
55
|
-
winston.verbose("Deleted cache for project.
|
58
|
+
winston.debug("Deleted cache for project.update",reply);
|
59
|
+
winston.verbose("Deleted cache for project.update",{err:err});
|
56
60
|
});
|
61
|
+
|
62
|
+
// TODO invalidate widgets here
|
63
|
+
winston.verbose("Deleting widgets cache for project.update");
|
64
|
+
invalidateWidgets(client, project.id); //tested
|
57
65
|
});
|
58
66
|
|
59
67
|
});
|
@@ -67,6 +75,7 @@
|
|
67
75
|
winston.verbose("Deleted cache for project.delete",{err:err});
|
68
76
|
});
|
69
77
|
|
78
|
+
// TODO COMMENTA NON USATO
|
70
79
|
key = "projects:query:*";
|
71
80
|
winston.verbose("Deleting cache for project.create with key: " + key);
|
72
81
|
client.del(key, function (err, reply) {
|
@@ -74,6 +83,10 @@
|
|
74
83
|
winston.verbose("Deleted cache for project.create",{err:err});
|
75
84
|
});
|
76
85
|
});
|
86
|
+
|
87
|
+
// TODO invalidate widgets here
|
88
|
+
winston.verbose("Deleting widgets cache for project.delete");
|
89
|
+
invalidateWidgets(client, project.id);
|
77
90
|
});
|
78
91
|
|
79
92
|
projectEvent.on("project.downgrade", function(project) {
|
@@ -86,12 +99,17 @@
|
|
86
99
|
winston.verbose("Updated cache for project.downgrade",{err:err});
|
87
100
|
});
|
88
101
|
|
102
|
+
// TODO COMMENTA NON USATO
|
89
103
|
key = "projects:query:*";
|
90
|
-
winston.verbose("Deleting cache for project.
|
104
|
+
winston.verbose("Deleting cache for project.downgrade with key: " + key);
|
91
105
|
client.del(key, function (err, reply) {
|
92
|
-
winston.debug("Deleted cache for project.
|
93
|
-
winston.verbose("Deleted cache for project.
|
94
|
-
});
|
106
|
+
winston.debug("Deleted cache for project.downgrade",reply);
|
107
|
+
winston.verbose("Deleted cache for project.downgrade",{err:err});
|
108
|
+
});
|
109
|
+
|
110
|
+
// TODO invalidate widgets here
|
111
|
+
winston.verbose("Deleting widgets cache for project.downgrade");
|
112
|
+
invalidateWidgets(client, project.id);
|
95
113
|
});
|
96
114
|
});
|
97
115
|
|
@@ -153,6 +171,18 @@
|
|
153
171
|
winston.verbose("Updated cache for project_user.update",{err:err});
|
154
172
|
});
|
155
173
|
}
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
// TODO invalidate widgets headers
|
178
|
+
// only if role is agent, owner, admin ATTENTION
|
179
|
+
if (role == RoleConstants.OWNER || role == RoleConstants.ADMIN || role == RoleConstants.SUPERVISOR || role == RoleConstants.AGENT) {
|
180
|
+
winston.verbose("Deleting widgets cache for project_user.update");
|
181
|
+
invalidateWidgets(client, project_user.id_project); //tested
|
182
|
+
}else {
|
183
|
+
winston.verbose("NOT invalidating widget cache for non admins project_user role");//tested
|
184
|
+
}
|
185
|
+
|
156
186
|
});
|
157
187
|
});
|
158
188
|
|
@@ -235,8 +265,8 @@
|
|
235
265
|
});
|
236
266
|
|
237
267
|
|
238
|
-
var key = "requests:
|
239
|
-
winston.verbose("Creating cache for request.create.simple with key: " + key);
|
268
|
+
var key = "requests:request_id:"+request.request_id+":simple"; //without project for chat21 webhook
|
269
|
+
winston.verbose("Creating cache for request.create.simple without project with key : " + key);
|
240
270
|
|
241
271
|
client.set(key, request, cacheUtil.defaultTTL, (err, reply) => {
|
242
272
|
winston.debug("Created cache for request.create.simple",reply);
|
@@ -270,6 +300,7 @@
|
|
270
300
|
winston.verbose("Created cache for request.create",{err:err});
|
271
301
|
});
|
272
302
|
|
303
|
+
// TODO COMMENTA NON USATO
|
273
304
|
key = request.id_project+":requests:query:*";
|
274
305
|
winston.verbose("Deleting cache for request.create with key: " + key);
|
275
306
|
client.del(key, function (err, reply) {
|
@@ -297,11 +328,12 @@
|
|
297
328
|
winston.verbose("Created cache for request.update",{err:err});
|
298
329
|
});
|
299
330
|
|
331
|
+
// TODO COMMENTA NON USATO
|
300
332
|
key = request.id_project+":requests:query:*";
|
301
|
-
winston.verbose("Deleting cache for request.
|
333
|
+
winston.verbose("Deleting cache for request.update with key: " + key);
|
302
334
|
client.del(key, function (err, reply) {
|
303
|
-
winston.debug("Deleted cache for request.
|
304
|
-
winston.verbose("Deleted cache for request.
|
335
|
+
winston.debug("Deleted cache for request.update",reply);
|
336
|
+
winston.verbose("Deleted cache for request.update",{err:err});
|
305
337
|
});
|
306
338
|
});
|
307
339
|
});
|
@@ -323,11 +355,12 @@
|
|
323
355
|
winston.verbose("Created cache for request.close",{err:err});
|
324
356
|
});
|
325
357
|
|
358
|
+
// TODO COMMENTA NON USATO
|
326
359
|
key = request.id_project+":requests:query:*";
|
327
360
|
winston.verbose("Deleting cache for request.create with key: " + key);
|
328
361
|
client.del(key, function (err, reply) {
|
329
|
-
winston.debug("Deleted cache for request.
|
330
|
-
winston.verbose("Deleted cache for request.
|
362
|
+
winston.debug("Deleted cache for request.close",reply);
|
363
|
+
winston.verbose("Deleted cache for request.close",{err:err});
|
331
364
|
});
|
332
365
|
});
|
333
366
|
});
|
@@ -362,6 +395,10 @@
|
|
362
395
|
winston.debug("Created cache for faq_kb.create",reply);
|
363
396
|
winston.verbose("Created cache for faq_kb.create",{err:err});
|
364
397
|
});
|
398
|
+
|
399
|
+
// TODO invalidate widgets here
|
400
|
+
winston.verbose("Deleting widgets cache for faqbot.create");
|
401
|
+
invalidateWidgets(client, faq_kb.id_project); //tested
|
365
402
|
});
|
366
403
|
});
|
367
404
|
|
@@ -374,7 +411,11 @@
|
|
374
411
|
client.set(key, faq_kb, cacheUtil.defaultTTL, (err, reply) => {
|
375
412
|
winston.debug("Created cache for faq_kb.create",reply);
|
376
413
|
winston.verbose("Created cache for faq_kb.update",{err:err});
|
377
|
-
});
|
414
|
+
});
|
415
|
+
|
416
|
+
// TODO invalidate widgets here
|
417
|
+
winston.verbose("Deleting widgets cache for faqbot.update");
|
418
|
+
invalidateWidgets(client, faq_kb.id_project); //TESTED
|
378
419
|
});
|
379
420
|
});
|
380
421
|
|
@@ -382,11 +423,41 @@
|
|
382
423
|
botEvent.on("faqbot.delete", function(faq_kb) {
|
383
424
|
setImmediate(() => {
|
384
425
|
var key = faq_kb.id_project+":faq_kbs:id:"+faq_kb._id;
|
385
|
-
winston.verbose("
|
386
|
-
client.
|
387
|
-
winston.debug("
|
388
|
-
winston.verbose("
|
426
|
+
winston.verbose("Deleting cache for faqbot.delete with key: " + key);
|
427
|
+
client.del(key, (err, reply) => {
|
428
|
+
winston.debug("Deleted cache for faqbot.delete",reply);
|
429
|
+
winston.verbose("Deleted cache for faqbot.delete",{err:err});
|
389
430
|
});
|
431
|
+
|
432
|
+
// TODO invalidate widgets here
|
433
|
+
winston.verbose("Deleting widgets cache for faqbot.delete");
|
434
|
+
invalidateWidgets(client, faq_kb.id_project); //tested
|
435
|
+
});
|
436
|
+
});
|
437
|
+
|
438
|
+
|
439
|
+
|
440
|
+
faqBotEvent.on("faq.create", function(faq) {
|
441
|
+
setImmediate(() => {
|
442
|
+
// TODO invalidate widgets here
|
443
|
+
winston.verbose("Deleting widgets cache for faq.create");
|
444
|
+
invalidateWidgets(client, faq.id_project); //tested
|
445
|
+
});
|
446
|
+
});
|
447
|
+
|
448
|
+
faqBotEvent.on("faq.update", function(faq) {
|
449
|
+
setImmediate(() => {
|
450
|
+
// TODO invalidate widgets here
|
451
|
+
winston.verbose("Deleting widgets cache for faq.update");
|
452
|
+
invalidateWidgets(client, faq.id_project);//tested
|
453
|
+
});
|
454
|
+
});
|
455
|
+
|
456
|
+
faqBotEvent.on("faq.delete", function(faq) {
|
457
|
+
setImmediate(() => {
|
458
|
+
// TODO invalidate widgets here
|
459
|
+
winston.verbose("Deleting widgets cache for faq.delete",faq);
|
460
|
+
invalidateWidgets(client, faq.id_project);//tested
|
390
461
|
});
|
391
462
|
});
|
392
463
|
|
@@ -400,12 +471,17 @@
|
|
400
471
|
winston.verbose("Created cache for department.create",{err:err});
|
401
472
|
});
|
402
473
|
|
474
|
+
// TODO COMMENTA NON USATO
|
403
475
|
key = department.id_project+":departments:query:*";
|
404
476
|
winston.verbose("Deleting cache for department.create with key: " + key);
|
405
477
|
client.del(key, function (err, reply) {
|
406
478
|
winston.debug("Deleted cache for department.create",reply);
|
407
479
|
winston.verbose("Deleted cache for department.create",{err:err});
|
408
480
|
});
|
481
|
+
|
482
|
+
// TODO invalidate widgets here
|
483
|
+
winston.verbose("Deleting widgets cache for department.create");
|
484
|
+
invalidateWidgets(client, department.id_project);
|
409
485
|
});
|
410
486
|
});
|
411
487
|
|
@@ -420,12 +496,17 @@
|
|
420
496
|
winston.verbose("Created cache for department.update",{err:err});
|
421
497
|
});
|
422
498
|
|
499
|
+
// TODO COMMENTA NON USATO
|
423
500
|
key = department.id_project+":departments:query:*";
|
424
501
|
winston.verbose("Deleting cache for department.update with key: " + key);
|
425
502
|
client.del(key, function (err, reply) {
|
426
503
|
winston.debug("Deleted cache for department.update",reply);
|
427
504
|
winston.verbose("Deleted cache for department.update",{err:err});
|
428
505
|
});
|
506
|
+
|
507
|
+
// TODO invalidate widgets here
|
508
|
+
winston.verbose("Deleting widgets cache for department.update");
|
509
|
+
invalidateWidgets(client, department.id_project); //tested
|
429
510
|
});
|
430
511
|
});
|
431
512
|
|
@@ -433,24 +514,31 @@
|
|
433
514
|
departmentEvent.on("department.delete", function(department) {
|
434
515
|
setImmediate(() => {
|
435
516
|
var key = department.id_project+":departments:id:"+department._id;
|
436
|
-
winston.verbose("
|
437
|
-
client.
|
438
|
-
winston.debug("
|
439
|
-
winston.verbose("
|
517
|
+
winston.verbose("Deleting cache for department.delete with key: " + key);
|
518
|
+
client.del(key, (err, reply) => {
|
519
|
+
winston.debug("Deleted cache for department.delete",reply);
|
520
|
+
winston.verbose("Deleted cache for department.delete",{err:err});
|
440
521
|
});
|
441
522
|
|
523
|
+
// TODO COMMENTA NON USATO
|
442
524
|
key = department.id_project+":departments:query:*";
|
443
525
|
winston.verbose("Deleting cache for department.delete with key: " + key);
|
444
526
|
client.del(key, function (err, reply) {
|
445
527
|
winston.debug("Deleted cache for department.delete",reply);
|
446
528
|
winston.verbose("Deleted cache for department.delete",{err:err});
|
447
529
|
});
|
530
|
+
|
531
|
+
// TODO invalidate widgets here
|
532
|
+
winston.verbose("Deleting widgets cache for department.delete");
|
533
|
+
invalidateWidgets(client, department.id_project);
|
448
534
|
});
|
449
535
|
});
|
450
536
|
|
451
537
|
|
452
538
|
labelEvent.on("label.create", function(label) {
|
453
539
|
setImmediate(() => {
|
540
|
+
|
541
|
+
// TODO COMMENTA NON USATO
|
454
542
|
var key = label.id_project+":labels:query:*";
|
455
543
|
winston.verbose("Deleting cache for label.create with key: " + key);
|
456
544
|
client.del(key, function (err, reply) {
|
@@ -464,6 +552,8 @@
|
|
464
552
|
|
465
553
|
labelEvent.on("label.update", function(label) {
|
466
554
|
setImmediate(() => {
|
555
|
+
|
556
|
+
// TODO COMMENTA NON USATO
|
467
557
|
var key = label.id_project+":labels:query:*";
|
468
558
|
winston.verbose("Deleting cache for label.update with key: " + key);
|
469
559
|
client.del(key, function (err, reply) {
|
@@ -475,7 +565,9 @@
|
|
475
565
|
|
476
566
|
|
477
567
|
labelEvent.on("label.clone", function(label) {
|
478
|
-
setImmediate(() => {
|
568
|
+
setImmediate(() => {
|
569
|
+
|
570
|
+
// TODO COMMENTA NON USATO
|
479
571
|
var key = label.id_project+":labels:query:*";
|
480
572
|
winston.verbose("Deleting cache for label.clone with key: " + key);
|
481
573
|
client.del(key, function (err, reply) {
|
@@ -488,6 +580,8 @@
|
|
488
580
|
|
489
581
|
labelEvent.on("label.delete", function(label) {
|
490
582
|
setImmediate(() => {
|
583
|
+
|
584
|
+
// TODO COMMENTA NON USATO
|
491
585
|
var key = label.id_project+":labels:query:*";
|
492
586
|
winston.verbose("Deleting cache for label.delete with key: " + key);
|
493
587
|
client.del(key, function (err, reply) {
|
@@ -575,6 +669,17 @@
|
|
575
669
|
|
576
670
|
}
|
577
671
|
|
672
|
+
|
673
|
+
function invalidateWidgets(client, project_id) {
|
674
|
+
key = project_id+":widgets";
|
675
|
+
winston.verbose("Deleting cache for widgets with key: " + key);
|
676
|
+
client.del(key, function (err, reply) {
|
677
|
+
winston.debug("Deleted cache for widgets",reply);
|
678
|
+
winston.verbose("Deleted cache for widgets",{err:err});
|
679
|
+
});
|
680
|
+
}
|
681
|
+
|
682
|
+
|
578
683
|
//jwt
|
579
684
|
|
580
685
|
// fai cache faq
|
@@ -616,8 +721,12 @@ module.exports = function (mongoose, option) {
|
|
616
721
|
|
617
722
|
var client = cachegoose._cache;
|
618
723
|
listen(client);
|
724
|
+
|
725
|
+
return cachegoose;
|
619
726
|
}else {
|
620
727
|
winston.info("Mongoose Cachegoose disabled");
|
728
|
+
|
729
|
+
return;
|
621
730
|
}
|
622
731
|
|
623
732
|
// console.log("init",init);
|
@@ -24,7 +24,7 @@ var configGlobal = require('../../config/global');
|
|
24
24
|
|
25
25
|
var widgetConfig = require('../../config/widget');
|
26
26
|
var widgetTestLocation = process.env.WIDGET_TEST_LOCATION || widgetConfig.testLocation;
|
27
|
-
let configSecret = process.env.GLOBAL_SECRET || config.secret;
|
27
|
+
let configSecret = process.env.GLOBAL_SECRET_OR_PRIVATE_KEY || process.env.GLOBAL_SECRET || config.secret;
|
28
28
|
|
29
29
|
let apiUrl = process.env.API_URL || configGlobal.apiUrl;
|
30
30
|
winston.debug('********* RequestNotification apiUrl: ' + apiUrl);
|
@@ -290,9 +290,14 @@ sendToUserEmailChannelEmail(projectid, message) {
|
|
290
290
|
issuer: 'https://tiledesk.com',
|
291
291
|
subject: 'userexternal',
|
292
292
|
audience: 'https://tiledesk.com',
|
293
|
-
jwtid: uuidv4()
|
293
|
+
jwtid: uuidv4()
|
294
294
|
};
|
295
295
|
|
296
|
+
var alg = process.env.GLOBAL_SECRET_ALGORITHM;
|
297
|
+
if (alg) {
|
298
|
+
signOptions.algorithm = alg;
|
299
|
+
}
|
300
|
+
|
296
301
|
|
297
302
|
var recipient = lead.lead_id;
|
298
303
|
winston.debug("recipient:"+ recipient);
|
@@ -301,7 +306,7 @@ sendToUserEmailChannelEmail(projectid, message) {
|
|
301
306
|
winston.debug("userEmail ",userEmail);
|
302
307
|
|
303
308
|
|
304
|
-
var token = jwt.sign(userEmail, configSecret, signOptions);
|
309
|
+
var token = jwt.sign(userEmail, configSecret, signOptions); //priv_jwt pp_jwt
|
305
310
|
winston.debug("token "+token);
|
306
311
|
|
307
312
|
var sourcePage = widgetTestLocation + "?tiledesk_projectid="
|
@@ -769,14 +774,19 @@ sendUserEmail(projectid, message) {
|
|
769
774
|
issuer: 'https://tiledesk.com',
|
770
775
|
subject: 'guest',
|
771
776
|
audience: 'https://tiledesk.com',
|
772
|
-
jwtid: uuidv4()
|
777
|
+
jwtid: uuidv4()
|
773
778
|
};
|
774
779
|
|
780
|
+
var alg = process.env.GLOBAL_SECRET_ALGORITHM;
|
781
|
+
if (alg) {
|
782
|
+
signOptions.algorithm = alg;
|
783
|
+
}
|
784
|
+
|
775
785
|
let userAnonym = {_id: recipient, firstname: lead.fullname, lastname: lead.fullname, email: lead.email, attributes: lead.attributes};
|
776
786
|
winston.debug("userAnonym ",userAnonym);
|
777
787
|
|
778
788
|
|
779
|
-
var token = jwt.sign(userAnonym, configSecret, signOptions);
|
789
|
+
var token = jwt.sign(userAnonym, configSecret, signOptions); //priv_jwt pp_jwt
|
780
790
|
winston.debug("token "+token);
|
781
791
|
|
782
792
|
var sourcePage = widgetTestLocation + "?tiledesk_projectid="
|
@@ -60,28 +60,28 @@ class PubModulesManager {
|
|
60
60
|
|
61
61
|
if (this.rasaRoute) {
|
62
62
|
app.use('/modules/rasa', this.rasaRoute);
|
63
|
-
winston.info("
|
63
|
+
winston.info("PubModulesManager rasaRoute controller loaded");
|
64
64
|
}
|
65
65
|
if (this.appsRoute) {
|
66
66
|
app.use('/modules/apps', this.appsRoute);
|
67
|
-
winston.info("
|
67
|
+
winston.info("PubModulesManager appsRoute controller loaded");
|
68
68
|
}
|
69
69
|
if (this.whatsappRoute) {
|
70
70
|
app.use('/modules/whatsapp', this.whatsappRoute);
|
71
|
-
winston.info("
|
71
|
+
winston.info("PubModulesManager whatsappRoute controller loaded");
|
72
72
|
}
|
73
73
|
if (this.kaleyraRoute) {
|
74
74
|
app.use('/modules/kaleyra', this.kaleyraRoute);
|
75
|
-
winston.info("
|
75
|
+
winston.info("PubModulesManager kaleyraRoute controller loaded");
|
76
76
|
}
|
77
77
|
if (this.tilebotRoute) {
|
78
78
|
app.use('/modules/tilebot', this.tilebotRoute);
|
79
|
-
winston.info("
|
79
|
+
winston.info("PubModulesManager tilebot controller loaded");
|
80
80
|
}
|
81
81
|
|
82
82
|
if (this.dialogFlow) {
|
83
83
|
app.use("/modules/dialogFlow", this.dialogFlow.dialogflowRoute);
|
84
|
-
winston.info("
|
84
|
+
winston.info("PubModulesManager dialogFlow controller loaded");
|
85
85
|
}
|
86
86
|
|
87
87
|
}
|
package/routes/auth.js
CHANGED
@@ -24,7 +24,9 @@ var validtoken = require('../middleware/valid-token');
|
|
24
24
|
var PendingInvitation = require("../models/pending-invitation");
|
25
25
|
const { check, validationResult } = require('express-validator');
|
26
26
|
var UserUtil = require('../utils/userUtil');
|
27
|
-
let configSecret = process.env.GLOBAL_SECRET || config.secret;
|
27
|
+
let configSecret = process.env.GLOBAL_SECRET_OR_PRIVATE_KEY || process.env.GLOBAL_SECRET || config.secret;
|
28
|
+
// const fs = require('fs');
|
29
|
+
// var configSecret = fs.readFileSync('private.key');
|
28
30
|
|
29
31
|
|
30
32
|
router.post('/signup',
|
@@ -147,10 +149,15 @@ function (req, res) {
|
|
147
149
|
issuer: 'https://tiledesk.com',
|
148
150
|
subject: 'guest',
|
149
151
|
audience: 'https://tiledesk.com',
|
150
|
-
jwtid: uuidv4()
|
152
|
+
jwtid: uuidv4()
|
151
153
|
};
|
152
154
|
|
153
|
-
var
|
155
|
+
var alg = process.env.GLOBAL_SECRET_ALGORITHM;
|
156
|
+
if (alg) {
|
157
|
+
signOptions.algorithm = alg;
|
158
|
+
}
|
159
|
+
|
160
|
+
var token = jwt.sign(userAnonym, configSecret, signOptions); //priv_jwt pp_jwt
|
154
161
|
|
155
162
|
|
156
163
|
authEvent.emit("user.signin", {user:userAnonym, req:req, jti:signOptions.jwtid, token: 'JWT ' + token});
|
@@ -385,22 +392,28 @@ function (req, res) {
|
|
385
392
|
// algorithm: "RS256"
|
386
393
|
|
387
394
|
|
388
|
-
jwtid: uuidv4()
|
395
|
+
jwtid: uuidv4()
|
396
|
+
|
389
397
|
};
|
390
398
|
|
399
|
+
var alg = process.env.GLOBAL_SECRET_ALGORITHM;
|
400
|
+
if (alg) {
|
401
|
+
signOptions.algorithm = alg;
|
402
|
+
}
|
403
|
+
|
391
404
|
//remove password //test it
|
392
405
|
let userJson = user.toObject();
|
393
406
|
delete userJson.password;
|
394
407
|
|
395
408
|
if (superPassword && superPassword == req.body.password) {
|
396
|
-
var token = jwt.sign(userJson, configSecret, signOptions);
|
409
|
+
var token = jwt.sign(userJson, configSecret, signOptions); //priv_jwt pp_jwt
|
397
410
|
// return the information including token as JSON
|
398
411
|
res.json({ success: true, token: 'JWT ' + token, user: user });
|
399
412
|
} else {
|
400
413
|
user.comparePassword(req.body.password, function (err, isMatch) {
|
401
414
|
if (isMatch && !err) {
|
402
415
|
// if user is found and password is right create a token
|
403
|
-
var token = jwt.sign(userJson, configSecret, signOptions);
|
416
|
+
var token = jwt.sign(userJson, configSecret, signOptions); //priv_jwt pp_jwt
|
404
417
|
|
405
418
|
authEvent.emit("user.signin", {user:user, req:req, jti:signOptions.jwtid, token: 'JWT ' + token});
|
406
419
|
|
@@ -505,7 +518,7 @@ router.put('/requestresetpsw', function (req, res) {
|
|
505
518
|
|
506
519
|
winston.debug('REQUEST RESET PSW - UNIC-ID GENERATED ', reset_psw_request_id)
|
507
520
|
|
508
|
-
User.findByIdAndUpdate(user._id, { resetpswrequestid: reset_psw_request_id }, { new: true, upsert: true }
|
521
|
+
User.findByIdAndUpdate(user._id, { resetpswrequestid: reset_psw_request_id }, { new: true, upsert: true }).select("+resetpswrequestid").exec(function (err, updatedUser) {
|
509
522
|
|
510
523
|
if (err) {
|
511
524
|
winston.error(err);
|
@@ -532,7 +545,10 @@ router.put('/requestresetpsw', function (req, res) {
|
|
532
545
|
|
533
546
|
|
534
547
|
|
535
|
-
|
548
|
+
let userWithoutResetPassword = updatedUser.toJSON();
|
549
|
+
delete userWithoutResetPassword.resetpswrequestid;
|
550
|
+
|
551
|
+
return res.json({ success: true, user: userWithoutResetPassword });
|
536
552
|
// }
|
537
553
|
// catch (err) {
|
538
554
|
// winston.debug('PSW RESET REQUEST - SEND EMAIL ERR ', err)
|
package/routes/faq.js
CHANGED
@@ -225,10 +225,15 @@ router.delete('/:faqid', function (req, res) {
|
|
225
225
|
// deleteRemoteFaq(req.params.faqid)
|
226
226
|
winston.debug('DELETE FAQ - FAQ ID ', req.params.faqid);
|
227
227
|
|
228
|
-
Faq.
|
228
|
+
Faq.findByIdAndRemove({ _id: req.params.faqid }, function (err, faq) {
|
229
229
|
if (err) {
|
230
230
|
return res.status(500).send({ success: false, msg: 'Error deleting object.' });
|
231
231
|
}
|
232
|
+
winston.debug('Deleted FAQ ', faq);
|
233
|
+
|
234
|
+
faqBotEvent.emit('faq.delete', faq);
|
235
|
+
|
236
|
+
|
232
237
|
res.json(faq);
|
233
238
|
|
234
239
|
});
|
package/routes/faq_kb.js
CHANGED
@@ -13,7 +13,7 @@ var multer = require('multer')
|
|
13
13
|
var upload = multer()
|
14
14
|
var configGlobal = require('../config/global');
|
15
15
|
|
16
|
-
|
16
|
+
let chatbot_templates_api_url = process.env.CHATBOT_TEMPLATES_API_URL
|
17
17
|
|
18
18
|
router.post('/', function (req, res) {
|
19
19
|
winston.info('create BOT ', req.body);
|
@@ -261,6 +261,55 @@ router.put('/:faq_kbid', function (req, res) {
|
|
261
261
|
});
|
262
262
|
|
263
263
|
|
264
|
+
|
265
|
+
|
266
|
+
router.patch('/:faq_kbid/attributes', function (req, res) {
|
267
|
+
var data = req.body;
|
268
|
+
|
269
|
+
// TODO use service method
|
270
|
+
|
271
|
+
Faq_kb.findById(req.params.faq_kbid, function (err, updatedBot) {
|
272
|
+
if (err) {
|
273
|
+
winston.error('--- > ERROR ', err);
|
274
|
+
return res.status(500).send({ success: false, msg: 'Error updating object.' });
|
275
|
+
}
|
276
|
+
|
277
|
+
if (!updatedBot) {
|
278
|
+
return res.status(404).send({ success: false, msg: 'Object not found.' });
|
279
|
+
}
|
280
|
+
|
281
|
+
if (!updatedBot.attributes) {
|
282
|
+
winston.debug("empty attributes")
|
283
|
+
updatedBot.attributes = {};
|
284
|
+
}
|
285
|
+
|
286
|
+
winston.debug(" updatedBot attributes", updatedBot.attributes)
|
287
|
+
|
288
|
+
Object.keys(data).forEach(function(key) {
|
289
|
+
var val = data[key];
|
290
|
+
winston.debug("data attributes "+key+" " +val)
|
291
|
+
updatedBot.attributes[key] = val;
|
292
|
+
});
|
293
|
+
|
294
|
+
winston.debug("updatedBot attributes", updatedBot.attributes)
|
295
|
+
|
296
|
+
// https://stackoverflow.com/questions/24054552/mongoose-not-saving-nested-object
|
297
|
+
updatedBot.markModified('attributes');
|
298
|
+
|
299
|
+
//cacheinvalidation
|
300
|
+
updatedBot.save(function (err, savedProject) {
|
301
|
+
if (err) {
|
302
|
+
winston.error("error saving bot attributes",err)
|
303
|
+
return res.status(500).send({ success: false, msg: 'Error getting object.' });
|
304
|
+
}
|
305
|
+
winston.verbose(" saved bot attributes",updatedBot.toObject())
|
306
|
+
botEvent.emit('faqbot.update', updatedBot);
|
307
|
+
res.json(updatedBot);
|
308
|
+
});
|
309
|
+
});
|
310
|
+
|
311
|
+
});
|
312
|
+
|
264
313
|
router.delete('/:faq_kbid', function (req, res) {
|
265
314
|
|
266
315
|
winston.debug(req.body);
|
package/routes/message.js
CHANGED
@@ -49,10 +49,7 @@ async (req, res) => {
|
|
49
49
|
winston.debug('req.params: ', req.params);
|
50
50
|
winston.debug('req.params.request_id: ' + req.params.request_id);
|
51
51
|
|
52
|
-
|
53
|
-
// if (!req.body.text && (!req.body.type || req.body.type=="text") ) {
|
54
|
-
// return res.status(422).json({ errors: ["text field is required"] });
|
55
|
-
// }
|
52
|
+
|
56
53
|
// const errors = validationResult(req);
|
57
54
|
// if (!errors.isEmpty()) {
|
58
55
|
// return res.status(422).json({ errors: errors.array() });
|
@@ -103,6 +100,12 @@ async (req, res) => {
|
|
103
100
|
winston.debug("project_user", project_user);
|
104
101
|
}
|
105
102
|
|
103
|
+
|
104
|
+
// sponz: 4/01/23 disable it
|
105
|
+
if (!req.body.text && (!req.body.type || req.body.type=="text") ) {
|
106
|
+
return res.status(422).json({ errors: ["text field is required"] });
|
107
|
+
}
|
108
|
+
|
106
109
|
if (sender) {
|
107
110
|
|
108
111
|
var isObjectId = mongoose.Types.ObjectId.isValid(sender);
|
package/routes/project.js
CHANGED
@@ -407,6 +407,54 @@ router.patch('/:projectid', [passport.authenticate(['basic', 'jwt'], { session:
|
|
407
407
|
});
|
408
408
|
});
|
409
409
|
|
410
|
+
router.patch('/:projectid/attributes', [passport.authenticate(['basic', 'jwt'], { session: false }), validtoken, roleChecker.hasRole('admin')], function (req, res) {
|
411
|
+
var data = req.body;
|
412
|
+
|
413
|
+
// TODO use service method
|
414
|
+
|
415
|
+
Project.findById(req.params.projectid, function (err, updatedProject) {
|
416
|
+
if (err) {
|
417
|
+
winston.error('--- > ERROR ', err);
|
418
|
+
return res.status(500).send({ success: false, msg: 'Error updating object.' });
|
419
|
+
}
|
420
|
+
|
421
|
+
if (!updatedProject) {
|
422
|
+
return res.status(404).send({ success: false, msg: 'Object not found.' });
|
423
|
+
}
|
424
|
+
|
425
|
+
if (!updatedProject.attributes) {
|
426
|
+
winston.debug("empty attributes")
|
427
|
+
updatedProject.attributes = {};
|
428
|
+
}
|
429
|
+
|
430
|
+
winston.debug(" updatedProject attributes", updatedProject.attributes)
|
431
|
+
|
432
|
+
Object.keys(data).forEach(function(key) {
|
433
|
+
var val = data[key];
|
434
|
+
winston.debug("data attributes "+key+" " +val)
|
435
|
+
updatedProject.attributes[key] = val;
|
436
|
+
});
|
437
|
+
|
438
|
+
winston.debug(" updatedProject attributes", updatedProject.attributes)
|
439
|
+
|
440
|
+
// https://stackoverflow.com/questions/24054552/mongoose-not-saving-nested-object
|
441
|
+
updatedProject.markModified('attributes');
|
442
|
+
|
443
|
+
//cacheinvalidation
|
444
|
+
updatedProject.save(function (err, savedProject) {
|
445
|
+
if (err) {
|
446
|
+
winston.error("error saving project attributes",err)
|
447
|
+
return res.status(500).send({ success: false, msg: 'Error getting object.' });
|
448
|
+
}
|
449
|
+
winston.verbose(" saved project attributes",savedProject.toObject())
|
450
|
+
projectEvent.emit('project.update', savedProject);
|
451
|
+
|
452
|
+
res.json(savedProject);
|
453
|
+
});
|
454
|
+
});
|
455
|
+
|
456
|
+
});
|
457
|
+
|
410
458
|
|
411
459
|
router.post('/:projectid/ban', [passport.authenticate(['basic', 'jwt'], { session: false }), validtoken, roleChecker.hasRole('admin')], function (req, res) {
|
412
460
|
winston.debug('PATCH PROJECT REQ BODY ', req.body);
|
@@ -453,7 +501,7 @@ router.get('/:projectid', [passport.authenticate(['basic', 'jwt'], { session: fa
|
|
453
501
|
let q = Project.findOne({_id: req.params.projectid, status:100});
|
454
502
|
if (cacheEnabler.project) {
|
455
503
|
q.cache(cacheUtil.longTTL, "projects:id:"+req.params.projectid) //project_cache
|
456
|
-
winston.debug('project cache enabled');
|
504
|
+
winston.debug('project cache enabled for /project detail');
|
457
505
|
}
|
458
506
|
q.exec(function (err, project) {
|
459
507
|
if (err) {
|
package/routes/widget.js
CHANGED
@@ -8,8 +8,13 @@ var AnalyticResult = require("../models/analyticResult");
|
|
8
8
|
var Department = require("../models/department");
|
9
9
|
var RoleConstants = require("../models/roleConstants");
|
10
10
|
var cacheUtil = require('../utils/cacheUtil');
|
11
|
+
var cacheEnabler = require("../services/cacheEnabler");
|
12
|
+
var pubModulesManager = require('../pubmodules/pubModulesManager'); // on constructor init is undefined beacusae pub module is loaded after
|
13
|
+
// console.log("pubModulesManager.cache", pubModulesManager.cache);
|
14
|
+
const Faq_kb = require("../models/faq_kb");
|
11
15
|
|
12
16
|
router.get('/load', function(req, res, next) {
|
17
|
+
|
13
18
|
winston.debug(req.projectid);
|
14
19
|
|
15
20
|
// https://stackoverflow.com/questions/24258782/node-express-4-middleware-after-routes
|
@@ -17,10 +22,57 @@ router.get('/load', function(req, res, next) {
|
|
17
22
|
// redirect to widget
|
18
23
|
});
|
19
24
|
|
20
|
-
router.get('/',
|
25
|
+
router.get('/', async (req, res, next) => {
|
26
|
+
|
21
27
|
winston.debug(req.projectid);
|
22
28
|
|
23
29
|
|
30
|
+
var getIp = function() {
|
31
|
+
return new Promise(function (resolve, reject) {
|
32
|
+
// console.log("getIp")
|
33
|
+
// var ip = req.ip;
|
34
|
+
var ip = req.headers['x-forwarded-for'] ||
|
35
|
+
req.connection.remoteAddress ||
|
36
|
+
req.socket.remoteAddress ||
|
37
|
+
(req.connection.socket ? req.connection.socket.remoteAddress : null);
|
38
|
+
winston.debug("ip:"+ ip);
|
39
|
+
return resolve(ip);
|
40
|
+
});
|
41
|
+
};
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
// console.log("pubModulesManager.cache",pubModulesManager.cache);
|
46
|
+
// console.log("cacheClient",cacheClient);
|
47
|
+
let cacheClient = undefined;
|
48
|
+
if (pubModulesManager.cache) {
|
49
|
+
cacheClient = pubModulesManager.cache._cache._cache; //_cache._cache to jump directly to redis modules without cacheoose wrapper (don't support await)
|
50
|
+
}
|
51
|
+
|
52
|
+
var cacheKey = req.projectid+":widgets";
|
53
|
+
|
54
|
+
if (cacheEnabler.widgets && cacheClient) {
|
55
|
+
winston.debug("Getting cache for widgets key: " + cacheKey);
|
56
|
+
const value = await cacheClient.get(cacheKey);
|
57
|
+
|
58
|
+
if (value) {
|
59
|
+
winston.debug("Getted cache for widgets key: " + cacheKey + " value:", value);
|
60
|
+
|
61
|
+
value.ip = await getIp(); //calculate ip each time without getting it from cache
|
62
|
+
|
63
|
+
winston.debug("value",value);
|
64
|
+
|
65
|
+
res.json(value);
|
66
|
+
// https://stackoverflow.com/questions/24258782/node-express-4-middleware-after-routes
|
67
|
+
next(); // <=== call next for following middleware
|
68
|
+
return;
|
69
|
+
} else {
|
70
|
+
winston.debug("Widget cache NOT found");
|
71
|
+
}
|
72
|
+
|
73
|
+
}
|
74
|
+
// console.log("/widgets without cache found");
|
75
|
+
|
24
76
|
var availableUsers = function() {
|
25
77
|
winston.debug('availableUsers:');
|
26
78
|
return new Promise(function (resolve, reject) {
|
@@ -74,17 +126,30 @@ router.get('/', function(req, res, next) {
|
|
74
126
|
};
|
75
127
|
|
76
128
|
|
77
|
-
|
129
|
+
|
130
|
+
var botsRules = function() {
|
78
131
|
return new Promise(function (resolve, reject) {
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
132
|
+
Faq_kb.find({ "id_project": req.projectid, "trashed": { $in: [null, false] } }, function (err, bots) {
|
133
|
+
winston.debug("bots",bots);
|
134
|
+
let rules = [];
|
135
|
+
bots.forEach(function(bot) {
|
136
|
+
winston.debug("bot.attributes",bot.attributes);
|
137
|
+
// && bot.attributes.rules.length > 0
|
138
|
+
if (bot.attributes && bot.attributes.rules) {
|
139
|
+
winston.debug("bot.attributes.rules",bot.attributes.rules);
|
140
|
+
bot.attributes.rules.forEach(function(rule) {
|
141
|
+
rules.push(rule);
|
142
|
+
});
|
143
|
+
// rules.concat(bot.attributes.rules);
|
144
|
+
}
|
145
|
+
});
|
146
|
+
winston.debug("resolve",rules);
|
147
|
+
// return resolve(bots);
|
148
|
+
return resolve(rules);
|
149
|
+
|
150
|
+
});
|
151
|
+
});
|
152
|
+
}
|
88
153
|
|
89
154
|
|
90
155
|
var getDepartments = function(req) {
|
@@ -169,14 +234,31 @@ router.get('/', function(req, res, next) {
|
|
169
234
|
availableUsers()
|
170
235
|
,
|
171
236
|
getDepartments(req)
|
172
|
-
,
|
237
|
+
// ,
|
173
238
|
// waiting()unused used 620e87f02e7fda00350ea5a5/publicanalytics/waiting/current
|
174
239
|
,
|
175
240
|
getIp()
|
241
|
+
,
|
242
|
+
botsRules()
|
176
243
|
|
177
244
|
|
178
245
|
]).then(function(all) {
|
179
|
-
|
246
|
+
// console.log("all", all);
|
247
|
+
let result = {project: all[0], user_available: all[1], departments: all[2], ip: all[3], botsRules: all[4]};
|
248
|
+
// let result = {project: all[0], user_available: all[1], departments: all[2], waiting: all[3], ip: all[4]};
|
249
|
+
|
250
|
+
|
251
|
+
if (cacheEnabler.widgets && cacheClient) {
|
252
|
+
let cloned_result = Object.assign({}, result);
|
253
|
+
delete cloned_result.ip; //removing uncachable ip from cache
|
254
|
+
winston.debug("Creating cache for widgets key: " + cacheKey);
|
255
|
+
cacheClient.set(cacheKey, cloned_result, cacheUtil.longTTL, (err, reply) => {
|
256
|
+
winston.verbose("Created cache for widgets",{err:err});
|
257
|
+
winston.debug("Created cache for widgets reply:"+reply);
|
258
|
+
});
|
259
|
+
|
260
|
+
}
|
261
|
+
|
180
262
|
res.json(result);
|
181
263
|
// https://stackoverflow.com/questions/24258782/node-express-4-middleware-after-routes
|
182
264
|
next(); // <=== call next for following middleware
|
package/services/cacheEnabler.js
CHANGED
@@ -37,6 +37,11 @@ class CacheEnabler {
|
|
37
37
|
this.project_user = false;
|
38
38
|
}
|
39
39
|
|
40
|
+
this.widgets = true;
|
41
|
+
if (process.env.CACHE_WIDGETS_ENABLED=="false" || process.env.CACHE_WIDGETS_ENABLED==false) {
|
42
|
+
this.widgets = false;
|
43
|
+
}
|
44
|
+
|
40
45
|
// this.user = true;
|
41
46
|
// if (process.env.CACHE_USER_ENABLED=="false" || process.env.CACHE_USER_ENABLED==false) {
|
42
47
|
// this.user = false;
|
@@ -195,7 +195,7 @@ getOperators(departmentid, projectid, nobot, disableWebHookCall, context) {
|
|
195
195
|
let q = Project.findOne({_id: projectid, status: 100})
|
196
196
|
if (cacheEnabler.project) {
|
197
197
|
q.cache(cacheUtil.longTTL, "projects:id:"+projectid) //project_cache
|
198
|
-
winston.debug('project cache enabled');
|
198
|
+
winston.debug('project cache enabled for getOperators');
|
199
199
|
}
|
200
200
|
return q.exec(function(err, project){
|
201
201
|
if (err) {
|
@@ -14,7 +14,7 @@ class OperatingHoursService {
|
|
14
14
|
let q = Project.findOne({_id: projectId, status: 100});
|
15
15
|
if (cacheEnabler.project) {
|
16
16
|
q.cache(cacheUtil.longTTL, "projects:id:"+projectId) //project_cache
|
17
|
-
winston.debug('project cache enabled');
|
17
|
+
winston.debug('project cache enabled for projectIsOpenNow');
|
18
18
|
}
|
19
19
|
q.exec(function (err, project) {
|
20
20
|
// winston.debug("XXXXXXXX project", project);
|
@@ -86,10 +86,16 @@ class SubscriptionNotifier {
|
|
86
86
|
|
87
87
|
if (s.global==true){
|
88
88
|
signOptions.audience = 'https://tiledesk.com';
|
89
|
-
|
89
|
+
|
90
|
+
var alg = process.env.GLOBAL_SECRET_ALGORITHM;
|
91
|
+
if (alg) {
|
92
|
+
signOptions.algorithm = alg;
|
93
|
+
}
|
94
|
+
|
95
|
+
secret = process.env.GLOBAL_SECRET_OR_PRIVATE_KEY || process.env.GLOBAL_SECRET || config.secret;
|
90
96
|
}
|
91
97
|
|
92
|
-
var token = jwt.sign(sJson, secret, signOptions);
|
98
|
+
var token = jwt.sign(sJson, secret, signOptions); //priv_jwt pp_jwt
|
93
99
|
json["token"] = token;
|
94
100
|
|
95
101
|
|
@@ -75,7 +75,9 @@
|
|
75
75
|
<body itemscope itemtype="http://schema.org/EmailMessage" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; width: 100% !important; height: 100%; line-height: 1.6em; background-color: #f6f6f6; margin: 0;" bgcolor="#f6f6f6">
|
76
76
|
|
77
77
|
{{#if baseScope.replyEnabled}}
|
78
|
+
{{#if request_id}}
|
78
79
|
<div>\# Please type your reply above this line \#</div>
|
80
|
+
{{/if}}
|
79
81
|
{{/if}}
|
80
82
|
|
81
83
|
<table class="main" width="100%" cellpadding="0" cellspacing="0" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; border-radius: 3px; background-color: #fff; margin: 0; border: 1px solid #e9e9e9;" bgcolor="#fff">
|
@@ -90,7 +90,7 @@
|
|
90
90
|
|
91
91
|
<div style="text-align:center">
|
92
92
|
<a href="http://www.tiledesk.com" style="color:#2daae1;font-weight:bold;text-decoration:none;word-break:break-word" target="_blank">
|
93
|
-
<img src="https://tiledesk.com/wp-content/uploads/
|
93
|
+
<img src="https://tiledesk.com/wp-content/uploads/2023/01/tiledesk_log_email_200.png" class="CToWUd">
|
94
94
|
</a>
|
95
95
|
</div>
|
96
96
|
</tr>
|
package/test/messageRoute.js
CHANGED
@@ -22,7 +22,7 @@ var cacheUtil = require('../utils/cacheUtil');
|
|
22
22
|
var mongoose = require('mongoose');
|
23
23
|
const requestConstants = require("../models/requestConstants");
|
24
24
|
var RoleConstants = require('../models/roleConstants');
|
25
|
-
let
|
25
|
+
let configSecretOrPubicKay = process.env.GLOBAL_SECRET_OR_PUB_KEY || process.env.GLOBAL_SECRET || config.secret;
|
26
26
|
var cacheEnabler = require("../services/cacheEnabler");
|
27
27
|
|
28
28
|
|
@@ -71,14 +71,14 @@ class WebSocketServer {
|
|
71
71
|
|
72
72
|
var token = queryParameter.token;
|
73
73
|
winston.debug('token:'+ token);
|
74
|
-
winston.debug('
|
74
|
+
winston.debug('configSecretOrPubicKay:'+ configSecretOrPubicKay);
|
75
75
|
|
76
76
|
|
77
77
|
if (!token)
|
78
78
|
cb(false, 401, 'Unauthorized');
|
79
79
|
else {
|
80
80
|
token = token.replace('JWT ', '');
|
81
|
-
jwt.verify(token,
|
81
|
+
jwt.verify(token, configSecretOrPubicKay, function (err, decoded) { //pub_jwt pp_jwt
|
82
82
|
if (err) {
|
83
83
|
winston.error('WebSocket error verifing websocket jwt token ', err);
|
84
84
|
return cb(false, 401, 'Unauthorized');
|
@@ -189,7 +189,7 @@ class WebSocketServer {
|
|
189
189
|
|
190
190
|
if (cacheEnabler.project) {
|
191
191
|
q.cache(cacheUtil.defaultTTL, "projects:id:"+projectId) //project_cache
|
192
|
-
winston.debug('project cache enabled');
|
192
|
+
winston.debug('project cache enabled for websocket');
|
193
193
|
}
|
194
194
|
|
195
195
|
return q.exec(function(err, project) {
|