@tiledesk/tiledesk-server 2.2.23 → 2.2.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/CHANGELOG.md +22 -1
  2. package/README.md +6 -0
  3. package/app.js +73 -3
  4. package/bin/www +4 -1
  5. package/channels/chat21/chat21WebHook.js +1 -1
  6. package/config/email.js +1 -1
  7. package/config/global.js +2 -0
  8. package/config/labels/widget.json +781 -611
  9. package/event/messageEvent.js +4 -4
  10. package/middleware/has-role.js +1 -1
  11. package/middleware/passport.js +3 -3
  12. package/models/project.js +10 -0
  13. package/models/project_user.js +2 -0
  14. package/models/request.js +1 -1
  15. package/package.json +4 -3
  16. package/pubmodules/emailNotification/requestNotification.js +4 -4
  17. package/pubmodules/messageTransformer/messageHandlebarsTransformerInterceptor.js +3 -3
  18. package/pubmodules/messageTransformer/messageTransformerInterceptor.js +3 -3
  19. package/pubmodules/rules/conciergeBot.js +5 -2
  20. package/pubmodules/scheduler/tasks/closeBotUnresponsiveRequestTask.js +12 -3
  21. package/routes/department.js +1 -1
  22. package/routes/faq_kb.js +2 -3
  23. package/routes/labels.js +2 -0
  24. package/routes/message.js +1 -1
  25. package/routes/project.js +73 -1
  26. package/routes/project_user.js +11 -4
  27. package/routes/request.js +15 -0
  28. package/routes/user-request.js +15 -0
  29. package/routes/widget.js +1 -1
  30. package/services/departmentService.js +5 -4
  31. package/services/faqBotHandler.js +1 -1
  32. package/services/faqService.js +62 -29
  33. package/services/labelService-no-default.js +2 -2
  34. package/services/labelService.js +1 -1
  35. package/services/leadService.js +2 -2
  36. package/services/operatingHoursService.js +1 -1
  37. package/services/requestService.js +3 -3
  38. package/utils/orgUtil.js +74 -0
  39. package/utils/sendMessageUtil.js +2 -2
  40. package/websocket/webSocketServer.js +10 -10
  41. package/services/faqBotSupport copy.js_consplit +0 -453
@@ -8,7 +8,7 @@ const ActionsConstants = require('../models/actionsConstants');
8
8
  class FaqService {
9
9
 
10
10
 
11
- create(name, url, projectid, user_id, type, description, webhook_url, webhook_enabled, language) {
11
+ create(name, url, projectid, user_id, type, description, webhook_url, webhook_enabled, language, template) {
12
12
  var that = this;
13
13
  return new Promise(function (resolve, reject) {
14
14
 
@@ -37,8 +37,15 @@ class FaqService {
37
37
 
38
38
  botEvent.emit('faqbot.create', savedFaq_kb);
39
39
 
40
+ winston.debug('type '+ type)
41
+
40
42
  if (type==="internal") {
41
- that.createGreetingsAndOperationalsFaqs(savedFaq_kb._id, savedFaq_kb.createdBy, savedFaq_kb.id_project);
43
+
44
+ if (!template) {
45
+ template = "example";
46
+ }
47
+ winston.debug('template '+ template);
48
+ that.createGreetingsAndOperationalsFaqs(savedFaq_kb._id, savedFaq_kb.createdBy, savedFaq_kb.id_project, template);
42
49
  } else {
43
50
  winston.debug('external bot: ', savedFaq_kb);
44
51
  }
@@ -50,33 +57,63 @@ class FaqService {
50
57
  });
51
58
  }
52
59
 
53
- createGreetingsAndOperationalsFaqs(faq_kb_id, created_by, projectid, remote_faqkb_key) {
60
+ createGreetingsAndOperationalsFaqs(faq_kb_id, created_by, projectid, template) {
54
61
  var that = this;
55
62
  return new Promise(function (resolve, reject) {
56
63
 
57
64
  // aggiungi esempio tdAction con intent_id
58
- var faqsArray = [
59
- { 'question': 'Hi', 'answer': 'Hi', 'topic': 'greetings' },
60
- { 'question': 'Hello', 'answer': 'Hello', 'topic': 'greetings' },
61
- { 'question': 'Who are you?', 'answer': 'Hi, I\'m a bot 🤖. You can find more about me [here](https://tiledesk.com/chatbot-for-customer-service).\ntdImage:https://console.tiledesk.com/assets/images/tily-welcomebot.gif\n* See the website https://tiledesk.com/\n* Back to start tdAction:start', 'topic': 'greetings' },
62
- { 'question': '👨🏻‍🦰 I want an agent', 'answer': 'We are looking for an operator.. '+ActionsConstants.CHAT_ACTION_MESSAGE.AGENT, 'intent_display_name': 'agent_handoff', 'topic': 'internal' },
63
- { 'question': 'Close\nResolved', 'answer': ActionsConstants.CHAT_ACTION_MESSAGE.CLOSE, 'topic': 'internal' },
64
- { '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' },
65
- { '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', 'topic': 'internal' }, //TODO se metto spazio n * nn va
66
- { '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' },
67
- { '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' },
68
- { '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' },
69
- { 'question': 'Sample Video', 'answer': 'tdVideo:https://www.youtube.com/embed/EngW7tLk6R8\n* What can you do?\n* Back to start tdAction:start', 'topic': 'sample' },
70
- { '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' },
71
-
72
- // { 'question': 'Sample Webhook', 'answer': 'tdWebhook:https://tiledesk-bot-webhook.tiledesk.repl.co', 'topic': 'sample' },
73
- { 'question': 'Sample Action', 'answer': 'Hello 👋 Would you like to take a closer look at our offer?\n* Yes, please tdAction:yes_action\n* No tdAction:no_action','intent_display_name': 'action1', 'topic': 'sample' },
74
- { 'question': 'Yes Action', 'answer': 'Great! Take a look here:\n* Tiledesk Pricing https://tiledesk.com/pricing-cloud/', 'intent_display_name': 'yes_action','topic': 'sample' },
75
- { 'question': 'No Action', 'answer': 'All right! If you need anything, let us know.', 'intent_display_name': 'no_action','topic': 'sample' },
76
-
77
-
78
- // action button nn si può fare perche gli id cambiano
79
- ]
65
+
66
+ winston.debug('template: '+ template);
67
+
68
+ var faqsArray;
69
+
70
+ if (template==="example") {
71
+
72
+ faqsArray = [
73
+ { 'question': 'Hi', 'answer': 'Hi', 'topic': 'greetings' },
74
+ { 'question': 'Hello', 'answer': 'Hello', 'topic': 'greetings' },
75
+ { 'question': 'Who are you?', 'answer': 'Hi, I\'m a bot 🤖. You can find more about me [here](https://tiledesk.com/chatbot-for-customer-service).\ntdImage:https://console.tiledesk.com/assets/images/tily-welcomebot.gif\n* See the website https://tiledesk.com/\n* Back to start tdAction:start', 'topic': 'greetings' },
76
+ { 'question': '👨🏻‍🦰 I want an agent', 'answer': 'We are looking for an operator.. '+ActionsConstants.CHAT_ACTION_MESSAGE.AGENT, 'intent_display_name': 'agent_handoff', 'topic': 'internal' },
77
+ { 'question': 'Close\nResolved', 'answer': ActionsConstants.CHAT_ACTION_MESSAGE.CLOSE, 'topic': 'internal' },
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
+ { '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
+ { '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' },
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
+ { '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
+ { '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' },
85
+
86
+ // { 'question': 'Sample Webhook', 'answer': 'tdWebhook:https://tiledesk-bot-webhook.tiledesk.repl.co', 'topic': 'sample' },
87
+ { 'question': 'Sample Action', 'answer': 'Hello 👋 Would you like to take a closer look at our offer?\n* Yes, please tdAction:yes_action\n* No tdAction:no_action','intent_display_name': 'action1', 'topic': 'sample' },
88
+ { 'question': 'Yes Action', 'answer': 'Great! Take a look here:\n* Tiledesk Pricing https://tiledesk.com/pricing-cloud/', 'intent_display_name': 'yes_action','topic': 'sample' },
89
+ { 'question': 'No Action', 'answer': 'All right! If you need anything, let us know.', 'intent_display_name': 'no_action','topic': 'sample' },
90
+
91
+
92
+ // action button nn si può fare perche gli id cambiano
93
+ ]
94
+
95
+ }
96
+
97
+ if (template==="blank") {
98
+
99
+ faqsArray = [
100
+ { 'question': '\\start', 'answer': 'Hello', 'intent_display_name': 'start', 'topic': 'internal' },
101
+ { '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
102
+ ]
103
+
104
+ }
105
+
106
+
107
+ if (template==="handoff") {
108
+
109
+ faqsArray = [
110
+ { 'question': '\\start', 'answer': 'Hello', 'intent_display_name': 'start', 'topic': 'internal' },
111
+ { 'question': '👨🏻‍🦰 I want an agent', 'answer': 'We are looking for an operator.. '+ActionsConstants.CHAT_ACTION_MESSAGE.AGENT, 'intent_display_name': 'agent_handoff', 'topic': 'internal' },
112
+ { '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
113
+ ]
114
+
115
+ }
116
+
80
117
 
81
118
  faqsArray.forEach(faq => {
82
119
 
@@ -101,10 +138,6 @@ class FaqService {
101
138
  winston.debug('FAQ SERVICE (save new faq) - QUESTION OF THE NEW GREETINGS FAQ CREATED ', savedFaq.question)
102
139
  winston.debug('FAQ SERVICE (save new faq) - ANSWER OF THE NEW GREETINGS FAQ CREATED ', savedFaq.answer)
103
140
  winston.debug('FAQ SERVICE (save new faq) - ID FAQKB GET IN THE OBJECT OF NEW FAQ CREATED ', savedFaq.id_faq_kb)
104
- // res.json({ 'Greetings Faqs': savedFaq });
105
- // return resolve(savedFaq);
106
-
107
- // that.createRemoteFaq(remote_faqkb_key, savedFaq);
108
141
 
109
142
  })
110
143
  });
@@ -122,7 +122,7 @@ getAllMerged(id_project) {
122
122
 
123
123
 
124
124
  return Label.findOne(query).lean()
125
- .cache(cacheUtil.longTTL, id_project+":labels:query:all")
125
+ //@DISABLED_CACHE .cache(cacheUtil.longTTL, id_project+":labels:query:all")
126
126
  .exec(function (err, labels) {
127
127
  if (err) {
128
128
  winston.error('Label ROUTE - REQUEST FIND ERR ', err)
@@ -167,7 +167,7 @@ getAll(id_project) {
167
167
 
168
168
 
169
169
  return Label.findOne(query).lean()
170
- .cache(cacheUtil.longTTL, id_project+":labels:query:all")
170
+ //@DISABLED_CACHE .cache(cacheUtil.longTTL, id_project+":labels:query:all")
171
171
  .exec(function (err, labels) {
172
172
  if (err) {
173
173
  winston.error('Label ROUTE - REQUEST FIND ERR ', err)
@@ -74,7 +74,7 @@ getAll(id_project) {
74
74
 
75
75
 
76
76
  return Label.findOne(query).lean()
77
- .cache(cacheUtil.longTTL, id_project+":labels:query:all")
77
+ //@DISABLED_CACHE .cache(cacheUtil.longTTL, id_project+":labels:query:all")
78
78
  .exec(function (err, labels) {
79
79
  if (err) {
80
80
  winston.error('Label ROUTE - REQUEST FIND ERR ', err)
@@ -14,7 +14,7 @@ class LeadService {
14
14
  var that = this;
15
15
  return new Promise(function (resolve, reject) {
16
16
  return Lead.findOne({email: email, id_project: id_project})
17
- .cache(cacheUtil.defaultTTL, id_project+":leads:email:"+email)
17
+ //@DISABLED_CACHE .cache(cacheUtil.defaultTTL, id_project+":leads:email:"+email)
18
18
  .exec(function(err, lead) {
19
19
  if (err) {
20
20
  return reject(err);
@@ -58,7 +58,7 @@ class LeadService {
58
58
  var that = this;
59
59
  return new Promise(function (resolve, reject) {
60
60
  return Lead.findOne({lead_id: lead_id, id_project: id_project})
61
- .cache(cacheUtil.defaultTTL, id_project+":leads:lead_id:"+lead_id)
61
+ //@DISABLED_CACHE .cache(cacheUtil.defaultTTL, id_project+":leads:lead_id:"+lead_id)
62
62
  .exec(function(err, lead) {
63
63
  if (err) {
64
64
  winston.error("Error createIfNotExistsWithLeadId", err);
@@ -12,7 +12,7 @@ class OperatingHoursService {
12
12
 
13
13
  // winston.debug('O ---> [ OHS ] -> PROJECT ID ', projectId)
14
14
  Project.findOne({_id: projectId, status: 100})
15
- .cache(cacheUtil.defaultTTL, "projects:id:"+projectId)
15
+ //@DISABLED_CACHE .cache(cacheUtil.defaultTTL, "projects:id:"+projectId)
16
16
  .exec(function (err, project) {
17
17
  // winston.debug("XXXXXXXX project", project);
18
18
  if (err) {
@@ -170,7 +170,7 @@ class RequestService {
170
170
 
171
171
  return Request
172
172
  .findOne({request_id: request_id, id_project: id_project})
173
- .cache(cacheUtil.defaultTTL, id_project+":requests:request_id:"+request_id)
173
+ //@DISABLED_CACHE .cache(cacheUtil.defaultTTL, id_project+":requests:request_id:"+request_id)
174
174
  .exec( function(err, request) {
175
175
 
176
176
  if (err) {
@@ -322,7 +322,7 @@ class RequestService {
322
322
 
323
323
  return Request
324
324
  .findOne({request_id: request_id, id_project: id_project})
325
- .cache(cacheUtil.defaultTTL, id_project+":requests:request_id:"+request_id)
325
+ //@DISABLED_CACHE .cache(cacheUtil.defaultTTL, id_project+":requests:request_id:"+request_id)
326
326
  .exec( function(err, request) {
327
327
 
328
328
  if (err) {
@@ -901,7 +901,7 @@ class RequestService {
901
901
  .populate('participatingBots')
902
902
  .populate('participatingAgents')
903
903
  .populate({path:'requester',populate:{path:'id_user'}})
904
- .cache(cacheUtil.defaultTTL, id_project+":requests:request_id:"+request_id)
904
+ //@DISABLED_CACHE .cache(cacheUtil.defaultTTL, id_project+":requests:request_id:"+request_id)
905
905
  .exec(function(err, request) {
906
906
  if (err) {
907
907
  winston.error(err);
@@ -0,0 +1,74 @@
1
+
2
+
3
+ 'use strict';
4
+ var global = require('../config/global');
5
+ var email = require('../config/email');
6
+ var winston = require('../config/winston');
7
+
8
+
9
+
10
+
11
+ class OrgUtil {
12
+
13
+ constructor() {
14
+ this.ORGANIZATION_ENABLED = process.env.ORGANIZATION_ENABLED || global.organizationEnabled;
15
+ if (this.ORGANIZATION_ENABLED===true || this.ORGANIZATION_ENABLED === "true") {
16
+ this.ORGANIZATION_ENABLED = true;
17
+ }else {
18
+ this.ORGANIZATION_ENABLED = false;
19
+ }
20
+
21
+ winston.info("Organization enabled: "+ this.ORGANIZATION_ENABLED );
22
+
23
+ this.ORGANIZATION_BASE_URL = process.env.ORGANIZATION_BASE_URL || global.organizationBaseUrl;
24
+ winston.info("Organization base url: "+ this.ORGANIZATION_BASE_URL );
25
+
26
+ }
27
+
28
+ getOrg(req) {
29
+
30
+ // if (this.ORGANIZATION_ENABLED===false) {
31
+ // return undefined;
32
+ // }
33
+
34
+
35
+ // let host = req.get('host');
36
+ // winston.info("host: "+ host );
37
+
38
+ let origin = req.get('origin');
39
+ winston.info("origin: "+ origin );
40
+
41
+ // winston.info("email: " + email.baseUrl);
42
+ winston.info("this.ORGANIZATION_BASE_URL: " + this.ORGANIZATION_BASE_URL);
43
+ // global.organizationBaseUrl
44
+ // if (host !=email.baseUrl ) {
45
+ if (origin && origin.indexOf(this.ORGANIZATION_BASE_URL)>-1) {
46
+ // if (origin!=this.ORGANIZATION_BASE_URL) {
47
+ // winston.info("host found: "+ host );
48
+ // return host;
49
+ winston.info("origin found: "+ origin );
50
+ return origin;
51
+ }
52
+ winston.info("origin not found: "+ origin );
53
+
54
+ // winston.info("host not found: "+ host );
55
+ // if (host.indexOf("localhost1")>-1) {
56
+ // console.log("host found: "+ host );
57
+ // return "localhost";
58
+ // }
59
+ return undefined;
60
+
61
+ }
62
+
63
+
64
+
65
+
66
+
67
+
68
+ }
69
+
70
+
71
+ var orgUtil = new OrgUtil();
72
+
73
+
74
+ module.exports = orgUtil;
@@ -23,14 +23,14 @@ async send(sender, senderFullname, recipient, text, id_project, createdBy, attri
23
23
  winston.debug("bot id: "+id);
24
24
  sender = id; //change sender removing bot_
25
25
  var bot = await Faq_kb.findById(id)
26
- .cache(cacheUtil.defaultTTL, id_project+":faq_kbs:id:"+id)
26
+ //@DISABLED_CACHE .cache(cacheUtil.defaultTTL, id_project+":faq_kbs:id:"+id)
27
27
  .exec();
28
28
  winston.debug("bot",bot);
29
29
  senderFullname = bot.name;
30
30
  } else {
31
31
  winston.debug("user id: "+sender);
32
32
  var user = await User.findById(sender)
33
- .cache(cacheUtil.defaultTTL, "users:id:"+sender)
33
+ //@DISABLED_CACHE .cache(cacheUtil.defaultTTL, "users:id:"+sender)
34
34
  .exec()
35
35
  winston.debug("user", user);
36
36
  senderFullname = user.fullName;
@@ -93,7 +93,7 @@ class WebSocketServer {
93
93
  // winston.debug('ok websocket');
94
94
 
95
95
  User.findOne({_id: identifier, status: 100}, 'email firstname lastname emailverified id')
96
- .cache(cacheUtil.defaultTTL, "users:id:"+identifier)
96
+ //@DISABLED_CACHE .cache(cacheUtil.defaultTTL, "users:id:"+identifier)
97
97
  .exec(function (err, user) {
98
98
 
99
99
 
@@ -176,7 +176,7 @@ class WebSocketServer {
176
176
 
177
177
 
178
178
  return Project.findOne({ _id: projectId, status: 100})
179
- .cache(cacheUtil.defaultTTL, "projects:id:"+projectId)
179
+ //@DISABLED_CACHE .cache(cacheUtil.defaultTTL, "projects:id:"+projectId)
180
180
  .exec(function(err, project) {
181
181
  if (err) {
182
182
  winston.error('WebSocket - Error getting Project', err);
@@ -197,7 +197,7 @@ class WebSocketServer {
197
197
 
198
198
 
199
199
  Project_user.findOne({ id_project: projectId, id_user: req.user._id, $or:[ {"role": "agent"}, {"role": "admin"}, {"role": "owner"}], status: "active" })
200
- .cache(cacheUtil.defaultTTL, projectId+":project_users:role:teammate:"+req.user._id)
200
+ //@DISABLED_CACHE .cache(cacheUtil.defaultTTL, projectId+":project_users:role:teammate:"+req.user._id)
201
201
  .exec(function (err, projectuser) {
202
202
  if (err) {
203
203
  winston.error('WebSocket error getting Project_user', err);
@@ -266,7 +266,7 @@ class WebSocketServer {
266
266
 
267
267
 
268
268
  Project_user.findOne({ id_project: projectId, id_user: req.user._id, $or:[ {"role": "agent"}, {"role": "admin"}, {"role": "owner"}], status: "active"})
269
- .cache(cacheUtil.defaultTTL, projectId+":project_users:role:teammate:"+req.user._id)
269
+ //@DISABLED_CACHE .cache(cacheUtil.defaultTTL, projectId+":project_users:role:teammate:"+req.user._id)
270
270
  .exec(function (err, projectuser) {
271
271
  if (err) {
272
272
  winston.error('WebSocket error getting Project_user', err);
@@ -315,7 +315,7 @@ class WebSocketServer {
315
315
  .limit(lastRequestsLimit)
316
316
  // DISABLED 23Marzo2021 per problema request.snapshot.requester.isAuthenticated = undefined
317
317
  .lean() //https://www.tothenew.com/blog/high-performance-find-query-using-lean-in-mongoose-2/ https://stackoverflow.com/questions/33104136/mongodb-mongoose-slow-query-when-fetching-10k-documents
318
- .cache(cacheUtil.queryTTL, projectId+":requests:query:status-50-1000:preflight-false:select_snapshot_agents:"+cacheUserId)
318
+ //@DISABLED_CACHE .cache(cacheUtil.queryTTL, projectId+":requests:query:status-50-1000:preflight-false:select_snapshot_agents:"+cacheUserId)
319
319
  .exec(function(err, requests) {
320
320
 
321
321
  if (err) {
@@ -381,7 +381,7 @@ class WebSocketServer {
381
381
 
382
382
  //check if current user can see the data
383
383
  Project_user.findOne({ id_project: projectId, id_user: req.user._id, $or:[ {"role": "agent"}, {"role": "admin"}, {"role": "owner"}], status: "active"})
384
- .cache(cacheUtil.defaultTTL, projectId+":project_users:role:teammate:"+req.user._id)
384
+ //@DISABLED_CACHE .cache(cacheUtil.defaultTTL, projectId+":project_users:role:teammate:"+req.user._id)
385
385
  .exec(function (err, currentProjectuser) {
386
386
  if (err) {
387
387
  winston.error('WebSocket error getting Project_user', err);
@@ -407,7 +407,7 @@ class WebSocketServer {
407
407
  }
408
408
 
409
409
  Project_user.findOne(query)
410
- .cache(cacheUtil.defaultTTL, projectId+":project_users:users:"+userId)
410
+ // @DISABLED_CACHE .cache(cacheUtil.defaultTTL, projectId+":project_users:users:"+userId)
411
411
  .exec(function (err, projectuser) {
412
412
  if (err) {
413
413
  winston.error('WebSocket error getting Project_user', err);
@@ -451,7 +451,7 @@ class WebSocketServer {
451
451
  winston.debug(' query: ',query);
452
452
 
453
453
  Project_user.findOne(query)
454
- .cache(cacheUtil.defaultTTL, projectId+":project_users:"+puId)
454
+ // @DISABLED_CACHE .cache(cacheUtil.defaultTTL, projectId+":project_users:"+puId)
455
455
  .exec(function (err, projectuser) {
456
456
  if (err) {
457
457
  winston.error('WebSocket error getting Project_user', err);
@@ -491,7 +491,7 @@ class WebSocketServer {
491
491
  winston.debug(' query: ',query);
492
492
 
493
493
  EventModel.find(query)
494
- .cache(cacheUtil.defaultTTL, projectId+":events:"+puId)
494
+ // @DISABLED_CACHE .cache(cacheUtil.defaultTTL, projectId+":events:"+puId)
495
495
  .sort({createdAt: 'desc'})
496
496
  .limit(lastEventsLimit)
497
497
  .exec(function(err, events) {
@@ -518,7 +518,7 @@ class WebSocketServer {
518
518
  winston.debug('recipientId: '+recipientId);
519
519
 
520
520
  Project_user.findOne({ id_project: projectId, id_user: req.user._id, $or:[ {"role": "agent"}, {"role": "admin"}, {"role": "owner"}], status: "active" })
521
- .cache(cacheUtil.defaultTTL, projectId+":project_users:role:teammate:"+req.user._id)
521
+ // @DISABLED_CACHE .cache(cacheUtil.defaultTTL, projectId+":project_users:role:teammate:"+req.user._id)
522
522
  .exec(function (err, projectuser) {
523
523
  if (err) {
524
524
  winston.error('WebSocket error getting Project_user', err);