@tiledesk/tiledesk-server 2.10.13 → 2.10.15

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,13 @@
5
5
  🚀 IN PRODUCTION 🚀
6
6
  (https://www.npmjs.com/package/@tiledesk/tiledesk-server/v/2.3.77)
7
7
 
8
+ # 2.10.15
9
+ - Readded event on fully_abandoned request
10
+
11
+ # 2.10.14
12
+ - Updated tybot-connector to 0.2.127
13
+ - Restored request.js file
14
+
8
15
  # 2.10.13
9
16
  - Updated tybot-connector to 0.2.127
10
17
  - Added event on request fully abandoned
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.10.13",
4
+ "version": "2.10.15",
5
5
  "scripts": {
6
6
  "start": "node ./bin/www",
7
7
  "pretest": "mongodb-runner start",
package/routes/request.js CHANGED
@@ -183,7 +183,7 @@ router.post('/',
183
183
 
184
184
  winston.debug('res.json(savedRequest)');
185
185
  var endTimestamp = new Date();
186
- winston.verbose("(Request Route) request create end: " + (endTimestamp - startTimestamp));
186
+ winston.verbose("request create end: " + (endTimestamp - startTimestamp));
187
187
  return res.json(savedRequest);
188
188
  // });
189
189
  // });
@@ -274,7 +274,7 @@ router.patch('/:requestid', function (req, res) {
274
274
 
275
275
 
276
276
 
277
- winston.verbose("(Request Route) Request patch update", update);
277
+ winston.verbose("Request patch update", update);
278
278
 
279
279
  //cacheinvalidation
280
280
  return Request.findOneAndUpdate({ "request_id": req.params.requestid, "id_project": req.projectid }, { $set: update }, { new: true, upsert: false })
@@ -327,18 +327,18 @@ router.put('/:requestid/close', async function (req, res) {
327
327
  })
328
328
 
329
329
  if (!request) {
330
- winston.verbose("(Request Route) Request with request_id " + request_id)
330
+ winston.verbose("Request with request_id " + request_id)
331
331
  return res.status(404).send({ success: false, error: "Request not found"})
332
332
  }
333
333
 
334
334
  if (!request.participantsAgents.includes(req.user.id)) {
335
- winston.verbose("(Request Route) Request can't be closed by a non participant. Attempt made by " + req.user.id);
335
+ winston.verbose("Request can't be closed by a non participant. Attempt made by " + req.user.id);
336
336
  return res.status(403).send({ success: false, error: "You must be among the participants to close a conversation."})
337
337
  }
338
338
  }
339
339
 
340
340
  return requestService.closeRequestByRequestId(req.params.requestid, req.projectid, false, true, closed_by, req.body.force).then(function (closedRequest) {
341
- winston.verbose("(Request Route) request closed", closedRequest);
341
+ winston.verbose("request closed", closedRequest);
342
342
  return res.json(closedRequest);
343
343
  });
344
344
 
@@ -350,7 +350,7 @@ router.put('/:requestid/reopen', function (req, res) {
350
350
  // reopenRequestByRequestId(request_id, id_project) {
351
351
  return requestService.reopenRequestByRequestId(req.params.requestid, req.projectid).then(function (reopenRequest) {
352
352
 
353
- winston.verbose("(Request Route) request reopen", reopenRequest);
353
+ winston.verbose("request reopen", reopenRequest);
354
354
 
355
355
  return res.json(reopenRequest);
356
356
  });
@@ -381,7 +381,7 @@ router.post('/:requestid/participants',
381
381
  //addParticipantByRequestId(request_id, id_project, member)
382
382
  return requestService.addParticipantByRequestId(req.params.requestid, req.projectid, req.body.member).then(function (updatedRequest) {
383
383
 
384
- winston.verbose("(Request Route) participant added", updatedRequest);
384
+ winston.verbose("participant added", updatedRequest);
385
385
 
386
386
  return res.json(updatedRequest);
387
387
  });
@@ -421,7 +421,7 @@ router.delete('/:requestid/participants/:participantid', function (req, res) {
421
421
  //removeParticipantByRequestId(request_id, id_project, member)
422
422
  return requestService.removeParticipantByRequestId(req.params.requestid, req.projectid, req.params.participantid).then(function (updatedRequest) {
423
423
 
424
- winston.verbose("(Request Route) participant removed", updatedRequest);
424
+ winston.verbose("participant removed", updatedRequest);
425
425
 
426
426
  return res.json(updatedRequest);
427
427
  });
@@ -452,16 +452,15 @@ router.delete('/:requestid/participants/:participantid', function (req, res) {
452
452
  router.put('/:requestid/assign', function (req, res) {
453
453
  winston.debug(req.body);
454
454
 
455
- let id_project = req.projectid;
456
455
  let user = req.user;
457
456
  let pu;
458
457
  if (req.projectuser) {
459
- pu = req.projectuser.id;
458
+ pu = req.projectuser._id
460
459
  }
461
-
462
460
  // leggi la request se già assegnata o già chiusa (1000) esci
463
- // cacheinvalidation
464
- return Request.findOne({ "request_id": req.params.requestid, "id_project": id_project })
461
+
462
+ //cacheinvalidation
463
+ return Request.findOne({ "request_id": req.params.requestid, "id_project": req.projectid })
465
464
  .exec(function (err, request) {
466
465
 
467
466
  if (err) {
@@ -474,16 +473,16 @@ router.put('/:requestid/assign', function (req, res) {
474
473
  }
475
474
 
476
475
  if (request.status === RequestConstants.ASSIGNED || request.status === RequestConstants.SERVED || request.status === RequestConstants.CLOSED) {
477
- winston.verbose('(Request Route) Request already assigned');
476
+ winston.info('Request already assigned');
478
477
  return res.json(request);
479
478
  }
480
479
  //route(request_id, departmentid, id_project) {
481
- requestService.route(req.params.requestid, req.body.departmentid, id_project, req.body.nobot, req.body.no_populate).then(function (updatedRequest) {
480
+ requestService.route(req.params.requestid, req.body.departmentid, req.projectid, req.body.nobot, req.body.no_populate).then(function (updatedRequest) {
481
+
482
+ winston.debug("department changed", updatedRequest);
482
483
 
483
- winston.debug("request routed ", updatedRequest);
484
-
485
484
  if (updatedRequest.status === RequestConstants.ABANDONED) {
486
- eventService.emit('request.fully_abandoned', updatedRequest, id_project, pu, user._id, undefined, user);
485
+ eventService.emit('request.fully_abandoned', updatedRequest, req.projectid, pu, user._id, undefined, user)
487
486
  }
488
487
 
489
488
  return res.json(updatedRequest);
@@ -635,7 +634,7 @@ router.patch('/:requestid/attributes', function (req, res) {
635
634
  winston.error("error saving request attributes", err)
636
635
  return res.status(500).send({ success: false, msg: 'Error getting object.' });
637
636
  }
638
- winston.verbose("(Request Route) saved request attributes", savedRequest.toObject())
637
+ winston.verbose(" saved request attributes", savedRequest.toObject())
639
638
  requestEvent.emit("request.update", savedRequest);
640
639
  requestEvent.emit("request.update.comment", { comment: "ATTRIBUTES_PATCH", request: savedRequest });//Deprecated
641
640
  requestEvent.emit("request.updated", { comment: "ATTRIBUTES_PATCH", request: savedRequest, patch: { attributes: data } });
@@ -668,7 +667,7 @@ router.post('/:requestid/notes', async function (req, res) {
668
667
 
669
668
  // Check if the user is a participant
670
669
  if (!request.participantsAgents.includes(req.user.id)) {
671
- winston.verbose("(Request Route) Trying to add a note from a non participating agent");
670
+ winston.verbose("Trying to add a note from a non participating agent");
672
671
  return res.status(403).send({ success: false, error: "You are not participating in the conversation"})
673
672
  }
674
673
  }
@@ -714,7 +713,7 @@ router.delete('/:requestid/notes/:noteid', async function (req, res) {
714
713
 
715
714
  // Check if the user is a participant
716
715
  if (!request.participantsAgents.includes(req.user.id)) {
717
- winston.verbose("(Request Route) Trying to delete a note from a non participating agent");
716
+ winston.verbose("Trying to delete a note from a non participating agent");
718
717
  return res.status(403).send({ success: false, error: "You are not participating in the conversation"})
719
718
  }
720
719
  }
@@ -784,7 +783,7 @@ router.post('/:requestid/email/send',
784
783
  }
785
784
 
786
785
  let newto = request.lead.email
787
- winston.verbose("(Request Route) Sending an email newto " + newto);
786
+ winston.verbose("Sending an email newto " + newto);
788
787
 
789
788
  //sendEmailDirect(to, text, project, request_id, subject, tokenQueryString, sourcePage, payload)
790
789
  emailService.sendEmailDirect(newto, text, req.project, request_id, subject, undefined, undefined, undefined, replyto);
@@ -807,7 +806,7 @@ router.post('/:requestid/followers',
807
806
  check('member').notEmpty(),
808
807
  ],
809
808
  function (req, res) {
810
- winston.verbose("(Request Route) followers add", req.body);
809
+ winston.info("followers add", req.body);
811
810
 
812
811
  const errors = validationResult(req);
813
812
  if (!errors.isEmpty()) {
@@ -817,7 +816,7 @@ router.post('/:requestid/followers',
817
816
  //addParticipantByRequestId(request_id, id_project, member)
818
817
  return requestService.addFollowerByRequestId(req.params.requestid, req.projectid, req.body.member).then(function (updatedRequest) {
819
818
 
820
- winston.verbose("(Request Route) participant added", updatedRequest);
819
+ winston.verbose("participant added", updatedRequest);
821
820
 
822
821
  return res.json(updatedRequest);
823
822
  });
@@ -850,7 +849,7 @@ router.delete('/:requestid/followers/:followerid', function (req, res) {
850
849
  //removeFollowerByRequestId(request_id, id_project, member)
851
850
  return requestService.removeFollowerByRequestId(req.params.requestid, req.projectid, req.params.followerid).then(function (updatedRequest) {
852
851
 
853
- winston.verbose("(Request Route) follower removed", updatedRequest);
852
+ winston.verbose("follower removed", updatedRequest);
854
853
 
855
854
  return res.json(updatedRequest);
856
855
  });
@@ -877,7 +876,7 @@ router.delete('/:requestid', function (req, res) {
877
876
  if (err) {
878
877
  return res.status(500).send({ success: false, msg: 'Error deleting messages.' });
879
878
  }
880
- winston.verbose('(Request Route) Messages deleted for the recipient: ' + req.params.requestid);
879
+ winston.verbose('Messages deleted for the recipient: ' + req.params.requestid);
881
880
  });
882
881
 
883
882
 
@@ -891,7 +890,7 @@ router.delete('/:requestid', function (req, res) {
891
890
  return res.status(404).send({ success: false, msg: 'Object not found.' });
892
891
  }
893
892
 
894
- winston.verbose('(Request Route) Request deleted with request_id: ' + req.params.requestid);
893
+ winston.verbose('Request deleted with request_id: ' + req.params.requestid);
895
894
 
896
895
  requestEvent.emit('request.delete', request);
897
896
 
@@ -939,7 +938,7 @@ router.delete('/id/:id', function (req, res) {
939
938
  return res.status(404).send({ success: false, msg: 'Object not found.' });
940
939
  }
941
940
 
942
- winston.verbose('(Request Route) Request deleted with id: ' + req.params.id);
941
+ winston.verbose('Request deleted with id: ' + req.params.id);
943
942
 
944
943
  requestEvent.emit('request.delete', request);
945
944
 
@@ -1212,7 +1211,7 @@ router.get('/', function (req, res, next) {
1212
1211
  } else if (req.query.duration_op === 'lt') {
1213
1212
  query.duration = { $lte: duration }
1214
1213
  } else {
1215
- winston.verbose("(Request Route) Duration operator can be 'gt' or 'lt'. Skip duration_op " + req.query.duration_op)
1214
+ winston.verbose("Duration operator can be 'gt' or 'lt'. Skip duration_op " + req.query.duration_op)
1216
1215
  }
1217
1216
  }
1218
1217
 
@@ -1228,12 +1227,12 @@ router.get('/', function (req, res, next) {
1228
1227
 
1229
1228
  if (req.query.full_text) {
1230
1229
  if (req.query.no_textscore != "true" && req.query.no_textscore != true) {
1231
- winston.verbose('(Request Route) fulltext projection on');
1230
+ winston.verbose('fulltext projection on');
1232
1231
  projection = { score: { $meta: "textScore" } };
1233
1232
  }
1234
1233
  }
1235
1234
 
1236
- winston.verbose('(Request Route) Find request with query ', query);
1235
+ winston.verbose('REQUEST ROUTE - REQUEST FIND QUERY ', query);
1237
1236
 
1238
1237
  var q1 = Request.find(query, projection).
1239
1238
  skip(skip).limit(limit);
@@ -1262,7 +1261,7 @@ router.get('/', function (req, res, next) {
1262
1261
  var q2 = Request.countDocuments(query).exec();
1263
1262
 
1264
1263
  if (req.query.no_count && req.query.no_count == "true") {
1265
- winston.verbose('(Request Route) - no_count');
1264
+ winston.info('REQUEST ROUTE - no_count ');
1266
1265
  q2 = 0;
1267
1266
  }
1268
1267
 
@@ -1274,16 +1273,16 @@ router.get('/', function (req, res, next) {
1274
1273
  count: results[1],
1275
1274
  requests: results[0]
1276
1275
  };
1277
- winston.debug('(Request Route) - objectToReturn ');
1278
- winston.debug('(Request Route) - objectToReturn ', objectToReturn);
1276
+ winston.debug('REQUEST ROUTE - objectToReturn ');
1277
+ winston.debug('REQUEST ROUTE - objectToReturn ', objectToReturn);
1279
1278
 
1280
1279
  const endExecTime = new Date();
1281
- winston.verbose('(Request Route) - exec time: ' + (endExecTime - startExecTime));
1280
+ winston.verbose('REQUEST ROUTE - exec time: ' + (endExecTime - startExecTime));
1282
1281
 
1283
1282
  return res.json(objectToReturn);
1284
1283
 
1285
1284
  }).catch(function (err) {
1286
- winston.error('(Request Route) find request error ', err);
1285
+ winston.error('REQUEST ROUTE - REQUEST FIND ERR ', err);
1287
1286
  return res.status(500).send({ success: false, msg: 'Error getting requests.', err: err });
1288
1287
  });
1289
1288
 
@@ -1835,7 +1834,7 @@ router.get('/csv', function (req, res, next) {
1835
1834
  } else if (req.query.duration_op === 'lt') {
1836
1835
  query.duration = { $lte: duration }
1837
1836
  } else {
1838
- winston.verbose("(Request Route) Duration operator can be 'gt' or 'lt'. Skip duration_op " + req.query.duration_op)
1837
+ winston.verbose("Duration operator can be 'gt' or 'lt'. Skip duration_op " + req.query.duration_op)
1839
1838
  }
1840
1839
  }
1841
1840
 
@@ -2162,4 +2161,4 @@ router.get('/:requestid/chatbot/parameters', async (req, res) => {
2162
2161
 
2163
2162
  })
2164
2163
 
2165
- module.exports = router;
2164
+ module.exports = router;