@tiledesk/tiledesk-server 2.3.29 → 2.3.31

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
 
2
- # Untagged
2
+
3
+ # 2.3.31
4
+ - logfix
5
+
6
+ # 2.3.30
7
+ - save multiple messages fix with sequential promises
8
+ - JSON_BODY_LIMIT increased to 500KB. Added JSON_BODY_LIMIT env variable
9
+
10
+ # 2.3.29
3
11
  - UIDGenerator class replacement for request route
4
12
  - Added hasRole cache for project_user
5
13
  - Added index { id_project: 1, role: 1, status: 1, createdAt: 1 } for Project_user schema
@@ -9,9 +17,14 @@
9
17
  - Log fix
10
18
  - add fields reply and enabled to faq model
11
19
  - field answer in faq model is no longer required
12
- - add field public to faq_kb model (IGNORA PER IL MOMENTO)
20
+ - add field public to faq_kb model
13
21
  - when template is undefined the empty template is now created
14
- - add test
22
+ - Add unit test for project and project_user
23
+ - Created new endpoint for creating new requests with unit test
24
+ - Created new endpoint for inserting multiple messages at once with unit test
25
+ - New validation for empty text for new message endpoint
26
+ - Added project_user_test route
27
+ - Unit test fix
15
28
 
16
29
  # 2.3.28
17
30
  - UIDGenerator renamed fix
@@ -29,7 +42,7 @@
29
42
 
30
43
  # 2.3.24
31
44
  - Increased cache TTL from: standardTTL from 120 to 300, longTTL from 1200 to 3600
32
- - Added cache request.create.simple, + cacheEnabler. name fix
45
+ - Added cache request.create.simple + cacheEnabler. name fix
33
46
  - Disabled unapplicable cache for updateWaitingTimeByRequestId and find request by id REST API
34
47
  - Updated dependency @tiledesk/tiledesk-tybot-connector to 0.1.14
35
48
  - Restored populateMessageWithRequest. Bug with \agent command. Try to resolve performance with cache
package/app.js CHANGED
@@ -148,7 +148,6 @@ geoService.listen();
148
148
 
149
149
 
150
150
 
151
-
152
151
  var faqBotHandler = require('./services/faqBotHandler');
153
152
  faqBotHandler.listen();
154
153
 
@@ -225,7 +224,10 @@ if (process.env.ENABLE_ALTERNATIVE_CORS_MIDDLEWARE === "true") {
225
224
 
226
225
  // https://stackoverflow.com/questions/18710225/node-js-get-raw-request-body-using-express
227
226
 
228
- app.use(bodyParser.json({
227
+ const JSON_BODY_LIMIT = process.envJSON_BODY_LIMIT || '500KB';
228
+ winston.debug("JSON_BODY_LIMIT : " + JSON_BODY_LIMIT);
229
+
230
+ app.use(bodyParser.json({limit: JSON_BODY_LIMIT,
229
231
  verify: function (req, res, buf) {
230
232
  // var url = req.originalUrl;
231
233
  // if (url.indexOf('/stripe/')) {
@@ -235,7 +237,7 @@ app.use(bodyParser.json({
235
237
  }
236
238
  }));
237
239
 
238
- app.use(bodyParser.urlencoded({ extended: false }));
240
+ app.use(bodyParser.urlencoded({limit: JSON_BODY_LIMIT, extended: false }));
239
241
 
240
242
  app.use(cookieParser());
241
243
  app.use(express.static(path.join(__dirname, 'public')));
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.3.29",
4
+ "version": "2.3.31",
5
5
  "scripts": {
6
6
  "start": "node ./bin/www",
7
7
  "pretest": "mongodb-runner start",
package/routes/message.js CHANGED
@@ -21,6 +21,7 @@ const { check, validationResult } = require('express-validator');
21
21
 
22
22
  var Project_user = require("../models/project_user");
23
23
  var mongoose = require('mongoose');
24
+ var PromiseUtil = require("../utils/promiseUtil");
24
25
 
25
26
  csv = require('csv-express');
26
27
  csv.separator = ';';
@@ -406,7 +407,8 @@ async (req, res) => {
406
407
  });
407
408
  winston.debug('--- >promises', promises);
408
409
 
409
- Promise.all(promises).then((values) => {
410
+ //Promise.all(promises).then((values) => {
411
+ PromiseUtil.doAllSequentually(promises).then((values) => {
410
412
  winston.info('Inserted multiple messages with values: ', values);
411
413
  return res.status(200).json(values);
412
414
  }).catch((err) => {
@@ -513,7 +513,7 @@ class RequestService {
513
513
  try {
514
514
  // getOperators(departmentid, projectid, nobot, disableWebHookCall, context) {
515
515
  var result = await departmentService.getOperators(departmentid, id_project, false, undefined, context);
516
- console.log("************* after get operator: "+new Date().toISOString());
516
+ // console.log("************* after get operator: "+new Date().toISOString());
517
517
 
518
518
  winston.debug("getOperators", result);
519
519
  } catch(err) {
@@ -0,0 +1,31 @@
1
+ class PromiseUtil {
2
+
3
+ async doAllSequentually(promises) {
4
+ // return new Promise(async function (resolve, reject) {
5
+ // console.log("promises",promises);
6
+ var values = [];
7
+ for (let i=0; i < promises.length; i++) {
8
+ // console.log("promises[i]",promises[i]);
9
+
10
+ // const val = await
11
+ var value = await promises[i]
12
+ // .then(function(value) {
13
+ // console.log("done promises[i]",value);
14
+ // values.push(value);
15
+ // console.log("values before",values);
16
+ // });
17
+ values.push(value);
18
+ };
19
+
20
+ console.log("values",values);
21
+ // return resolve(values);
22
+
23
+ // });
24
+ return values;
25
+ }
26
+ }
27
+
28
+ var promiseUtil = new PromiseUtil();
29
+
30
+
31
+ module.exports = promiseUtil;