@tiledesk/tiledesk-server 2.4.45 → 2.4.46
Sign up to get free protection for your applications and to get access to all the features.
- package/event/botEvent.js +6 -3
- package/package.json +1 -1
- package/routes/auth.js +3 -3
- package/routes/request.js +4 -2
- package/services/BotSubscriptionNotifier.js +29 -18
package/event/botEvent.js
CHANGED
@@ -65,13 +65,15 @@ class BotEvent extends EventEmitter {
|
|
65
65
|
}
|
66
66
|
|
67
67
|
// qui potresti leggere anche +secret ed evitare prossima query in botNotification
|
68
|
-
let qbot = Faq_kb.findById(botId); //TODO add cache_bot_here
|
68
|
+
// let qbot = Faq_kb.findById(botId); //TODO add cache_bot_here
|
69
|
+
let qbot = Faq_kb.findById(botId).select('+secret')
|
69
70
|
//TODO unselect secret. secret is unselectable by default in the model
|
70
71
|
|
71
72
|
if (cacheEnabler.faq_kb) {
|
72
73
|
winston.debug('message.id_project+":faq_kbs:id:"+botId: '+ message.id_project+":faq_kbs:id:"+botId);
|
73
|
-
|
74
|
-
|
74
|
+
// qbot.cache(cacheUtil.defaultTTL, message.id_project+":faq_kbs:id:"+botId)
|
75
|
+
qbot.cache(cacheUtil.defaultTTL, message.id_project+":faq_kbs:id:"+botId+":secret")
|
76
|
+
winston.debug('faq_kb cache enabled');
|
75
77
|
}
|
76
78
|
|
77
79
|
qbot.exec(function(err, bot) {
|
@@ -87,6 +89,7 @@ class BotEvent extends EventEmitter {
|
|
87
89
|
}
|
88
90
|
|
89
91
|
winston.debug("bot debug", bot);
|
92
|
+
winston.debug('bot debug secret: '+ bot.secret);
|
90
93
|
|
91
94
|
if (bot) {
|
92
95
|
if (bot.type==="internal") {
|
package/package.json
CHANGED
package/routes/auth.js
CHANGED
@@ -471,10 +471,10 @@ function (req, res) {
|
|
471
471
|
// Redirect the user to the Google signin page</em>
|
472
472
|
// router.get("/google", passport.authenticate("google", { scope: ["email", "profile"] }));
|
473
473
|
router.get("/google", function(req,res,next){
|
474
|
-
winston.
|
474
|
+
winston.debug("redirect_url: "+ req.query.redirect_url );
|
475
475
|
req.session.redirect_url = req.query.redirect_url;
|
476
476
|
|
477
|
-
winston.
|
477
|
+
winston.debug("forced_redirect_url: "+ req.query.forced_redirect_url );
|
478
478
|
req.session.forced_redirect_url = req.query.forced_redirect_url;
|
479
479
|
|
480
480
|
// req._toParam = 'Hello';
|
@@ -542,7 +542,7 @@ router.get("/google/callback", passport.authenticate("google", { session: false
|
|
542
542
|
url = req.session.forced_redirect_url+"?jwt=JWT "+token; //attention we use jwt= (ionic) instead token=(dashboard) for ionic
|
543
543
|
}
|
544
544
|
|
545
|
-
winston.
|
545
|
+
winston.debug("Google Redirect: "+ url);
|
546
546
|
|
547
547
|
res.redirect(url);
|
548
548
|
|
package/routes/request.js
CHANGED
@@ -459,7 +459,7 @@ router.put('/:requestid/agent', async (req, res) => {
|
|
459
459
|
winston.debug(req.body);
|
460
460
|
//route(request_id, departmentid, id_project) {
|
461
461
|
|
462
|
-
|
462
|
+
|
463
463
|
var request = await Request.findOne({"request_id":req.params.requestid, id_project:req.projectid})
|
464
464
|
.exec();
|
465
465
|
|
@@ -817,7 +817,7 @@ router.get('/', function (req, res, next) {
|
|
817
817
|
|
818
818
|
if (req.user instanceof Subscription) {
|
819
819
|
//all request
|
820
|
-
} else if (projectuser && projectuser.role == "owner" || projectuser.role == "admin") {
|
820
|
+
} else if (projectuser && (projectuser.role == "owner" || projectuser.role == "admin")) {
|
821
821
|
//all request
|
822
822
|
// per uni mostrare solo quelle priprio quindi solo participants
|
823
823
|
if (req.query.mine) {
|
@@ -1030,6 +1030,8 @@ router.get('/', function (req, res, next) {
|
|
1030
1030
|
}
|
1031
1031
|
|
1032
1032
|
|
1033
|
+
|
1034
|
+
|
1033
1035
|
var direction = -1; //-1 descending , 1 ascending
|
1034
1036
|
if (req.query.direction) {
|
1035
1037
|
direction = req.query.direction;
|
@@ -14,10 +14,13 @@ winston.debug("webhook_origin: "+webhook_origin);
|
|
14
14
|
var cacheUtil = require('../utils/cacheUtil');
|
15
15
|
var cacheEnabler = require("../services/cacheEnabler");
|
16
16
|
|
17
|
+
|
18
|
+
|
19
|
+
|
17
20
|
class BotSubscriptionNotifier {
|
18
21
|
|
19
22
|
|
20
|
-
notify(bot,
|
23
|
+
notify(bot,secret, payload) {
|
21
24
|
|
22
25
|
winston.debug("BotSubscriptionNotifier bot", bot.toObject());
|
23
26
|
winston.debug("BotSubscriptionNotifier payload", payload );
|
@@ -58,7 +61,7 @@ class BotSubscriptionNotifier {
|
|
58
61
|
delete botPayload.description;
|
59
62
|
delete botPayload.attributes;
|
60
63
|
|
61
|
-
var token = jwt.sign(botPayload,
|
64
|
+
var token = jwt.sign(botPayload, secret, signOptions);
|
62
65
|
json["token"] = token;
|
63
66
|
|
64
67
|
|
@@ -93,25 +96,33 @@ class BotSubscriptionNotifier {
|
|
93
96
|
//modify to async
|
94
97
|
botEvent.on('bot.message.received.notify.external', function(botNotification) {
|
95
98
|
var bot = botNotification.bot;
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
99
|
+
var secret = bot.secret;
|
100
|
+
winston.debug('bot.message.received.notify.external: '+secret);
|
101
|
+
|
102
|
+
// winston.debug('getting botWithSecret');
|
103
|
+
// let qbot = Faq_kb.findById(bot._id).select('+secret')
|
104
|
+
|
105
|
+
// if (cacheEnabler.faq_kb) {
|
106
|
+
// let id_project = bot.id_project;
|
107
|
+
// winston.debug("id_project.id_project:"+id_project);
|
108
|
+
// qbot.cache(cacheUtil.defaultTTL, id_project+":faq_kbs:id:"+bot._id+":secret")
|
109
|
+
// winston.debug('faq_kb BotSubscriptionNotifier cache enabled');
|
110
|
+
// }
|
111
|
+
|
112
|
+
// qbot.exec(function (err, botWithSecret){ //TODO add cache_bot_here????
|
113
|
+
// if (err) {
|
114
|
+
// winston.debug('Error getting botWithSecret', err);
|
115
|
+
// }
|
116
|
+
// botSubscriptionNotifier.notify(bot, botWithSecret, botNotification.message);
|
117
|
+
// });
|
112
118
|
|
119
|
+
botSubscriptionNotifier.notify(bot, secret, botNotification.message);
|
120
|
+
|
121
|
+
|
113
122
|
});
|
114
123
|
|
124
|
+
|
125
|
+
|
115
126
|
winston.info('BotSubscriptionNotifier started');
|
116
127
|
|
117
128
|
}
|