@tiledesk/tiledesk-server 2.13.50 → 2.13.51

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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,10 @@
5
5
  🚀 IN PRODUCTION 🚀
6
6
  (https://www.npmjs.com/package/@tiledesk/tiledesk-server/v/2.3.77)
7
7
 
8
+ # 2.13.51
9
+ - Refactoring of route() and create() method on RequestService in order to improve performance for firt message
10
+ - Updated tests
11
+
8
12
  # 2.13.50
9
13
  - Updated kb route to support embeddings
10
14
  - Updated tybot-connector to 2.0.41
package/app.js CHANGED
@@ -182,6 +182,7 @@ var geoService = require('./services/geoService');
182
182
  // geoService.listen(); //queued
183
183
 
184
184
  var updateLeadQueued = require('./services/updateLeadQueued');
185
+ var updateRequestSnapshotQueued = require('./services/updateRequestSnapshotQueued');
185
186
 
186
187
  let JobsManager = require('./jobsManager');
187
188
 
@@ -191,7 +192,7 @@ if (process.env.JOB_WORKER_ENABLED=="true" || process.env.JOB_WORKER_ENABLED ==
191
192
  }
192
193
  winston.info("JobsManager jobWorkerEnabled: "+ jobWorkerEnabled);
193
194
 
194
- let jobsManager = new JobsManager(jobWorkerEnabled, geoService, botEvent, subscriptionNotifierQueued, botSubscriptionNotifier, updateLeadQueued);
195
+ let jobsManager = new JobsManager(jobWorkerEnabled, geoService, botEvent, subscriptionNotifierQueued, botSubscriptionNotifier, updateLeadQueued, updateRequestSnapshotQueued);
195
196
 
196
197
  var faqBotHandler = require('./services/faqBotHandler');
197
198
  faqBotHandler.listen();
package/jobs.js CHANGED
@@ -29,6 +29,7 @@ const botEvent = require('./event/botEvent');
29
29
  var channelManager = require('./channels/channelManager');
30
30
 
31
31
  var updateLeadQueued = require('./services/updateLeadQueued');
32
+ var updateRequestSnapshotQueued = require('./services/updateRequestSnapshotQueued');
32
33
 
33
34
 
34
35
  require('./services/mongoose-cache-fn')(mongoose);
@@ -86,7 +87,7 @@ async function main()
86
87
 
87
88
 
88
89
 
89
- let jobsManager = new JobsManager(undefined, geoService, botEvent, subscriptionNotifierQueued, botSubscriptionNotifier, updateLeadQueued);
90
+ let jobsManager = new JobsManager(undefined, geoService, botEvent, subscriptionNotifierQueued, botSubscriptionNotifier, updateLeadQueued, updateRequestSnapshotQueued);
90
91
 
91
92
  jobsManager.listen();
92
93
 
package/jobsManager.js CHANGED
@@ -2,7 +2,7 @@
2
2
  var winston = require('./config/winston');
3
3
 
4
4
  class JobsManager {
5
- constructor(jobWorkerEnabled, geoService, botEvent, subscriptionNotifierQueued, botSubscriptionNotifier, updateLeadQueued) {
5
+ constructor(jobWorkerEnabled, geoService, botEvent, subscriptionNotifierQueued, botSubscriptionNotifier, updateLeadQueued, updateRequestSnapshotQueued) {
6
6
  this.geoService = geoService;
7
7
  this.botEvent = botEvent;
8
8
  // this.subscriptionNotifier = subscriptionNotifier;
@@ -22,6 +22,7 @@ class JobsManager {
22
22
  // winston.info("JobsManager jobWorkerEnabled: "+ this.jobWorkerEnabled);
23
23
 
24
24
  this.updateLeadQueued = updateLeadQueued;
25
+ this.updateRequestSnapshotQueued = updateRequestSnapshotQueued;
25
26
  }
26
27
 
27
28
 
@@ -39,6 +40,10 @@ class JobsManager {
39
40
 
40
41
  this.updateLeadQueued.listen();
41
42
 
43
+ if (this.updateRequestSnapshotQueued) {
44
+ this.updateRequestSnapshotQueued.listen();
45
+ }
46
+
42
47
  // this.botSubscriptionNotifier.start(); // disabled
43
48
  }
44
49
 
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.13.50",
4
+ "version": "2.13.51",
5
5
  "scripts": {
6
6
  "start": "node ./bin/www",
7
7
  "pretest": "mongodb-runner start",
@@ -204,9 +204,10 @@ function startWorker() {
204
204
  winston.info("Data queue", oka)
205
205
  });
206
206
 
207
-
208
-
209
-
207
+ ch.bindQueue(_ok.queue, exchange, "request_snapshot_update", {}, function(err3, oka) {
208
+ winston.info("Queue bind: "+_ok.queue+ " err: "+err3+ " key: request_snapshot_update");
209
+ winston.info("Data queue", oka)
210
+ });
210
211
 
211
212
 
212
213
  ch.consume(queueName, processMsg, { noAck: false });
@@ -320,6 +321,11 @@ function work(msg, cb) {
320
321
  leadEvent.emit('lead.fullname.email.update.queue', JSON.parse(message_string));
321
322
  }
322
323
 
324
+ if (topic === 'request_snapshot_update') {
325
+ winston.debug("reconnect here topic request_snapshot_update:" + topic);
326
+ requestEvent.emit('request.snapshot.update.queue', JSON.parse(message_string));
327
+ }
328
+
323
329
 
324
330
 
325
331
  cb(true);
@@ -404,6 +410,13 @@ function listen() {
404
410
  });
405
411
  });
406
412
 
413
+ requestEvent.on('request.snapshot.update', function(data) {
414
+ setImmediate(() => {
415
+ winston.debug("reconnect request.snapshot.update")
416
+ console.log("reconnect request.snapshot.update")
417
+ publish(exchange, "request_snapshot_update", Buffer.from(JSON.stringify(data)));
418
+ });
419
+ });
407
420
 
408
421
 
409
422
  messageEvent.on('message.create', function(message) {
@@ -184,6 +184,10 @@ function work(msg, cb) {
184
184
  winston.debug("reconnectfanout here topic faqbot_update:" + topic);
185
185
  botEvent.emit('faqbot.update.queue.pubsub', JSON.parse(message_string));
186
186
  }
187
+ if (topic === 'request_snapshot_add') {
188
+ winston.debug("reconnectfanout here topic request_snapshot_add:" + topic);
189
+ requestEvent.emit('request.snapshot.add.queue.pubsub', JSON.parse(message_string));
190
+ }
187
191
  cb(true);
188
192
  // WebSocket.cb(true);
189
193
  // requestEvent.on(msg.KEYYYYYYY+'.ws', msg.content);
package/routes/request.js CHANGED
@@ -570,6 +570,7 @@ router.put('/:requestid/assign', function (req, res) {
570
570
  return res.json(updatedRequest);
571
571
  }).catch(function (error) {
572
572
  // TODO: error log removed due to attempt to reduces logs when no department is found
573
+ console.log('Error changing the department.', error)
573
574
  winston.verbose('Error changing the department.', error)
574
575
  return res.status(500).send({ success: false, msg: 'Error changing the department.' });
575
576
  })
@@ -587,6 +588,7 @@ router.put('/:requestid/departments', function (req, res) {
587
588
  return res.json(updatedRequest);
588
589
  }).catch(function (error) {
589
590
  // TODO: error log removed due to attempt to reduces logs when no department is found
591
+ console.log('Error changing the department.', error)
590
592
  winston.verbose('Error changing the department.', error)
591
593
  return res.status(500).send({ success: false, msg: 'Error changing the department.' });
592
594
  })
@@ -622,6 +624,7 @@ router.put('/:requestid/agent', async (req, res) => {
622
624
  return res.json(updatedRequest);
623
625
  }).catch(function (error) {
624
626
  // TODO: error log removed due to attempt to reduces logs when no department is found
627
+ console.log('Error changing the department.', error)
625
628
  winston.verbose('Error changing the department.', error)
626
629
  return res.status(500).send({ success: false, msg: 'Error changing the department.' });
627
630
  })