@tiledesk/tiledesk-server 2.3.71 → 2.3.73

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -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) {
@@ -5,7 +5,7 @@ var winston = require('../config/winston');
5
5
  var PresenceSchema = new Schema({
6
6
  status: {
7
7
  type: String,
8
- default: 'offline',
8
+ default: 'offline', //online
9
9
  required: true,
10
10
  index: true
11
11
  },
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
@@ -31,6 +31,7 @@ var UserSchema = new Schema({
31
31
  },
32
32
  resetpswrequestid: {
33
33
  type: String,
34
+ select: false
34
35
  },
35
36
  signedInAt: {
36
37
  type:Date
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.71",
4
+ "version": "2.3.73",
5
5
  "scripts": {
6
6
  "start": "node ./bin/www",
7
7
  "pretest": "mongodb-runner start",
@@ -36,13 +36,14 @@
36
36
  "@tiledesk-ent/tiledesk-server-enterprise": "^1.0.0"
37
37
  },
38
38
  "dependencies": {
39
- "@tiledesk/tiledesk-apps": "^1.0.9",
39
+ "@tiledesk/tiledesk-apps": "^1.0.12",
40
40
  "@tiledesk/tiledesk-whatsapp-connector": "^0.1.19",
41
+ "@tiledesk/tiledesk-kaleyra-proxy": "^0.1.6",
41
42
  "@tiledesk/tiledesk-chat21-app": "^1.1.7",
42
43
  "@tiledesk/tiledesk-chatbot-util": "^0.8.33",
43
44
  "@tiledesk/tiledesk-json-rules-engine": "^4.0.3",
44
45
  "@tiledesk/tiledesk-rasa-connector": "^1.0.10",
45
- "@tiledesk/tiledesk-tybot-connector": "^0.1.42",
46
+ "@tiledesk/tiledesk-tybot-connector": "^0.1.49",
46
47
  "@tiledesk/tiledesk-dialogflow-connector": "^1.8.3",
47
48
  "app-root-path": "^3.0.0",
48
49
  "bcrypt-nodejs": "0.0.3",
@@ -76,7 +77,6 @@
76
77
  "moment": "^2.29.3",
77
78
  "moment-timezone": "^0.5.33",
78
79
  "mongoose": "^5.13.14",
79
- "mongoose-auto-increment": "^5.0.1",
80
80
  "mongoose-sequence": "^5.3.1",
81
81
  "morgan": "^1.10.0",
82
82
  "multer": "^1.4.4",
@@ -83,6 +83,8 @@ var ActivitySchema = new Schema({
83
83
  }
84
84
  );
85
85
 
86
+ ActivitySchema.index({id_project: 1, createdAt: -1});
87
+
86
88
  // TODO metti indice per query è lentina
87
89
 
88
90
  module.exports = mongoose.model('activity', ActivitySchema);
@@ -14,6 +14,7 @@ class Listener {
14
14
  apps.startApp({
15
15
  ACCESS_TOKEN_SECRET: process.env.APPS_ACCESS_TOKEN_SECRET || 'nodeauthsecret',
16
16
  MONGODB_URI: process.env.APPS_MONGODB_URI || config.databaseUri,
17
+ KALEYRA_ENABLED: process.env.KALEYRA_ENABLED || config.kaleyra_enabled
17
18
  }, () => {
18
19
  winston.info("Tiledesk Apps proxy server succesfully started.")
19
20
  })
@@ -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.create with key: " + key);
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.create",reply);
55
- winston.verbose("Deleted cache for project.create",{err:err});
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.create with key: " + key);
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.create",reply);
93
- winston.verbose("Deleted cache for project.create",{err:err});
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:id:"+request.request_id+":simple"; //without project for chat21 webhook
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.create with key: " + key);
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.create",reply);
304
- winston.verbose("Deleted cache for request.create",{err:err});
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.create",reply);
330
- winston.verbose("Deleted cache for request.create",{err:err});
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("Creating cache for faqbot.delete with key: " + key);
386
- client.set(key, faq_kb, cacheUtil.defaultTTL, (err, reply) => {
387
- winston.debug("Created cache for faqbot.delete",reply);
388
- winston.verbose("Created cache for faqbot.delete",{err:err});
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("Creating cache for department.delete with key: " + key);
437
- client.set(key, department, cacheUtil.defaultTTL, (err, reply) => {
438
- winston.debug("Created cache for department.delete",reply);
439
- winston.verbose("Created cache for department.delete",{err:err});
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="
@@ -0,0 +1,6 @@
1
+ const listener = require('./listener');
2
+
3
+ const kaleyra = require('@tiledesk/tiledesk-kaleyra-proxy');
4
+ const kaleyraRoute = kaleyra.router;
5
+
6
+ module.exports = { listener: listener, kaleyraRoute: kaleyraRoute }
@@ -0,0 +1,32 @@
1
+ const kaleyra = require("@tiledesk/tiledesk-kaleyra-proxy");
2
+ var winston = require('../../config/winston');
3
+ var configGlobal = require('../../config/global');
4
+
5
+ const apiUrl = process.env.API_URL || configGlobal.apiUrl;
6
+ winston.info("Kaleyra apiUrl: " + apiUrl);
7
+
8
+ class Listener {
9
+
10
+ listen(config) {
11
+ winston.info("Kaleyra Listener listen");
12
+ if (config.databaseUri) {
13
+ winston.debug("kaleyra config databaseUri: " + config.databaseUri);
14
+ }
15
+
16
+ kaleyra.startApp({
17
+ MONGODB_URL: config.databaseUri,
18
+ API_URL: apiUrl,
19
+ BASE_URL: apiUrl + "/modules/kaleyra",
20
+ APPS_API_URL: apiUrl + "/modules/apps",
21
+ KALEYRA_API_URL: process.env.KALEYRA_API_URL,
22
+ API_KEY: process.env.API_KEY,
23
+ log: process.env.KALEYRA_LOG
24
+ }, () => {
25
+ winston.info("Tiledesk Kaleyra proxy server succesfully started.");
26
+ })
27
+ }
28
+ }
29
+
30
+ var listener = new Listener();
31
+
32
+ module.exports = listener;
@@ -27,6 +27,9 @@ class PubModulesManager {
27
27
  this.whatsapp = undefined;
28
28
  this.whatsappRoute = undefined;
29
29
 
30
+ this.kaleyra = undefined;
31
+ this.kaleyraRoute = undefined;
32
+
30
33
  this.activityArchiver = undefined;
31
34
  this.activityRoute = undefined;
32
35
 
@@ -57,24 +60,28 @@ class PubModulesManager {
57
60
 
58
61
  if (this.rasaRoute) {
59
62
  app.use('/modules/rasa', this.rasaRoute);
60
- winston.info("ModulesManager rasaRoute controller loaded");
63
+ winston.info("PubModulesManager rasaRoute controller loaded");
61
64
  }
62
65
  if (this.appsRoute) {
63
66
  app.use('/modules/apps', this.appsRoute);
64
- winston.info("ModulesManager appsRoute controller loaded");
67
+ winston.info("PubModulesManager appsRoute controller loaded");
65
68
  }
66
69
  if (this.whatsappRoute) {
67
70
  app.use('/modules/whatsapp', this.whatsappRoute);
68
- winston.info("ModulesManager whatsappRoute controller loaded");
71
+ winston.info("PubModulesManager whatsappRoute controller loaded");
72
+ }
73
+ if (this.kaleyraRoute) {
74
+ app.use('/modules/kaleyra', this.kaleyraRoute);
75
+ winston.info("PubModulesManager kaleyraRoute controller loaded");
69
76
  }
70
77
  if (this.tilebotRoute) {
71
78
  app.use('/modules/tilebot', this.tilebotRoute);
72
- winston.info("ModulesManager tilebot controller loaded");
79
+ winston.info("PubModulesManager tilebot controller loaded");
73
80
  }
74
-
81
+
75
82
  if (this.dialogFlow) {
76
83
  app.use("/modules/dialogFlow", this.dialogFlow.dialogflowRoute);
77
- winston.info("ModulesManager dialogFlow controller loaded");
84
+ winston.info("PubModulesManager dialogFlow controller loaded");
78
85
  }
79
86
 
80
87
  }
@@ -263,6 +270,21 @@ class PubModulesManager {
263
270
  }
264
271
  }
265
272
 
273
+ try {
274
+ this.kaleyra = require('./kaleyra');
275
+ winston.debug("this.kaleyra: " + this.kaleyra);
276
+ this.kaleyra.listener.listen(config);
277
+
278
+ this.kaleyraRoute = this.kaleyra.kaleyraRoute;
279
+
280
+ winston.info("PubModulesManager initialized apps.");
281
+ } catch(err) {
282
+ if (err.code == 'MODULE_NOT_FOUND') {
283
+ winston.info("PubModulesManager init apps module not found");
284
+ }else {
285
+ winston.info("PubModulesManager error initializing init apps module", err);
286
+ }
287
+ }
266
288
 
267
289
  try {
268
290
  this.activityArchiver = require('./activities').activityArchiver;