@tiledesk/tiledesk-server 2.2.16 → 2.2.20

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
@@ -1,8 +1,14 @@
1
+ # 2.2.19
2
+ - disabled waiting time in widgets endpoint unused
1
3
 
4
+ # 2.2.18
5
+ - Router logger module enable with ROUTELOGGER_ENABLED=true
2
6
 
3
7
 
8
+ # 2.2.17 -> PROD
9
+ - Removed default fallback limit on parse reply
4
10
 
5
- # 2.2.16
11
+ # 2.2.16
6
12
  - Email templates endpoint
7
13
  - Created request.updated event for request event and deprecated request.update.comment
8
14
  - Added Handlebars template processor for the message transformer module only if message.attributes.templateProcessor=true
@@ -11,7 +17,7 @@
11
17
  - Added /intents alias for /faq endpoint
12
18
  - The request_id field of the request model has now a unique index
13
19
 
14
- # 2.2.15 -> PROD
20
+ # 2.2.15
15
21
  - Added catch messageService.send for bot
16
22
  - Added external searcher for bot( ex. Rasa proxy)
17
23
  - Faq language fix taken from bot language for create single and import from csv
package/app.js CHANGED
@@ -107,7 +107,7 @@ var email = require('./routes/email');
107
107
  var bootDataLoader = require('./services/bootDataLoader');
108
108
  var settingDataLoader = require('./services/settingDataLoader');
109
109
  var schemaMigrationService = require('./services/schemaMigrationService');
110
-
110
+ var RouterLogger = require('./models/routerLogger');
111
111
 
112
112
  require('./services/mongoose-cache-fn')(mongoose);
113
113
 
@@ -222,7 +222,42 @@ app.options('*', cors());
222
222
  // const customRedisRateLimiter = require("./rateLimiter").customRedisRateLimiter;
223
223
  // app.use(customRedisRateLimiter);
224
224
 
225
+ if (process.env.ROUTELOGGER_ENABLED==="true") {
226
+ winston.info("RouterLogger enabled ");
227
+ app.use(function (req, res, next) {
228
+ // winston.error("log ", req);
229
+
230
+ try {
231
+ var projectid = req.projectid;
232
+ winston.debug("RouterLogger projectIdSetter projectid:" + projectid);
233
+
234
+ var fullUrl = req.protocol + '://' + req.get('host') + req.originalUrl;
235
+ winston.debug("fullUrl:"+ fullUrl);
236
+ winston.debug("req.get('origin'):" + req.get('origin'));
237
+
238
+ var routerLogger = new RouterLogger({
239
+ origin: req.get('origin'),
240
+ fullurl: fullUrl,
241
+ url: req.originalUrl.split("?").shift(),
242
+ id_project: projectid,
243
+ });
244
+
245
+ routerLogger.save(function (err, savedRouterLogger) {
246
+ if (err) {
247
+ winston.error('Error saving RouterLogger ', err)
248
+ }
249
+ winston.debug("RouterLogger saved "+ savedRouterLogger);
250
+ next();
251
+ });
252
+ }catch(e) {
253
+ winston.error('Error saving RouterLogger ', e)
254
+ next();
255
+ }
256
+ });
225
257
 
258
+ } else {
259
+ winston.info("RouterLogger disabled ");
260
+ }
226
261
 
227
262
  app.get('/', function (req, res) {
228
263
  res.send('Hello from Tiledesk server. It\'s UP. See the documentation here http://developer.tiledesk.com');
@@ -276,6 +311,9 @@ var projectSetter = function (req, res, next) {
276
311
  }
277
312
 
278
313
 
314
+
315
+
316
+
279
317
  // app.use('/admin', admin);
280
318
 
281
319
  //oauth2
@@ -284,6 +322,7 @@ var projectSetter = function (req, res, next) {
284
322
  // app.post('/oauth/token', oauth2.token);
285
323
 
286
324
 
325
+
287
326
  app.use('/auth', auth);
288
327
  app.use('/testauth', [passport.authenticate(['basic', 'jwt'], { session: false }), validtoken], authtest);
289
328
 
@@ -407,6 +446,7 @@ app.use(function (err, req, res, next) {
407
446
  res.render('error');
408
447
  });*/
409
448
 
449
+
410
450
  // error handler
411
451
  app.use((err, req, res, next) => {
412
452
  winston.error("General error", err);
@@ -63,8 +63,8 @@
63
63
 
64
64
  "INFO_SUPPORT_USER_ADDED_SUBJECT":"you",
65
65
  "INFO_SUPPORT_USER_ADDED_YOU_VERB":"you have been added ",
66
- "INFO_SUPPORT_USER_ADDED_COMPLEMENT":"joined",
67
- "INFO_SUPPORT_USER_ADDED_VERB":"to chat",
66
+ "INFO_SUPPORT_USER_ADDED_COMPLEMENT":"the chat",
67
+ "INFO_SUPPORT_USER_ADDED_VERB":"joined",
68
68
  "INFO_SUPPORT_CHAT_REOPENED":"Chat reopened",
69
69
  "INFO_SUPPORT_CHAT_CLOSED":"Chat closed",
70
70
 
@@ -141,8 +141,8 @@
141
141
 
142
142
  "INFO_SUPPORT_USER_ADDED_SUBJECT":"tu",
143
143
  "INFO_SUPPORT_USER_ADDED_YOU_VERB":"sei stato aggiunto ",
144
- "INFO_SUPPORT_USER_ADDED_COMPLEMENT":"si è unito",
145
- "INFO_SUPPORT_USER_ADDED_VERB":"alla chat",
144
+ "INFO_SUPPORT_USER_ADDED_COMPLEMENT":"alla chat",
145
+ "INFO_SUPPORT_USER_ADDED_VERB":"si è unito",
146
146
  "INFO_SUPPORT_CHAT_REOPENED":"Chat riaperta",
147
147
  "INFO_SUPPORT_CHAT_CLOSED":"Chat chiusa",
148
148
 
@@ -217,8 +217,8 @@
217
217
 
218
218
  "INFO_SUPPORT_USER_ADDED_SUBJECT":"toi",
219
219
  "INFO_SUPPORT_USER_ADDED_YOU_VERB":"tu as été ajouté ",
220
- "INFO_SUPPORT_USER_ADDED_COMPLEMENT":"rejoint",
221
- "INFO_SUPPORT_USER_ADDED_VERB":"discuter",
220
+ "INFO_SUPPORT_USER_ADDED_COMPLEMENT":"discuter",
221
+ "INFO_SUPPORT_USER_ADDED_VERB":"rejoint",
222
222
  "INFO_SUPPORT_CHAT_REOPENED":"Chat rouvert",
223
223
  "INFO_SUPPORT_CHAT_CLOSED":"Chat fermé",
224
224
 
@@ -293,8 +293,8 @@
293
293
 
294
294
  "INFO_SUPPORT_USER_ADDED_SUBJECT":"usted",
295
295
  "INFO_SUPPORT_USER_ADDED_YOU_VERB":"usted ha sido agregado ",
296
- "INFO_SUPPORT_USER_ADDED_COMPLEMENT":"unido",
297
- "INFO_SUPPORT_USER_ADDED_VERB":"para charlar",
296
+ "INFO_SUPPORT_USER_ADDED_COMPLEMENT":"para charlar",
297
+ "INFO_SUPPORT_USER_ADDED_VERB":"unido",
298
298
  "INFO_SUPPORT_CHAT_REOPENED":"Chat reabierto",
299
299
  "INFO_SUPPORT_CHAT_CLOSED":"Chat cerrado",
300
300
 
@@ -370,8 +370,8 @@
370
370
 
371
371
  "INFO_SUPPORT_USER_ADDED_SUBJECT": "Sie",
372
372
  "INFO_SUPPORT_USER_ADDED_YOU_VERB": "Sie wurden hinzugefügt ",
373
- "INFO_SUPPORT_USER_ADDED_COMPLEMENT": "beigetreten",
374
- "INFO_SUPPORT_USER_ADDED_VERB": "zum Chatten",
373
+ "INFO_SUPPORT_USER_ADDED_COMPLEMENT": "zum Chatten",
374
+ "INFO_SUPPORT_USER_ADDED_VERB": "beigetreten",
375
375
  "INFO_SUPPORT_CHAT_REOPENED": "Chat wieder geöffnet",
376
376
  "INFO_SUPPORT_CHAT_CLOSED": "Chat geschlossen",
377
377
 
@@ -446,8 +446,8 @@
446
446
 
447
447
  "INFO_SUPPORT_USER_ADDED_SUBJECT": "você",
448
448
  "INFO_SUPPORT_USER_ADDED_YOU_VERB": "você foi adicionado ",
449
- "INFO_SUPPORT_USER_ADDED_COMPLEMENT": "aderiu",
450
- "INFO_SUPPORT_USER_ADDED_VERB": "para conversar",
449
+ "INFO_SUPPORT_USER_ADDED_COMPLEMENT": "para conversar",
450
+ "INFO_SUPPORT_USER_ADDED_VERB": "aderiu",
451
451
  "INFO_SUPPORT_CHAT_REOPENED": "Chat reaberto",
452
452
  "INFO_SUPPORT_CHAT_CLOSED": "Bate-papo fechado",
453
453
 
@@ -0,0 +1,57 @@
1
+ var mongoose = require('mongoose');
2
+ var Schema = mongoose.Schema;
3
+ var config = require('../config/database');
4
+
5
+
6
+ var winston = require('../config/winston');
7
+
8
+ var dbUrl = process.env.MONGODB_LOGS_URI || config.databaselogs || process.env.MONGODB_URI;
9
+ winston.info('VisitorCounterSchema dbUrl: '+dbUrl);
10
+
11
+ // mongoose.set('useFindAndModify', false); //??
12
+ // mongoose.set('useCreateIndex', true);
13
+ // mongoose.set('useUnifiedTopology', true);
14
+
15
+ var conn = mongoose.createConnection(dbUrl, { "autoIndex": true });
16
+ // var conn = mongoose.connect(dbUrl, { "useNewUrlParser": true, "autoIndex": true });
17
+
18
+ // db.getCollection('reqlogs').aggregate([ {$group:{_id:{id_project:"$id_project"}, "count":{$sum:1}}},{$sort:{"count":-1}}])
19
+ // db.getCollection('projects').find({"_id":ObjectId("5afeaf94404bff0014098f54")})
20
+
21
+ var RouterLoggerSchema = new Schema({
22
+ url: {
23
+ type: String,
24
+ index: true
25
+ },
26
+ fullurl: {
27
+ type: String,
28
+ index: true
29
+ },
30
+
31
+ // ip: {
32
+ // type: String,
33
+ // index: true
34
+ // },
35
+ // host: {
36
+ // type: String,
37
+ // index: true
38
+ // },
39
+ origin: {
40
+ type: String,
41
+ index: true
42
+ },
43
+ id_project: {
44
+ type: String,
45
+ index: true
46
+ //required: true
47
+ }
48
+ }, {
49
+ timestamps: true
50
+ }
51
+ );
52
+
53
+ var routerLogger = conn.model('router_logger', RouterLoggerSchema);
54
+
55
+
56
+
57
+ module.exports = routerLogger;
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.2.16",
4
+ "version": "2.2.20",
5
5
  "scripts": {
6
6
  "start": "node ./bin/www",
7
7
  "pretest": "mongodb-runner start",
@@ -41,8 +41,8 @@ router.post('/', [
41
41
  eventService.emit(req.body.name, req.body.attributes, req.projectid, pu, req.user.id, undefined, req.user).then(function(event) {
42
42
  res.json(event);
43
43
  }).catch(function(err) {
44
- winston.error('Error saving the event '+ JSON.stringify(savedEvent), err)
45
- return res.status(500).send({success: false, msg: 'Error saving the event '+ JSON.stringify(savedEvent)});
44
+ winston.error('Error saving the event '+ JSON.stringify(event), err)
45
+ return res.status(500).send({success: false, msg: 'Error saving the event '+ JSON.stringify(event)});
46
46
  });
47
47
 
48
48
  // var newEvent = new Event({
@@ -11,27 +11,29 @@ var winston = require('../config/winston');
11
11
  //winston.debug(req.params);
12
12
  //winston.debug("req.projectid", req.projectid);
13
13
 
14
- AnalyticResult.aggregate([
15
- //last 4
16
- { $match: {"id_project":req.projectid, "createdAt" : { $gte : new Date((new Date().getTime() - (4 * 60 * 60 * 1000))) }} },
17
- { "$group": {
18
- "_id": "$id_project",
19
- "waiting_time_avg":{"$avg": "$waiting_time"}
20
- }
21
- },
14
+ res.json([]);
15
+
16
+ // AnalyticResult.aggregate([
17
+ // //last 4
18
+ // { $match: {"id_project":req.projectid, "createdAt" : { $gte : new Date((new Date().getTime() - (4 * 60 * 60 * 1000))) }} },
19
+ // { "$group": {
20
+ // "_id": "$id_project",
21
+ // "waiting_time_avg":{"$avg": "$waiting_time"}
22
+ // }
23
+ // },
22
24
 
23
- ])
24
- // .cache(cacheUtil.longTTL, req.projectid+":analytics:query:waiting:avg:4hours")
25
- .exec(function(err, result) {
26
-
27
- if (err) {
28
- winston.debug(err);
29
- return res.status(500).send({success: false, msg: 'Error getting analytics.'});
30
- }
31
- //winston.debug(result);
32
-
33
- res.json(result);
34
- });
25
+ // ])
26
+ // // .cache(cacheUtil.longTTL, req.projectid+":analytics:query:waiting:avg:4hours")
27
+ // .exec(function(err, result) {
28
+
29
+ // if (err) {
30
+ // winston.debug(err);
31
+ // return res.status(500).send({success: false, msg: 'Error getting analytics.'});
32
+ // }
33
+ // //winston.debug(result);
34
+
35
+ // res.json(result);
36
+ // });
35
37
 
36
38
  });
37
39
 
package/routes/widget.js CHANGED
@@ -123,7 +123,7 @@ router.get('/', function(req, res, next) {
123
123
  ,
124
124
  getDepartments(req)
125
125
  ,
126
- waiting()
126
+ // waiting()unused used 620e87f02e7fda00350ea5a5/publicanalytics/waiting/current
127
127
  ,
128
128
  getIp()
129
129
 
@@ -368,7 +368,8 @@ class FaqBotSupport {
368
368
  // found = true;
369
369
  // return resolve(bot_answer);
370
370
 
371
- if (message.channel.name == "chat21") { //why this contition on chat21 channel? bacause only chat21 support parsed replies?
371
+ // problem with
372
+ // if (message.channel.name == "chat21") { //why this contition on chat21 channel? bacause only chat21 support parsed replies?
372
373
  winston.debug("faqBotSupport message.channel.name is chat21",message);
373
374
  that.getParsedMessage(bot_answer.text,message, bot, faqs[0]).then(function(bot_answerres) {
374
375
 
@@ -377,10 +378,10 @@ class FaqBotSupport {
377
378
  return resolve(bot_answerres);
378
379
  });
379
380
 
380
- } else {
381
- winston.debug("faqBotSupport message.channel.name is not chat21 returning default",message);
382
- return resolve(bot_answer);
383
- }
381
+ // } else {
382
+ // winston.debug("faqBotSupport message.channel.name is not chat21 returning default",message);
383
+ // return resolve(bot_answer);
384
+ // }
384
385
 
385
386
  } else {
386
387
  var message_key = "DEFAULT_NOTFOUND_NOBOT_SENTENCE_REPLY_MESSAGE";