@tiledesk/tiledesk-server 2.4.86 → 2.4.88

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.4.88
9
+ - Added chatbot templates and community in pubmodules
10
+
11
+ # 2.4.87
12
+ - Updated tybot-connector to 0.2.43
13
+ - Updated whatsapp-connector to 0.1.59
14
+
8
15
  # 2.4.86
9
16
  - Updated tybot-connector to 0.2.41
10
17
 
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.4.86",
4
+ "version": "2.4.88",
5
5
  "scripts": {
6
6
  "start": "node ./bin/www",
7
7
  "pretest": "mongodb-runner start",
@@ -45,9 +45,10 @@
45
45
  "@tiledesk/tiledesk-messenger-connector": "^0.1.13",
46
46
  "@tiledesk/tiledesk-rasa-connector": "^1.0.10",
47
47
  "@tiledesk/tiledesk-telegram-connector": "^0.1.10",
48
- "@tiledesk/tiledesk-tybot-connector": "^0.2.41",
49
- "@tiledesk/tiledesk-whatsapp-connector": "^0.1.58",
48
+ "@tiledesk/tiledesk-tybot-connector": "^0.2.43",
49
+ "@tiledesk/tiledesk-whatsapp-connector": "^0.1.59",
50
50
  "@tiledesk/tiledesk-whatsapp-jobworker": "^0.0.7",
51
+ "@tiledesk/tiledesk-chatbot-templates": "^0.1.0",
51
52
  "amqplib": "^0.5.5",
52
53
  "app-root-path": "^3.0.0",
53
54
  "bcrypt-nodejs": "0.0.3",
@@ -0,0 +1,7 @@
1
+ const listener = require("./listener");
2
+
3
+ const templates = require("@tiledesk/tiledesk-chatbot-templates");
4
+ const templatesRoute = templates.router;
5
+
6
+
7
+ module.exports = { listener: listener, templatesRoute: templatesRoute }
@@ -0,0 +1,29 @@
1
+ const templates = require("@tiledesk/tiledesk-chatbot-templates");
2
+ const winston = require("../../config/winston");
3
+ var configGlobal = require('../../config/global');
4
+
5
+ class Listener {
6
+
7
+ listen(config) {
8
+
9
+ winston.info("Chatbot Templates Listener listen");
10
+ if (config.databaseUri) {
11
+ winston.debug("chatbot templates config databaseUri: " + config.databaseUri);
12
+ }
13
+
14
+ templates.startApp({
15
+ MONGODB_URL: config.databaseUri,
16
+ CHATBOT_TEMPLATES_LOG: 1
17
+ }, (err) => {
18
+ if (!err) {
19
+ winston.info("Chatbot Templates proxy server successfully started.");
20
+ } else {
21
+ winston.info("unable to start Tiledesk Chatbot Templates." + err);
22
+ }
23
+ })
24
+ }
25
+ }
26
+
27
+ var listener = new Listener();
28
+
29
+ module.exports = listener;
@@ -33,6 +33,9 @@ class PubModulesManager {
33
33
  this.telegram = undefined;
34
34
  this.telegramRoute = undefined;
35
35
 
36
+ this.templates = undefined;
37
+ this.templatesRoute = undefined;
38
+
36
39
  this.kaleyra = undefined;
37
40
  this.kaleyraRoute = undefined;
38
41
 
@@ -85,6 +88,10 @@ class PubModulesManager {
85
88
  app.use('/modules/telegram', this.telegramRoute);
86
89
  winston.info("PubModulesManager telegramRoute controller loaded");
87
90
  }
91
+ if (this.templatesRoute) {
92
+ app.use('/modules/templates', this.templatesRoute);
93
+ winston.info("PubModulesManager templatesRoute controller loaded");
94
+ }
88
95
  if (this.kaleyraRoute) {
89
96
  app.use('/modules/kaleyra', this.kaleyraRoute);
90
97
  winston.info("PubModulesManager kaleyraRoute controller loaded");
@@ -316,6 +323,22 @@ class PubModulesManager {
316
323
  winston.info("PubModulesManager error initializing init apps module", err);
317
324
  }
318
325
  }
326
+
327
+ try {
328
+ this.templates = require('./chatbotTemplates');
329
+ winston.info("this.templates: " + this.templates);
330
+ this.templates.listener.listen(config);
331
+
332
+ this.templatesRoute = this.templates.templatesRoute;
333
+
334
+ winston.info("PubModulesManager initialized apps (templates).")
335
+ } catch(err) {
336
+ if (err.code == 'MODULE_NOT_FOUND') {
337
+ winston.info("PubModulesManager init apps module not found ");
338
+ } else {
339
+ winston.info("PubModulesManager error initializing init apps module", err);
340
+ }
341
+ }
319
342
 
320
343
  try {
321
344
  this.kaleyra = require('./kaleyra');
package/routes/auth.js CHANGED
@@ -382,7 +382,29 @@ router.post('/signinWithCustomToken', [
382
382
 
383
383
  if (req.user.role && (req.user.role === RoleConstants.OWNER || req.user.role === RoleConstants.ADMIN || req.user.role === RoleConstants.AGENT)) {
384
384
  let userFromDB = await User.findOne({email: req.user.email , status: 100}).exec();
385
- return res.json({ success: true, token: req.headers["authorization"], user: userFromDB });
385
+
386
+ var signOptions = {
387
+ issuer: 'https://tiledesk.com',
388
+ subject: 'user',
389
+ audience: 'https://tiledesk.com',
390
+ jwtid: uuidv4()
391
+ };
392
+
393
+ var alg = process.env.GLOBAL_SECRET_ALGORITHM;
394
+ if (alg) {
395
+ signOptions.algorithm = alg;
396
+ }
397
+
398
+ //remove password //test it
399
+ let userJson = userFromDB.toObject();
400
+ delete userJson.password;
401
+
402
+ let returnToken = jwt.sign(userJson, configSecret, signOptions); //priv_jwt pp_jwt
403
+
404
+
405
+ return res.json({ success: true, token: "JWT " + returnToken, user: userFromDB });
406
+ // return res.json({ success: true, token: req.headers["authorization"], user: userFromDB });
407
+
386
408
 
387
409
  } else {
388
410
  return res.json({ success: true, token: req.headers["authorization"], user: userToReturn });