@tiledesk/tiledesk-server 2.2.17 → 2.2.18

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,32 +1,11 @@
1
- Trigger1:
2
- * se agenti disponibili
3
- * Azione: rispondi con messaggio “online”
4
- * Azione: invia in chat messaggio “Assegnata a $REQUEST_FIRST_PARTECIPANT” [SCATTA SU: ONAFTERSERVE()]
5
-
6
- * Trigger2:
7
- * agenti non disponibili
8
- * Azione: rispondi con messaggio “offline” (il messaggio offline comprende info sulla messa in coda e sul tempo medio di attesa) $AVG_WAIT_TIME
9
- * richiesta served() => in unassigned (in coda)
10
-
11
- * Trigger3:
12
- * orari chiusi
13
- * Azione: messaggio “orari chiusi”
14
- * Il chatbot rimane (più probabile perchè il chatbot di ingresso già gestisce le faq)
15
- * metti in coda con messaggio (“orari chiusi” oppure altro messaggio)
16
-
17
- senza chatbot
18
-
19
- ATTUALE: se online fai serve() con messaggio online
20
- ATTUALE: se offline fai serve() con messaggio offline
21
- ATTUALE: se orari chiusi fai serve() solo messaggio orari chiusi
22
- AGGIUNGERE (con documentazione): se orari chiusi invita un chatbot (visto che non c’è, ma serve solo negli orari di chiusura) con messaggio orari chiusi
23
-
1
+ # 2.2.18
2
+ - Router logger module enable with ROUTELOGGER_ENABLED=true
24
3
 
25
4
 
26
5
  # 2.2.17 -> PROD
27
- - removed default fallback limit on parse reply
6
+ - Removed default fallback limit on parse reply
28
7
 
29
- # 2.2.16 -> PROD
8
+ # 2.2.16
30
9
  - Email templates endpoint
31
10
  - Created request.updated event for request event and deprecated request.update.comment
32
11
  - Added Handlebars template processor for the message transformer module only if message.attributes.templateProcessor=true
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.17",
4
+ "version": "2.2.18",
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({
@@ -368,6 +368,7 @@ class FaqBotSupport {
368
368
  // found = true;
369
369
  // return resolve(bot_answer);
370
370
 
371
+ // problem with
371
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) {