@tiledesk/tiledesk-server 2.9.15 → 2.9.17

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@
5
5
  🚀 IN PRODUCTION 🚀
6
6
  (https://www.npmjs.com/package/@tiledesk/tiledesk-server/v/2.3.77)
7
7
 
8
+ # 2.9.17
9
+ - Added: /requests/count endpoint
10
+
11
+ # 2.9.16
12
+ - Update: change automatically the content status on re-index
13
+
8
14
  # 2.9.15
9
15
  - Updated jobs-worker-queue-manager
10
16
 
package/app.js CHANGED
@@ -422,7 +422,13 @@ if (process.env.ROUTELOGGER_ENABLED==="true") {
422
422
  winston.info("RouterLogger disabled ");
423
423
  }
424
424
 
425
- app.get('/', function (req, res) {
425
+ app.get('/', function (req, res) {
426
+
427
+ console.log("(/api) req ", req.headers)
428
+ console.log("(/api) x-forwarded-for: ", req.headers['x-forwarded-for'], "remote port: ", req.socket.remotePort);
429
+ console.log("(/api) X-Real-IP ", req.headers['X-Real-IP'])
430
+ console.log("(/api) remoteAddress: ", req.socket.remoteAddress)
431
+
426
432
  res.send('Hello from Tiledesk server. It\'s UP. See the documentation here http://developer.tiledesk.com');
427
433
  });
428
434
 
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.9.15",
4
+ "version": "2.9.17",
5
5
  "scripts": {
6
6
  "start": "node ./bin/www",
7
7
  "pretest": "mongodb-runner start",
@@ -48,7 +48,7 @@
48
48
  "@tiledesk/tiledesk-rasa-connector": "^1.0.10",
49
49
  "@tiledesk/tiledesk-telegram-connector": "^0.1.14",
50
50
  "@tiledesk/tiledesk-train-jobworker": "^0.0.11",
51
- "@tiledesk/tiledesk-tybot-connector": "^0.2.95",
51
+ "@tiledesk/tiledesk-tybot-connector": "^0.2.96-rc1",
52
52
  "@tiledesk/tiledesk-whatsapp-connector": "^0.1.72",
53
53
  "@tiledesk/tiledesk-whatsapp-jobworker": "^0.0.8",
54
54
  "@tiledesk/tiledesk-sms-connector": "^0.1.7",
package/routes/kb.js CHANGED
@@ -1208,14 +1208,20 @@ async function startScrape(data) {
1208
1208
  data.gptkey = gptkey;
1209
1209
  }
1210
1210
 
1211
+
1212
+ let status_updated = await updateStatus(data.id, 200);
1213
+ winston.verbose("status of kb " + data.id + " updated: " + status_updated);
1214
+
1211
1215
  return new Promise((resolve, reject) => {
1212
1216
  openaiService.singleScrape(data).then(async (resp) => {
1213
1217
  winston.debug("singleScrape resp: ", resp.data);
1214
- let status_updated = await updateStatus(data.id, 100);
1218
+ let status_updated = await updateStatus(data.id, 300);
1215
1219
  winston.verbose("status of kb " + data.id + " updated: " + status_updated);
1216
1220
  resolve(resp.data);
1217
- }).catch((err) => {
1221
+ }).catch( async (err) => {
1218
1222
  winston.error("singleScrape err: ", err);
1223
+ let status_updated = await updateStatus(data.id, 400);
1224
+ winston.verbose("status of kb " + data.id + " updated: " + status_updated);
1219
1225
  reject(err);
1220
1226
  })
1221
1227
  })
package/routes/project.js CHANGED
@@ -906,7 +906,7 @@ router.get('/:projectid/users/availables', async (req, res) => {
906
906
  });
907
907
  });
908
908
  } catch (err) {
909
- wisnton.error("(Users Availables) check operating hours error: ", err);
909
+ winston.error("(Users Availables) check operating hours error: ", err);
910
910
  return res.status(500).send({ success: false, msg: err });
911
911
  }
912
912
  }
package/routes/request.js CHANGED
@@ -1463,6 +1463,52 @@ router.get('/csv', function (req, res, next) {
1463
1463
 
1464
1464
  });
1465
1465
 
1466
+ router.get('/count', async (req, res) => {
1467
+
1468
+ let id_project = req.projectid;
1469
+ let merge_assigned = req.query.merge_assigned;
1470
+
1471
+ let unassigned_count = 0;
1472
+ let human_assigned_count = 0;
1473
+ let bot_assigned_count = 0;
1474
+
1475
+ unassigned_count = await Request.countDocuments({ id_project: id_project, status: 100, preflight: false }).catch((err) => {
1476
+ winston.error("Error getting unassigned requests count: ", err);
1477
+ res.status(400).send({ success: false, error: err });
1478
+ })
1479
+ winston.info("Unassigned count: ", unassigned_count);
1480
+
1481
+ human_assigned_count = await Request.countDocuments({ id_project: id_project, status: 200, preflight: false, hasBot: false }).catch((err) => {
1482
+ winston.error("Error getting human unassigned requests count: ", err);
1483
+ res.status(400).send({ success: false, error: err });
1484
+ })
1485
+ winston.info("Unassigned count: ", unassigned_count);
1486
+
1487
+ bot_assigned_count = await Request.countDocuments({ id_project: id_project, status: 200, preflight: false, hasBot: true }).catch((err) => {
1488
+ winston.error("Error getting bot assigned requests count: ", err);
1489
+ res.status(400).send({ success: false, error: err });
1490
+ })
1491
+ winston.info("Unassigned count: ", bot_assigned_count);
1492
+
1493
+
1494
+ if (merge_assigned) {
1495
+ let data = {
1496
+ unassigned: unassigned_count,
1497
+ assigned: human_assigned_count + bot_assigned_count
1498
+ }
1499
+ return res.status(200).send(data);
1500
+
1501
+ } else {
1502
+ let data = {
1503
+ unassigned: unassigned_count,
1504
+ assigned: human_assigned_count,
1505
+ bot_assigned: bot_assigned_count
1506
+ }
1507
+ return res.status(200).send(data);
1508
+ }
1509
+
1510
+ })
1511
+
1466
1512
  router.get('/:requestid', function (req, res) {
1467
1513
 
1468
1514
  var requestid = req.params.requestid;
@@ -1517,5 +1563,4 @@ router.get('/:requestid/chatbot/parameters', async (req, res) => {
1517
1563
 
1518
1564
  })
1519
1565
 
1520
-
1521
1566
  module.exports = router;
@@ -196,6 +196,28 @@ class WebSocketServer {
196
196
  var projectId = urlSub[1];
197
197
  winston.debug('projectId: ' + projectId);
198
198
 
199
+ if (projectId === "65203e12f8c0cf002cf4110b"
200
+ || projectId === "62c3f10152dc7400352bab0d"
201
+ || projectId === "66acec0cf7ebf80013d67974"
202
+ || projectId === "6613ff078890fc0013ad3c3a"
203
+ || projectId === "6565047fdd64fd001323f37c"
204
+ || projectId === "656054000410fa00132e5dcc") {
205
+
206
+ console.log('(WebSocket) WSS onSubscribeCallback - ProjectID ' + projectId);
207
+ console.log("(WebSocket) req ", req.headers)
208
+ console.log("(WebSocket) x-forwarded-for: ", req.headers['x-forwarded-for'], "remote port: ", req.socket.remotePort);
209
+ console.log("(/api) X-Real-IP ", req.headers['X-Real-IP'])
210
+ console.log("(WebSocket) remoteAddress: ", req.socket.remoteAddress)
211
+
212
+
213
+ try {
214
+ console.log("req: ", JSON.stringify(req))
215
+ } catch(err) {
216
+ console.log("Unable to stringify request")
217
+ console.log("req: ", req)
218
+ }
219
+
220
+ }
199
221
 
200
222
  let q = Project.findOne({ _id: projectId, status: 100 })
201
223