@tiledesk/tiledesk-server 2.2.39 → 2.3.1-8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. package/CHANGELOG.md +121 -0
  2. package/LICENSE +14 -657
  3. package/README.md +17 -3
  4. package/app.js +21 -60
  5. package/channels/chat21/chat21Handler.js +18 -3
  6. package/channels/chat21/chat21WebHook.js +31 -15
  7. package/channels/chat21/package-lock.json +663 -706
  8. package/channels/chat21/package.json +2 -2
  9. package/deploy.sh +2 -0
  10. package/event/botEvent.js +1 -1
  11. package/event/subscriptionEvent.js +11 -0
  12. package/fonts/Roboto-Italic.ttf +0 -0
  13. package/fonts/Roboto-Medium.ttf +0 -0
  14. package/fonts/Roboto-MediumItalic.ttf +0 -0
  15. package/fonts/Roboto-Regular.ttf +0 -0
  16. package/middleware/ipFilter.js +220 -0
  17. package/middleware/passport.js +11 -2
  18. package/models/lead.js +2 -0
  19. package/models/project.js +10 -0
  20. package/models/project_user.js +4 -0
  21. package/models/request.js +50 -12
  22. package/models/subscriptionLog.js +34 -0
  23. package/models/tagLibrary.js +42 -0
  24. package/package.json +6 -12
  25. package/pubmodules/activities/activityArchiver.js +314 -0
  26. package/pubmodules/activities/index.js +3 -0
  27. package/pubmodules/activities/models/activity.js +88 -0
  28. package/pubmodules/activities/routes/activity.js +710 -0
  29. package/pubmodules/activities/test/activityRoute.js +85 -0
  30. package/pubmodules/analytics/analytics.js +1719 -0
  31. package/pubmodules/analytics/index.js +3 -0
  32. package/pubmodules/canned/cannedResponse.js +55 -0
  33. package/pubmodules/canned/cannedResponseRoute.js +163 -0
  34. package/pubmodules/canned/index.js +3 -0
  35. package/pubmodules/emailNotification/requestNotification.js +215 -28
  36. package/pubmodules/events/eventRoute.js +37 -7
  37. package/pubmodules/messageActions/messageActionsInterceptor.js +4 -2
  38. package/pubmodules/pubModulesManager.js +129 -5
  39. package/pubmodules/rasa/listener.js +5 -5
  40. package/pubmodules/rules/conciergeBot.js +4 -4
  41. package/pubmodules/scheduler/tasks/closeAgentUnresponsiveRequestTask.js +3 -1
  42. package/pubmodules/scheduler/tasks/closeBotUnresponsiveRequestTask.js +3 -1
  43. package/pubmodules/tilebot/index.js +11 -0
  44. package/pubmodules/tilebot/listener.js +69 -0
  45. package/pubmodules/trigger/default.js +271 -0
  46. package/pubmodules/trigger/event/actionEventEmitter.js +10 -0
  47. package/pubmodules/trigger/event/flowEventEmitter.js +10 -0
  48. package/pubmodules/trigger/event/triggerEventEmitter.js +10 -0
  49. package/pubmodules/trigger/index.js +3 -0
  50. package/pubmodules/trigger/models/trigger.js +149 -0
  51. package/pubmodules/trigger/rulesTrigger.js +1181 -0
  52. package/pubmodules/trigger/start.js +118 -0
  53. package/pubmodules/trigger/triggerRoute.js +150 -0
  54. package/routes/auth.js +7 -2
  55. package/routes/department.js +51 -0
  56. package/routes/faq.js +7 -0
  57. package/routes/faq_kb.js +1 -1
  58. package/routes/group.js +140 -0
  59. package/routes/lead.js +24 -1
  60. package/routes/message.js +6 -3
  61. package/routes/project.js +118 -0
  62. package/routes/project_user.js +9 -0
  63. package/routes/public-request.js +280 -2
  64. package/routes/request.js +122 -16
  65. package/routes/subscription.js +140 -0
  66. package/routes/tag.js +138 -0
  67. package/routes/user-request.js +3 -2
  68. package/routes/users.js +1 -1
  69. package/routes/widget.js +80 -3
  70. package/routes/widgetLoader.js +31 -0
  71. package/services/banUserNotifier.js +86 -0
  72. package/services/emailService.js +189 -11
  73. package/services/faqService.js +2 -2
  74. package/services/geoService.js +30 -4
  75. package/services/leadService.js +2 -0
  76. package/services/modulesManager.js +7 -188
  77. package/services/requestService.js +364 -6
  78. package/services/subscriptionNotifier.js +485 -0
  79. package/template/email/assignedEmailMessage.html +1 -1
  80. package/template/email/assignedRequest.html +1 -1
  81. package/template/email/newMessage.html +1 -1
  82. package/template/email/newMessageFollower.html +236 -0
  83. package/template/email/passwordChanged.html +1 -1
  84. package/template/email/pooledEmailMessage.html +1 -1
  85. package/template/email/pooledRequest.html +1 -1
  86. package/template/email/resetPassword.html +2 -2
  87. package/template/email/ticket.html +1 -1
  88. package/test/cannedRoute.js +166 -0
  89. package/test/messageRoute.js +69 -0
  90. package/test/requestService.js +3 -1
  91. package/utils/orgUtil.js +3 -3
  92. package/views/messages.jade +2 -2
  93. package/websocket/webSocketServer.js +23 -5
@@ -0,0 +1,86 @@
1
+ var messageService = require("./messageService");
2
+ var projectEvent = require("../event/projectEvent");
3
+
4
+ var winston = require('../config/winston');
5
+
6
+ var MessageConstants = require("../models/messageConstants");
7
+
8
+ class BanUserNotifier {
9
+
10
+ listen() {
11
+ projectEvent.on("project.update.user.ban", function(data) {
12
+ var project=data.project;
13
+ var banInfo = data.banInfo;
14
+
15
+ winston.debug("User Banned");
16
+
17
+ var message = {
18
+ sender: 'system',
19
+ senderFullname: 'Bot',
20
+ recipient: banInfo.id,
21
+ recipientFullname: banInfo.id,
22
+ text: "User Banned",
23
+ id_project: project._id,
24
+ createdBy: "system",
25
+ attributes: {subtype:"info", messagelabel: {key: "USER_BANNED"} },
26
+ channel_type: MessageConstants.CHANNEL_TYPE.DIRECT,
27
+ status: MessageConstants.CHAT_MESSAGE_STATUS.SENDING,
28
+ // channel: {name: "chat21"}
29
+ };
30
+ messageService.save(message);
31
+ winston.info("User banned", message);
32
+ // messageService.send(
33
+ // 'system',
34
+ // 'Bot',
35
+ // banInfo.id,
36
+ // "User Banned",
37
+ // project._id,
38
+ // 'system',
39
+ // {subtype:"info"},
40
+ // undefined,
41
+ // undefined
42
+ // );
43
+ });
44
+ projectEvent.on("project.update.user.unban", function(data) {
45
+ var project=data.project;
46
+ var banInfo = data.banInfo;
47
+
48
+ winston.debug("User UnBanned: "+banInfo);
49
+
50
+ // var message = {
51
+ // sender: 'system',
52
+ // senderFullname: 'Bot',
53
+ // recipient: banInfo,
54
+ // recipientFullname: banInfo,
55
+ // text: "User Unbanned",
56
+ // id_project: project._id,
57
+ // createdBy: "system",
58
+ // attributes: {subtype:"info", messagelabel: {key: "USER_BANNED"}},
59
+ // channel_type: MessageConstants.CHANNEL_TYPE.DIRECT,
60
+ // status: MessageConstants.CHAT_MESSAGE_STATUS.SENDING,
61
+ // };
62
+ // messageService.save(message);
63
+ // winston.info("User UnBanned", message);
64
+
65
+
66
+
67
+
68
+ // messageService.send(
69
+ // 'system',
70
+ // 'Bot',
71
+ // banInfo.id,
72
+ // "User Unbanned",
73
+ // project._id,
74
+ // 'system',
75
+ // {subtype:"info"},
76
+ // undefined,
77
+ // undefined
78
+ // );
79
+ });
80
+ }
81
+
82
+ }
83
+ var banUserNotifier = new BanUserNotifier();
84
+
85
+
86
+ module.exports = banUserNotifier;
@@ -191,20 +191,24 @@ class EmailService {
191
191
  user: configEmail.user,
192
192
  pass: configEmail.pass
193
193
  },
194
+ // secureConnection: false,
195
+ // tls:{
196
+ // ciphers:'SSLv3'
197
+ // },
194
198
 
195
- // openssl genrsa -out dkim_private.pem 2048
199
+ // openssl genrsa -out dkim_private.pem 2048
196
200
  // openssl rsa -in dkim_private.pem -pubout -outform der 2>/dev/null | openssl base64 -A
197
201
  // ->
198
202
  // v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAunT2EopDAYnHwAOHd33KhlzjUXJfhmA+fK+cG85i9Pm33oyv1NoGrOynsni0PO6j7oRxxHqs6EMDOw4I/Q0C7aWn20oBomJZehTOkCV2xpuPKESiRktCe/MIZqbkRdypis4jSkFfFFkBHwgkAg5tb11E9elJap0ed/lN5/XlpGedqoypKxp+nEabgYO5mBMMNKRvbHx0eQttRYyIaNkTuMbAaqs4y3TkHOpGvZTJsvUonVMGAstSCfUmXnjF38aKpgyTausTSsxHbaxh3ieUB4ex+svnvsJ4Uh5Skklr+bxLVEHeJN55rxmV67ytLg5XCRWqdKIcJHFvSlm2YwJfcwIDAQABMacAL
199
203
  // testdkim._domainkey.tiledesk.com. 86400 IN TXT "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAunT2EopDAYnHwAOHd33KhlzjUXJfhmA+fK+cG85i9Pm33oyv1NoGrOynsni0PO6j7oRxxHqs6EMDOw4I/Q0C7aWn20oBomJZehTOkCV2xpuPKESiRktCe/MIZqbkRdypis4jSkFfFFkBHwgkAg5tb11E9elJap0ed/lN5/XlpGedqoypKxp+nEabgYO5mBMMNKRvbHx0eQttRYyIaNkTuMbAaqs4y3TkHOpGvZTJsvUonVMGAstSCfUmXnjF38aKpgyTausTSsxHbaxh3ieUB4ex+svnvsJ4Uh5Skklr+bxLVEHeJN55rxmV67ytLg5XCRWqdKIcJHFvSlm2YwJfcwIDAQABMacAL"
200
204
 
201
- dkim: {
202
- domainName: "example.com",
203
- keySelector: "2017",
204
- privateKey: "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBg...",
205
- cacheDir: "/tmp",
206
- cacheTreshold: 100 * 1024
207
- }
205
+ // dkim: {
206
+ // domainName: "example.com",
207
+ // keySelector: "2017",
208
+ // privateKey: "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBg...",
209
+ // cacheDir: "/tmp",
210
+ // cacheTreshold: 100 * 1024
211
+ // }
208
212
  };
209
213
 
210
214
  winston.debug("getTransport transport: ",transport);
@@ -406,7 +410,9 @@ class EmailService {
406
410
  }
407
411
  }
408
412
 
409
-
413
+ // troncare nome utnete e nome progetto a max 10 caratteri
414
+ // cambiare in [Nicky:Dashboard Support] Assigned Chat
415
+ // serve per aggiornare native... fai aggiornamento
410
416
 
411
417
  let subject = `[Tiledesk ${project ? project.name : '-'}] New Assigned Chat`;
412
418
 
@@ -958,11 +964,12 @@ class EmailService {
958
964
 
959
965
  let inReplyTo;
960
966
  let references;
967
+ winston.debug("message.request.attributes", message.request.attributes);
961
968
  if (message.request.attributes) {
962
969
  if (message.request.attributes.email_messageId) {
963
970
  inReplyTo = message.request.attributes.email_messageId;
964
971
  }
965
- if (message.attributes.email_references) {
972
+ if (message.request.attributes.email_references) {
966
973
  references = message.request.attributes.email_references;
967
974
  }
968
975
  }
@@ -1176,6 +1183,177 @@ class EmailService {
1176
1183
  }
1177
1184
 
1178
1185
 
1186
+
1187
+
1188
+
1189
+
1190
+
1191
+
1192
+
1193
+
1194
+
1195
+ async sendFollowerNotification(to, message, project) {
1196
+
1197
+ var that = this;
1198
+
1199
+
1200
+ if (project.toJSON) {
1201
+ project = project.toJSON();
1202
+ }
1203
+
1204
+ var html = await this.readTemplate('newMessageFollower.html', project.settings);
1205
+
1206
+
1207
+ var envTemplate = process.env.EMAIL_FOLLOWER_HTML_TEMPLATE;
1208
+ winston.debug("envTemplate: " + envTemplate);
1209
+
1210
+ if (envTemplate) {
1211
+ html = envTemplate;
1212
+ }
1213
+
1214
+ winston.debug("html: " + html);
1215
+
1216
+ var template = handlebars.compile(html);
1217
+
1218
+ var baseScope = JSON.parse(JSON.stringify(that));
1219
+ delete baseScope.pass;
1220
+
1221
+
1222
+ let msgText = message.text;//.replace(/[\n\r]/g, '<br>');
1223
+ msgText = encode(msgText);
1224
+ if (this.markdown) {
1225
+ msgText = marked(msgText);
1226
+ }
1227
+
1228
+ winston.debug("msgText: " + msgText);
1229
+ winston.debug("baseScope: " + JSON.stringify(baseScope));
1230
+
1231
+
1232
+ var replacements = {
1233
+ message: message,
1234
+ project: project,
1235
+ msgText: msgText,
1236
+ baseScope: baseScope
1237
+ };
1238
+
1239
+ var html = template(replacements);
1240
+ winston.debug("html: " + html);
1241
+
1242
+ const fs = require('fs');
1243
+ fs.writeFileSync('tem1111.html', html);
1244
+
1245
+
1246
+
1247
+ let messageId = message._id + "@" + MESSAGE_ID_DOMAIN;
1248
+
1249
+ let replyTo;
1250
+ if (this.replyEnabled) {
1251
+ replyTo = message.request.request_id + this.inboundDomainDomainWithAt;
1252
+ }
1253
+
1254
+ let headers;
1255
+ if (message.request) {
1256
+
1257
+ messageId = message.request.request_id + "+" + messageId;
1258
+
1259
+ if (message.request.attributes && message.request.attributes.email_replyTo) {
1260
+ replyTo = message.request.attributes.email_replyTo;
1261
+ }
1262
+
1263
+ headers = {"X-TILEDESK-PROJECT-ID": project._id, "X-TILEDESK-REQUEST-ID": message.request.request_id, "X-TILEDESK-TICKET-ID":message.request.ticket_id };
1264
+
1265
+ winston.verbose("messageId: " + messageId);
1266
+ winston.verbose("replyTo: " + replyTo);
1267
+ winston.verbose("email headers", headers);
1268
+ }
1269
+
1270
+
1271
+ let inReplyTo;
1272
+ let references;
1273
+ let cc;
1274
+ let ccString;
1275
+
1276
+ if (message.request && message.request.attributes) {
1277
+ winston.debug("email message.request.attributes: ", message.request.attributes);
1278
+
1279
+ if (message.request.attributes.email_messageId) {
1280
+ inReplyTo = message.request.attributes.email_messageId;
1281
+ }
1282
+ if (message.request.attributes.email_references) {
1283
+ references = message.request.attributes.email_references;
1284
+ }
1285
+
1286
+ if (message.request.attributes.email_cc) {
1287
+ cc = message.request.attributes.email_cc;
1288
+ }
1289
+ winston.debug("email message.request.attributes.email_ccStr: "+ message.request.attributes.email_ccStr);
1290
+ if (message.request.attributes.email_ccStr!=undefined) {
1291
+ ccString = message.request.attributes.email_ccStr;
1292
+ winston.debug("email set ccString");
1293
+ }
1294
+ }
1295
+ winston.verbose("email inReplyTo: "+ inReplyTo);
1296
+ winston.verbose("email references: "+ references);
1297
+ winston.verbose("email cc: ", cc);
1298
+ winston.verbose("email ccString: "+ ccString);
1299
+
1300
+ let from;
1301
+ let configEmail;
1302
+ if (project && project.settings && project.settings.email) {
1303
+ if (project.settings.email.config) {
1304
+ configEmail = project.settings.email.config;
1305
+ winston.verbose("custom email configEmail setting found: ", configEmail);
1306
+ }
1307
+ if (project.settings.email.from) {
1308
+ from = project.settings.email.from;
1309
+ winston.verbose("custom from email setting found: "+ from);
1310
+ }
1311
+ }
1312
+
1313
+
1314
+
1315
+
1316
+ that.send({
1317
+ messageId: messageId,
1318
+ // sender: message.senderFullname, //must be an email
1319
+ from:from,
1320
+ to:to,
1321
+ cc: ccString,
1322
+ replyTo: replyTo,
1323
+ inReplyTo: inReplyTo,
1324
+ references: references,
1325
+ // subject:`${message.request ? message.request.subject : '-'}`,
1326
+ subject:`${message.request ? message.request.ticket_id : '-'}`, //gmail uses subject
1327
+ text:html,
1328
+ html:html,
1329
+ config:configEmail,
1330
+ headers:headers
1331
+ });
1332
+
1333
+ // // messageId = "notification" + messageId;
1334
+
1335
+ // // that.send({
1336
+ // // messageId: messageId,
1337
+ // // // sender: message.senderFullname, //must be an email
1338
+ // // to: that.bcc,
1339
+ // // replyTo: replyTo,
1340
+ // // inReplyTo: inReplyTo,
1341
+ // // references: references,
1342
+ // // // subject: `${message.request ? message.request.subject : '-'} - notification`,
1343
+ // // subject: `${message.request ? message.request.subject : '-'} - notification`,
1344
+ // // text:html,
1345
+ // // html:html,
1346
+ // // headers:headers
1347
+ // // });
1348
+
1349
+
1350
+ }
1351
+
1352
+
1353
+
1354
+
1355
+
1356
+
1179
1357
  /*
1180
1358
  sendEmailChannelTakingNotification(to, request, project, tokenQueryString) {
1181
1359
 
@@ -1505,6 +1683,6 @@ async sendRequestTranscript(to, messages, request, project) {
1505
1683
 
1506
1684
  var emailService = new EmailService();
1507
1685
 
1508
- // emailService.sendTest("al@f21.it");
1686
+ // emailService.sendTest("asd.");
1509
1687
 
1510
1688
  module.exports = emailService;
@@ -39,7 +39,7 @@ class FaqService {
39
39
 
40
40
  winston.debug('type '+ type)
41
41
 
42
- if (type==="internal") {
42
+ if (type==="internal" || type==="tilebot") {
43
43
 
44
44
  if (!template) {
45
45
  template = "example";
@@ -78,7 +78,7 @@ class FaqService {
78
78
  { 'question': '\\start', 'answer': 'Hello 👋. I\'m a bot 🤖.\n\nChoose one of the options below or write a message to reach our staff.\n* Who are you?\n* Where are you?\n* What can you do?\n* 👨🏻‍🦰 I want an agent', 'intent_display_name': 'start', 'topic': 'internal' },
79
79
  { 'question': 'defaultFallback', 'answer': 'I can not provide an adequate answer. Write a new question or talk to a human agent.\n* Back to start tdAction:start\n* See the docs https://docs.tiledesk.com/\n* 👨🏻‍🦰 I want an agent', 'intent_display_name': 'defaultFallback', 'topic': 'internal' }, //TODO se metto spazio n * nn va
80
80
  { 'question': 'What can you do?', 'answer': 'Using natural language processing, I\'m able to find the best answer for your users. I also support images, videos etc.. Let\'s try:\n* Sample Image\n* Sample Video\n* Sample Action tdAction:action1\n* Sample Frame\n* Back to start tdAction:start', 'topic': 'sample' },
81
- { 'question': 'Sample Image', 'answer': 'tdImage:https://tiledesk.com/tiledesk-logo-x1.png\n* What can you do?\n* Back to start tdAction:start', 'topic': 'sample' },
81
+ { 'question': 'Sample Image', 'answer': 'tdImage:https://tiledesk.com/wp-content/uploads/2022/07/tiledesk_v2.png\n* What can you do?\n* Back to start tdAction:start', 'topic': 'sample' },
82
82
  { 'question': 'Sample Frame', 'answer': 'tdFrame:https://www.emanueleferonato.com/wp-content/uploads/2019/02/runner/\n* What can you do?\n* Back to start tdAction:start', 'topic': 'sample' },
83
83
  { 'question': 'Sample Video', 'answer': 'tdVideo:https://www.youtube.com/embed/EngW7tLk6R8\n* What can you do?\n* Back to start tdAction:start', 'topic': 'sample' },
84
84
  { 'question': 'Where are you?', 'answer': 'We are here ❤️\ntdFrame:https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d6087916.923447935!2d8.234804542117423!3d41.836572992140624!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x12d4fe82448dd203%3A0xe22cf55c24635e6f!2sItaly!5e0!3m2!1sen!2sit!4v1613657475377!5m2!1sen!2sit\n* Back to start tdAction:start', 'topic': 'sample' },
@@ -8,6 +8,13 @@ var geoip = require('geoip-lite');
8
8
 
9
9
  class GeoService {
10
10
 
11
+ constructor() {
12
+ this.enabled = true;
13
+ if (process.env.GEO_SERVICE_ENABLED=="false" || process.env.GEO_SERVICE_ENABLED==false) {
14
+ this.enabled = false;
15
+ }
16
+ winston.debug("GeoService this.enabled: "+ this.enabled);
17
+ }
11
18
 
12
19
 
13
20
  // https://medium.com/@rossbulat/node-js-client-ip-location-with-geoip-lite-fallback-c25833c94a76
@@ -16,7 +23,12 @@ class GeoService {
16
23
 
17
24
  listen() {
18
25
 
19
- winston.info("GeoService listener started");
26
+ if (this.enabled==true) {
27
+ winston.info("GeoService listener started");
28
+ } else {
29
+ return winston.info("GeoService listener disabled");
30
+ }
31
+
20
32
 
21
33
 
22
34
 
@@ -36,9 +48,19 @@ class GeoService {
36
48
  // area: 200 }
37
49
 
38
50
 
39
- requestEvent.on('request.create', function(request) {
40
51
 
41
- winston.debug("request", request.toObject());
52
+ var requestCreateKey = 'request.create';
53
+ // if (requestEvent.queueEnabled) {
54
+ // requestCreateKey = 'request.create.queue';
55
+ // }
56
+ // winston.debug('GeoService requestCreateKey: ' + requestCreateKey);
57
+
58
+
59
+ requestEvent.on(requestCreateKey, function(request) {
60
+
61
+ setImmediate(() => {
62
+
63
+ winston.debug("request", request);
42
64
 
43
65
  var ip = (request.location && request.location.ipAddress) || (request.attributes && request.attributes.ipAddress);
44
66
  winston.debug("ip" + ip);
@@ -114,11 +136,15 @@ class GeoService {
114
136
  }
115
137
  return winston.verbose("Saved location metadata for request with id " + request._id);
116
138
  });
139
+
140
+ //TODO AGGIORNA ANCHE LEAD e req.snapshot.lead?
141
+ // leggi ip da request e nn da attributes
117
142
 
118
143
  }
119
144
  }
120
145
  });
121
- }
146
+ });
147
+ }
122
148
 
123
149
 
124
150
  }
@@ -128,6 +128,8 @@ class LeadService {
128
128
 
129
129
 
130
130
  leadEvent.emit('lead.update', updatedLead);
131
+ leadEvent.emit('lead.email.update', updatedLead);
132
+ leadEvent.emit('lead.fullname.update', updatedLead);
131
133
  return resolve(updatedLead);
132
134
  });
133
135
  });
@@ -28,16 +28,10 @@ if (licenseKey) {
28
28
 
29
29
  class ModulesManager {
30
30
 
31
- constructor() {
32
- this.trigger = undefined;
33
- this.triggerRoute = undefined;
31
+ constructor() {
34
32
  this.stripe = undefined;
35
33
  this.graphql = undefined;
36
- this.analyticsRoute = undefined;
37
- this.resthookRoute = undefined;
38
- this.elasticIndexer = undefined;
39
- this.activityArchiver = undefined;
40
- this.activityRoute = undefined;
34
+ this.elasticIndexer = undefined;
41
35
  this.facebookRoute = undefined;
42
36
  this.jwthistoryArchiver = undefined;
43
37
  this.jwthistoryRoute = undefined;
@@ -47,9 +41,6 @@ class ModulesManager {
47
41
  this.routingQueue = undefined;
48
42
  this.queue = undefined;
49
43
  this.cache = undefined;
50
- this.cannedResponseRoute = undefined;
51
- this.tagRoute = undefined;
52
- this.groupsRoute = undefined;
53
44
  this.visitorCounterRoute = undefined;
54
45
  this.visitorCounterMiddleware = undefined;
55
46
  this.widgetsRoute = undefined;
@@ -107,50 +98,16 @@ class ModulesManager {
107
98
  useUnderProjects(app) {
108
99
  var that = this;
109
100
  winston.debug("ModulesManager using controllers");
110
-
111
-
112
- if (this.triggerRoute) {
113
- app.use('/:projectid/modules/triggers', [passport.authenticate(['basic', 'jwt'], { session: false }), validtoken, roleChecker.hasRole('admin')], this.triggerRoute);
114
- winston.info("ModulesManager trigger controller loaded");
115
- }
116
-
117
- if (this.analyticsRoute) {
118
- app.use('/:projectid/analytics', [passport.authenticate(['basic', 'jwt'], { session: false }), validtoken, roleChecker.hasRole('agent')], this.analyticsRoute);
119
- winston.info("ModulesManager analytics controller loaded");
120
- }
121
-
122
- if (this.resthookRoute) {
123
- app.use('/:projectid/subscriptions', [passport.authenticate(['basic', 'jwt'], { session: false }), validtoken, roleChecker.hasRole('admin')], this.resthookRoute);
124
- winston.info("ModulesManager subscriptions controller loaded");
125
- }
126
-
127
- if (this.activityRoute) {
128
- app.use('/:projectid/activities', [passport.authenticate(['basic', 'jwt'], { session: false }), validtoken, roleChecker.hasRole('admin')], this.activityRoute);
129
- winston.info("ModulesManager activities controller loaded");
130
- }
131
-
101
+
102
+
103
+
132
104
 
133
105
  if (this.requestHistoryRoute) {
134
106
  app.use('/:projectid/requests/:request_id/history', [passport.authenticate(['basic', 'jwt'], { session: false }), validtoken, roleChecker.hasRoleOrTypes(null, ['subscription'])] , this.requestHistoryRoute);
135
107
  winston.info("ModulesManager requestHistory controller loaded");
136
108
  }
137
109
 
138
-
139
- if (this.cannedResponseRoute) {
140
- app.use('/:projectid/canned', [passport.authenticate(['basic', 'jwt'], { session: false }), validtoken, roleChecker.hasRole('agent')], this.cannedResponseRoute);
141
- winston.info("ModulesManager canned controller loaded");
142
- }
143
-
144
- if (this.tagRoute) {
145
- app.use('/:projectid/tags', [passport.authenticate(['basic', 'jwt'], { session: false }), validtoken, roleChecker.hasRole('agent')], this.tagRoute);
146
- winston.info("ModulesManager tag controller loaded");
147
- }
148
-
149
- if (this.groupsRoute) {
150
- app.use('/:projectid/groups', [passport.authenticate(['basic', 'jwt'], { session: false }), validtoken, roleChecker.hasRole('admin')], this.groupsRoute);
151
- winston.info("ModulesManager group controller loaded");
152
- }
153
-
110
+
154
111
 
155
112
 
156
113
  if (this.visitorCounterRoute) {
@@ -188,19 +145,6 @@ class ModulesManager {
188
145
 
189
146
 
190
147
 
191
- try {
192
- this.trigger = require('@tiledesk-ent/tiledesk-server-triggers').start;
193
- winston.debug("this.trigger:"+ this.trigger);
194
- this.triggerRoute = require('@tiledesk-ent/tiledesk-server-triggers').triggerRoute;
195
- winston.debug("this.triggerRoute:"+ this.triggerRoute);
196
- winston.info("ModulesManager trigger initialized");
197
- } catch(err) {
198
- if (err.code == 'MODULE_NOT_FOUND') {
199
- winston.info("ModulesManager init trigger module not found");
200
- }else {
201
- winston.error("ModulesManager error initializing init trigger module", err);
202
- }
203
- }
204
148
 
205
149
 
206
150
  try {
@@ -213,51 +157,6 @@ class ModulesManager {
213
157
  winston.error("ModulesManager error initializing init stripe module", err);
214
158
  }
215
159
  }
216
-
217
- try {
218
- this.resthookRoute = require('@tiledesk-ent/tiledesk-server-resthook').resthookRoute;
219
- winston.debug("this.resthookRoute:"+ this.resthookRoute);
220
- this.subscriptionNotifier = require('@tiledesk-ent/tiledesk-server-resthook').subscriptionNotifier;
221
- // this.subscriptionNotifier.start();
222
- winston.info("ModulesManager resthook initialized");
223
- } catch(err) {
224
- if (err.code == 'MODULE_NOT_FOUND') {
225
- winston.info("ModulesManager init resthookRoute module not found");
226
- }else {
227
- winston.error("ModulesManager error initializing init resthook module", err);
228
- }
229
- }
230
-
231
-
232
- try {
233
- this.analyticsRoute = require('@tiledesk-ent/tiledesk-server-analytics').analyticsRoute;
234
- winston.debug("this.analyticsRoute:"+ this.analyticsRoute);
235
- winston.info("ModulesManager analyticsRoute initialized");
236
- } catch(err) {
237
- if (err.code == 'MODULE_NOT_FOUND') {
238
- winston.info("ModulesManager init analytics module not found");
239
- }else {
240
- winston.error("ModulesManager error initializing init analytics module", err);
241
- }
242
- }
243
-
244
-
245
- try {
246
- this.activityArchiver = require('@tiledesk-ent/tiledesk-server-activities').activityArchiver;
247
- // this.activityArchiver.listen();
248
- winston.debug("this.activityArchiver:"+ this.activityArchiver);
249
-
250
- this.activityRoute = require('@tiledesk-ent/tiledesk-server-activities').activityRoute;
251
- winston.debug("this.activityRoute:"+ this.activityRoute);
252
-
253
- winston.info("ModulesManager activities initialized");
254
- } catch(err) {
255
- if (err.code == 'MODULE_NOT_FOUND') {
256
- winston.info("ModulesManager init activities module not found");
257
- }else {
258
- winston.error("ModulesManager error initializing init activities module", err);
259
- }
260
- }
261
160
 
262
161
 
263
162
 
@@ -359,70 +258,8 @@ class ModulesManager {
359
258
  }
360
259
  }
361
260
 
362
- try {
363
- this.cannedResponseRoute = require('@tiledesk-ent/tiledesk-server-canned').cannedResponseRoute;
364
- winston.debug("this.cannedResponseRoute:"+ this.cannedResponseRoute);
365
- winston.info("ModulesManager cannedResponseRoute initialized");
366
- } catch(err) {
367
- if (err.code == 'MODULE_NOT_FOUND') {
368
- winston.info("ModulesManager init canned module not found");
369
- }else {
370
- winston.error("ModulesManager error initializing init canned module", err);
371
- }
372
- }
373
-
374
- try {
375
- this.tagRoute = require('@tiledesk-ent/tiledesk-server-tags').tagRoute;
376
- winston.debug("this.tagRoute:"+ this.tagRoute);
377
- winston.info("ModulesManager tagRoute initialized");
378
- } catch(err) {
379
- if (err.code == 'MODULE_NOT_FOUND') {
380
- winston.info("ModulesManager init tag module not found");
381
- }else {
382
- winston.error("ModulesManager error initializing init tag module", err);
383
- }
384
- }
385
-
386
- try {
387
- this.groupsRoute = require('@tiledesk-ent/tiledesk-server-groups').groupsRoute;
388
- winston.debug("this.groupsRoute:"+ this.groupsRoute);
389
- winston.info("ModulesManager groupsRoute initialized");
390
- } catch(err) {
391
- if (err.code == 'MODULE_NOT_FOUND') {
392
- winston.info("ModulesManager init group module not found");
393
- }else {
394
- winston.error("ModulesManager error initializing init group module", err);
395
- }
396
- }
397
-
398
261
 
399
-
400
- if (config && config.routes && config.routes.departmentsRoute) {
401
- try {
402
- require('@tiledesk-ent/tiledesk-server-departments').ext(config.routes.departmentsRoute, config.passport);
403
- winston.info("ModulesManager departmentsRoute initialized");
404
- } catch(err) {
405
- if (err.code == 'MODULE_NOT_FOUND') {
406
- winston.info("ModulesManager init departments module not found");
407
- }else {
408
- winston.error("ModulesManager error initializing init departments module", err);
409
- }
410
- }
411
- }
412
-
413
- if (config && config.routes && config.routes.projectsRoute) {
414
- try {
415
- require('@tiledesk-ent/tiledesk-server-mt').ext(config.routes.projectsRoute, config.passport);
416
- winston.info("ModulesManager mt initialized");
417
- } catch(err) {
418
- if (err.code == 'MODULE_NOT_FOUND') {
419
- winston.info("ModulesManager init mt module not found");
420
- }else {
421
- winston.error("ModulesManager error initializing init mt module", err);
422
- }
423
- }
424
- }
425
-
262
+
426
263
  try {
427
264
  this.visitorCounterRoute = require('@tiledesk-ent/tiledesk-server-visitorcounter').add(config.express);
428
265
  winston.debug("this.visitorCounterRoute:"+ this.visitorCounterRoute);
@@ -474,24 +311,6 @@ class ModulesManager {
474
311
 
475
312
  start() {
476
313
 
477
- // stampa log
478
- if (this.subscriptionNotifier) {
479
- try {
480
- this.subscriptionNotifier.start();
481
- winston.info("ModulesManager subscriptionNotifier started");
482
- } catch(err) {
483
- winston.info("ModulesManager error starting subscriptionNotifier module", err);
484
- }
485
- }
486
-
487
- if (this.activityArchiver) {
488
- try {
489
- this.activityArchiver.listen();
490
- winston.info("ModulesManager activityArchiver started");
491
- } catch(err) {
492
- winston.info("ModulesManager error starting activityArchiver module", err);
493
- }
494
- }
495
314
 
496
315
  if (this.jwthistoryArchiver) {
497
316
  try {