@tiledesk/tiledesk-server 2.7.14 → 2.7.16

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -5,11 +5,17 @@
5
5
  🚀 IN PRODUCTION 🚀
6
6
  (https://www.npmjs.com/package/@tiledesk/tiledesk-server/v/2.3.77)
7
7
 
8
- # 2.7.13
9
- - Updated whatsapp-connector to 0.2.68
8
+ # 2.7.16
9
+ - Updated tybot-connector to 0.2.63
10
+
11
+ # 2.7.15
12
+ - Updated whatsapp-connector to 0.1.69
13
+
14
+ # 2.7.14
15
+ - Updated whatsapp-connector to 0.1.68
10
16
 
11
17
  # 2.7.13
12
- - Updated whatsapp-connector to 0.2.67
18
+ - Updated whatsapp-connector to 0.1.67
13
19
 
14
20
  # 2.7.12
15
21
  - Updated tybot-connector to 0.2.62
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.7.14",
4
+ "version": "2.7.16",
5
5
  "scripts": {
6
6
  "start": "node ./bin/www",
7
7
  "pretest": "mongodb-runner start",
@@ -48,8 +48,8 @@
48
48
  "@tiledesk/tiledesk-rasa-connector": "^1.0.10",
49
49
  "@tiledesk/tiledesk-telegram-connector": "^0.1.12",
50
50
  "@tiledesk/tiledesk-train-jobworker": "^0.0.7",
51
- "@tiledesk/tiledesk-tybot-connector": "^0.2.62",
52
- "@tiledesk/tiledesk-whatsapp-connector": "^0.1.68",
51
+ "@tiledesk/tiledesk-tybot-connector": "^0.2.63",
52
+ "@tiledesk/tiledesk-whatsapp-connector": "^0.1.69",
53
53
  "@tiledesk/tiledesk-whatsapp-jobworker": "^0.0.7",
54
54
  "amqplib": "^0.5.5",
55
55
  "app-root-path": "^3.0.0",
package/routes/request.js CHANGED
@@ -1492,5 +1492,27 @@ router.get('/:requestid', function (req, res) {
1492
1492
  });
1493
1493
  });
1494
1494
 
1495
+ router.get('/:requestid/chatbot/parameters', async (req, res) => {
1496
+
1497
+ let project_id = req.projectid;
1498
+ let request_id = req.params.requestid;
1499
+
1500
+ let split_pattern = /-/
1501
+ let splitted = request_id.split(split_pattern);
1502
+
1503
+ if (project_id !== splitted[2]) {
1504
+ return res.status(401).send({ success: false, message: "Request does not belong to the project"})
1505
+ }
1506
+
1507
+ requestService.getRequestParametersFromChatbot(request_id).then((parameters) => {
1508
+ res.status(200).send(parameters);
1509
+
1510
+ }).catch((err) => {
1511
+ console.error("err: ", err.response)
1512
+ res.status(400).send(err);
1513
+ })
1514
+
1515
+ })
1516
+
1495
1517
 
1496
1518
  module.exports = router;
@@ -139,10 +139,10 @@ class EmailService {
139
139
 
140
140
  }
141
141
 
142
- readTemplate(templateName, settings) {
142
+ readTemplate(templateName, settings, environmentVariableKey) {
143
143
  // aggiunsta questo
144
144
  var that = this;
145
- winston.debug('EmailService readTemplate: ' + templateName + ' ' + JSON.stringify(settings));
145
+ winston.debug('EmailService readTemplate: ' + templateName + ' environmentVariableKey: ' + environmentVariableKey + ' setting ' + JSON.stringify(settings));
146
146
 
147
147
 
148
148
  if (settings && settings.email && settings.email.templates) {
@@ -162,11 +162,24 @@ class EmailService {
162
162
  return new Promise(function (resolve, reject) {
163
163
  return resolve(template);
164
164
  });
165
+ }
166
+ // else {
167
+ // return that.readTemplateFile(templateName);
168
+ // }
169
+ } else {
170
+ var envTemplate = process.env[environmentVariableKey];
171
+ winston.debug('EmailService envTemplate: ' + envTemplate);
172
+
173
+ if (envTemplate) {
174
+ winston.debug('EmailService return envTemplate: ' + envTemplate);
175
+
176
+ return envTemplate;
165
177
  } else {
178
+ winston.debug('EmailService return file: ' + templateName);
179
+
166
180
  return that.readTemplateFile(templateName);
167
181
  }
168
- } else {
169
- return that.readTemplateFile(templateName);
182
+
170
183
  }
171
184
  }
172
185
  readTemplateFile(templateName) {
@@ -328,7 +341,8 @@ class EmailService {
328
341
 
329
342
  var that = this;
330
343
 
331
- var html = await this.readTemplate('test.html', { "email": { "templates": { test: "123" } } });
344
+ // var html = await this.readTemplate('test.html', { "email": { "templates": { test: "123" } } }, "EMAIL_TEST_HTML_TEMPLATE");
345
+ var html = await this.readTemplate('test.html', undefined, "EMAIL_TEST_HTML_TEMPLATE");
332
346
 
333
347
  var template = handlebars.compile(html);
334
348
 
@@ -356,14 +370,7 @@ class EmailService {
356
370
  project = project.toJSON();
357
371
  }
358
372
 
359
- var html = await this.readTemplate('assignedRequest.html', project.settings);
360
-
361
- var envTemplate = process.env.EMAIL_ASSIGN_REQUEST_HTML_TEMPLATE;
362
- winston.debug("envTemplate: " + envTemplate);
363
-
364
- if (envTemplate) {
365
- html = envTemplate;
366
- }
373
+ var html = await this.readTemplate('assignedRequest.html', project.settings, "EMAIL_ASSIGN_REQUEST_HTML_TEMPLATE");
367
374
 
368
375
  winston.debug("html: " + html);
369
376
 
@@ -516,15 +523,7 @@ class EmailService {
516
523
  project = project.toJSON();
517
524
  }
518
525
 
519
- var html = await this.readTemplate('assignedEmailMessage.html', project.settings);
520
-
521
-
522
- var envTemplate = process.env.EMAIL_ASSIGN_MESSAGE_EMAIL_HTML_TEMPLATE;
523
- winston.debug("envTemplate: " + envTemplate);
524
-
525
- if (envTemplate) {
526
- html = envTemplate;
527
- }
526
+ var html = await this.readTemplate('assignedEmailMessage.html', project.settings, "EMAIL_ASSIGN_MESSAGE_EMAIL_HTML_TEMPLATE");
528
527
 
529
528
  winston.debug("html: " + html);
530
529
 
@@ -668,14 +667,7 @@ class EmailService {
668
667
 
669
668
  var that = this;
670
669
 
671
- var html = await this.readTemplate('pooledRequest.html', project.settings);
672
-
673
- var envTemplate = process.env.EMAIL_POOLED_REQUEST_HTML_TEMPLATE;
674
- winston.debug("envTemplate: " + envTemplate);
675
-
676
- if (envTemplate) {
677
- html = envTemplate;
678
- }
670
+ var html = await this.readTemplate('pooledRequest.html', project.settings, "EMAIL_POOLED_REQUEST_HTML_TEMPLATE");
679
671
 
680
672
  winston.debug("html: " + html);
681
673
 
@@ -805,16 +797,7 @@ class EmailService {
805
797
  project = project.toJSON();
806
798
  }
807
799
 
808
- var html = await this.readTemplate('pooledEmailMessage.html', project.settings);
809
-
810
-
811
- var envTemplate = process.env.EMAIL_POOLED_MESSAGE_EMAIL_HTML_TEMPLATE;
812
- winston.debug("envTemplate: " + envTemplate);
813
-
814
-
815
- if (envTemplate) {
816
- html = envTemplate;
817
- }
800
+ var html = await this.readTemplate('pooledEmailMessage.html', project.settings, "EMAIL_POOLED_MESSAGE_EMAIL_HTML_TEMPLATE");
818
801
 
819
802
  winston.debug("html: " + html);
820
803
 
@@ -955,16 +938,7 @@ class EmailService {
955
938
  project = project.toJSON();
956
939
  }
957
940
 
958
- var html = await this.readTemplate('newMessage.html', project.settings);
959
-
960
-
961
-
962
- var envTemplate = process.env.EMAIL_NEW_MESSAGE_HTML_TEMPLATE;
963
- winston.debug("envTemplate: " + envTemplate);
964
-
965
- if (envTemplate) {
966
- html = envTemplate;
967
- }
941
+ var html = await this.readTemplate('newMessage.html', project.settings, "EMAIL_NEW_MESSAGE_HTML_TEMPLATE");
968
942
 
969
943
  winston.debug("html: " + html);
970
944
 
@@ -1088,17 +1062,9 @@ class EmailService {
1088
1062
  project = project.toJSON();
1089
1063
  }
1090
1064
 
1091
- var html = await this.readTemplate('ticket.html', project.settings);
1065
+ var html = await this.readTemplate('ticket.html', project.settings, "EMAIL_TICKET_HTML_TEMPLATE");
1092
1066
  // this.readTemplateFile('ticket.txt', function(err, html) {
1093
1067
 
1094
-
1095
- var envTemplate = process.env.EMAIL_TICKET_HTML_TEMPLATE;
1096
- winston.debug("envTemplate: " + envTemplate);
1097
-
1098
- if (envTemplate) {
1099
- html = envTemplate;
1100
- }
1101
-
1102
1068
  winston.debug("html: " + html);
1103
1069
 
1104
1070
  var template = handlebars.compile(html);
@@ -1273,15 +1239,7 @@ class EmailService {
1273
1239
  project = project.toJSON();
1274
1240
  }
1275
1241
 
1276
- var html = await this.readTemplate('newMessageFollower.html', project.settings);
1277
-
1278
-
1279
- var envTemplate = process.env.EMAIL_FOLLOWER_HTML_TEMPLATE;
1280
- winston.debug("envTemplate: " + envTemplate);
1281
-
1282
- if (envTemplate) {
1283
- html = envTemplate;
1284
- }
1242
+ var html = await this.readTemplate('newMessageFollower.html', project.settings, "EMAIL_FOLLOWER_HTML_TEMPLATE");
1285
1243
 
1286
1244
  winston.debug("html: " + html);
1287
1245
 
@@ -1488,14 +1446,8 @@ class EmailService {
1488
1446
  project = project.toJSON();
1489
1447
  }
1490
1448
 
1491
- var html = await this.readTemplate('emailDirect.html', project.settings);
1492
-
1493
- var envTemplate = process.env.EMAIL_DIRECT_HTML_TEMPLATE;
1494
- winston.debug("envTemplate: " + envTemplate);
1449
+ var html = await this.readTemplate('emailDirect.html', project.settings, "EMAIL_DIRECT_HTML_TEMPLATE");
1495
1450
 
1496
- if (envTemplate) {
1497
- html = envTemplate;
1498
- }
1499
1451
 
1500
1452
  winston.debug("html: " + html);
1501
1453
 
@@ -1580,15 +1532,7 @@ class EmailService {
1580
1532
 
1581
1533
  var that = this;
1582
1534
 
1583
- var html = await this.readTemplate('resetPassword.html');
1584
-
1585
-
1586
- var envTemplate = process.env.EMAIL_RESET_PASSWORD_HTML_TEMPLATE;
1587
- winston.debug("envTemplate: " + envTemplate);
1588
-
1589
- if (envTemplate) {
1590
- html = envTemplate;
1591
- }
1535
+ var html = await this.readTemplate('resetPassword.html', undefined, "EMAIL_RESET_PASSWORD_HTML_TEMPLATE");
1592
1536
 
1593
1537
  winston.debug("html: " + html);
1594
1538
 
@@ -1618,15 +1562,7 @@ class EmailService {
1618
1562
 
1619
1563
  var that = this;
1620
1564
 
1621
- var html = await this.readTemplateFile('passwordChanged.html');
1622
-
1623
-
1624
- var envTemplate = process.env.EMAIL_PASSWORD_CHANGED_HTML_TEMPLATE;
1625
- winston.debug("envTemplate: " + envTemplate);
1626
-
1627
- if (envTemplate) {
1628
- html = envTemplate;
1629
- }
1565
+ var html = await this.readTemplateFile('passwordChanged.html', undefined, "EMAIL_PASSWORD_CHANGED_HTML_TEMPLATE");
1630
1566
 
1631
1567
  winston.debug("html: " + html);
1632
1568
 
@@ -1662,14 +1598,7 @@ class EmailService {
1662
1598
 
1663
1599
  var that = this;
1664
1600
 
1665
- var html = await this.readTemplateFile('beenInvitedExistingUser.html');
1666
-
1667
- var envTemplate = process.env.EMAIL_EXUSER_INVITED_HTML_TEMPLATE;
1668
- winston.debug("envTemplate: " + envTemplate);
1669
-
1670
- if (envTemplate) {
1671
- html = envTemplate;
1672
- }
1601
+ var html = await this.readTemplateFile('beenInvitedExistingUser.html', undefined, "EMAIL_EXUSER_INVITED_HTML_TEMPLATE");
1673
1602
 
1674
1603
  winston.debug("html: " + html);
1675
1604
 
@@ -1708,14 +1637,7 @@ class EmailService {
1708
1637
 
1709
1638
  var that = this;
1710
1639
 
1711
- var html = await this.readTemplateFile('beenInvitedNewUser.html');
1712
-
1713
- var envTemplate = process.env.EMAIL_NEWUSER_INVITED_HTML_TEMPLATE;
1714
- winston.debug("envTemplate: " + envTemplate);
1715
-
1716
- if (envTemplate) {
1717
- html = envTemplate;
1718
- }
1640
+ var html = await this.readTemplateFile('beenInvitedNewUser.html', undefined, "EMAIL_NEWUSER_INVITED_HTML_TEMPLATE");
1719
1641
 
1720
1642
  winston.debug("html: " + html);
1721
1643
 
@@ -1751,14 +1673,7 @@ class EmailService {
1751
1673
  if (savedUser.toJSON) {
1752
1674
  savedUser = savedUser.toJSON();
1753
1675
  }
1754
- var html = await this.readTemplateFile('verify.html');
1755
-
1756
- var envTemplate = process.env.EMAIL_VERIFY_HTML_TEMPLATE;
1757
- winston.debug("envTemplate: " + envTemplate);
1758
-
1759
- if (envTemplate) {
1760
- html = envTemplate;
1761
- }
1676
+ var html = await this.readTemplateFile('verify.html', undefined, "EMAIL_VERIFY_HTML_TEMPLATE");
1762
1677
 
1763
1678
  winston.debug("html: " + html);
1764
1679
 
@@ -1811,14 +1726,7 @@ class EmailService {
1811
1726
 
1812
1727
  var that = this;
1813
1728
 
1814
- var html = await this.readTemplate('sendTranscript.html', project.settings);
1815
-
1816
- var envTemplate = process.env.EMAIL_SEND_TRANSCRIPT_HTML_TEMPLATE;
1817
- winston.debug("envTemplate: " + envTemplate);
1818
-
1819
- if (envTemplate) {
1820
- html = envTemplate;
1821
- }
1729
+ var html = await this.readTemplate('sendTranscript.html', project.settings, "EMAIL_SEND_TRANSCRIPT_HTML_TEMPLATE");
1822
1730
 
1823
1731
  winston.debug("html: " + html);
1824
1732
 
@@ -1880,14 +1788,8 @@ class EmailService {
1880
1788
 
1881
1789
  var that = this;
1882
1790
 
1883
- let html = await this.readTemplate('redirectToDesktopEmail.html');
1884
-
1885
- let envTemplate = process.env.EMAIL_REDIRECT_TO_DESKTOP_TEMPLATE
1886
- winston.debug("envTemplate: " + envTemplate);
1791
+ let html = await this.readTemplate('redirectToDesktopEmail.html', undefined, "EMAIL_REDIRECT_TO_DESKTOP_TEMPLATE");
1887
1792
 
1888
- if (envTemplate) {
1889
- html = envTemplate;
1890
- }
1891
1793
 
1892
1794
  winston.debug("html: " + html);
1893
1795
 
@@ -16,6 +16,10 @@ var cacheEnabler = require("../services/cacheEnabler");
16
16
  var UIDGenerator = require("../utils/UIDGenerator");
17
17
  const { TdCache } = require('../utils/TdCache');
18
18
  const { QuoteManager } = require('./QuoteManager');
19
+ var configGlobal = require('../config/global');
20
+ const axios = require("axios").default;
21
+
22
+ const apiUrl = process.env.API_URL || configGlobal.apiUrl;
19
23
 
20
24
  let tdCache = new TdCache({
21
25
  host: process.env.CACHE_REDIS_HOST,
@@ -2459,10 +2463,25 @@ class RequestService {
2459
2463
 
2460
2464
 
2461
2465
 
2466
+ async getRequestParametersFromChatbot(request_id) {
2462
2467
 
2468
+ return new Promise( async (resolve, reject) => {
2469
+ await axios({
2470
+ url: apiUrl + '/modules/tilebot/ext/reserved/parameters/requests/' + request_id,
2471
+ headers: {
2472
+ 'Content-Type': 'application/json'
2473
+ },
2474
+ method: 'GET'
2475
+ }).then((response) => {
2476
+ console.log("[RequestService] response: ", response);
2477
+ resolve(response.data);
2478
+ }).catch((err) => {
2479
+ winston.error("get request parameter error: ", err.response.data);
2480
+ reject(err);
2481
+ })
2482
+ })
2463
2483
 
2464
-
2465
-
2484
+ }
2466
2485
 
2467
2486
  }
2468
2487