@tiledesk/tiledesk-server 2.3.72 → 2.3.74
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +24 -0
- package/event/botEvent.js +13 -1
- package/middleware/passport.js +39 -11
- package/models/faq_kb.js +5 -0
- package/models/presence.js +1 -1
- package/models/project.js +3 -0
- package/models/user.js +1 -0
- package/package.json +2 -2
- package/pubmodules/activities/models/activity.js +2 -0
- package/pubmodules/cache/mongoose-cachegoose-fn.js +171 -43
- package/pubmodules/emailNotification/requestNotification.js +15 -5
- package/pubmodules/pubModulesManager.js +6 -6
- package/routes/auth.js +24 -8
- package/routes/faq.js +6 -1
- package/routes/faq_kb.js +50 -1
- package/routes/message.js +7 -4
- package/routes/project.js +49 -1
- package/routes/widget.js +95 -13
- package/services/BotSubscriptionNotifier.js +17 -1
- package/services/cacheEnabler.js +5 -0
- package/services/departmentService.js +1 -1
- package/services/faqBotHandler.js +1 -1
- package/services/faqBotSupport.js +1 -1
- package/services/operatingHoursService.js +1 -1
- package/services/subscriptionNotifier.js +8 -2
- package/template/email/emailDirect.html +2 -0
- package/template/email/newMessage.html +1 -1
- package/test/messageRoute.js +1 -1
- package/utils/sendMessageUtil.js +2 -2
- package/websocket/webSocketServer.js +4 -4
package/CHANGELOG.md
CHANGED
@@ -5,6 +5,30 @@
|
|
5
5
|
🚀 IN PRODUCTION 🚀
|
6
6
|
(https://www.npmjs.com/package/@tiledesk/tiledesk-server/v/2.3.71)
|
7
7
|
|
8
|
+
# 2.3.73
|
9
|
+
- Removed unused mongoose-auto-increment dependency
|
10
|
+
- Removed version versions files
|
11
|
+
- Added attributes field to the project model and relative patch endpoint
|
12
|
+
- Message text validation only for the first message
|
13
|
+
- Updated tiledesk/tiledesk-tybot-connector@0.1.46
|
14
|
+
- Added an endpoint to patch the bot attributes
|
15
|
+
- Added Faq_kbSchema index({certified: 1, public: 1});
|
16
|
+
- Added ActivitySchema index({id_project: 1, createdAt: -1});
|
17
|
+
- Changed from .remove to findByIdAndRemove for faq remove endpoint to fix event emitter payload
|
18
|
+
- Updated tiledesk/tiledesk-tybot-connector@0.1.47
|
19
|
+
- Added caching for /widgets endpoint with invalidations
|
20
|
+
- Added bot rules to /widgets endpoint
|
21
|
+
- Select false for resetpswrequestid field of user model
|
22
|
+
- Added support for Public Private Key for JWT Auth with GLOBAL_SECRET_OR_PRIVATE_KEY and GLOBAL_SECRET_OR_PUB_KEY and GLOBAL_SECRET_ALGORITHM environments variables. If these properties are configured Public Private Key method is enabled otherwise if GLOBAL_SECRET env varible is configured the shared secret method is used. algorithm (default: HS256)
|
23
|
+
- Updated tiledesk/tiledesk-tybot-connector@0.1.48
|
24
|
+
- Removed “snapshot” from request payload for external chatbot
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
# 2.3.72
|
29
|
+
- Added Kaleyra module
|
30
|
+
- Updated tiledesk-apps to 1.0.12
|
31
|
+
|
8
32
|
# 2.3.71
|
9
33
|
- Email service send email direct fit without request_id
|
10
34
|
- Removed strong from transcript email template
|
package/event/botEvent.js
CHANGED
@@ -4,6 +4,8 @@ const Faq_kb = require('../models/faq_kb');
|
|
4
4
|
var winston = require('../config/winston');
|
5
5
|
|
6
6
|
class BotEvent extends EventEmitter {}
|
7
|
+
const cacheUtil = require("../utils/cacheUtil");
|
8
|
+
const cacheEnabler = require("../services/cacheEnabler");
|
7
9
|
|
8
10
|
const botEvent = new BotEvent();
|
9
11
|
|
@@ -108,7 +110,17 @@ messageEvent.on('message.create', function(message) {
|
|
108
110
|
}
|
109
111
|
|
110
112
|
|
111
|
-
Faq_kb.findById(botId)
|
113
|
+
let qbot = Faq_kb.findById(botId); //TODO add cache_bot_here
|
114
|
+
|
115
|
+
if (cacheEnabler.faq_kb) {
|
116
|
+
qbot.cache(cacheUtil.defaultTTL, message.id_project+":faq_kbs:id:"+botId)
|
117
|
+
winston.debug('faq_kb cache enabled');
|
118
|
+
}
|
119
|
+
|
120
|
+
qbot.exec(function(err, bot) {
|
121
|
+
|
122
|
+
|
123
|
+
|
112
124
|
if (err) {
|
113
125
|
winston.error('Error getting object.', err);
|
114
126
|
return 0;
|
package/middleware/passport.js
CHANGED
@@ -18,7 +18,7 @@ var UserUtil = require('../utils/userUtil');
|
|
18
18
|
var jwt = require('jsonwebtoken');
|
19
19
|
const url = require('url');
|
20
20
|
var cacheUtil = require('../utils/cacheUtil');
|
21
|
-
|
21
|
+
var cacheEnabler = require("../services/cacheEnabler");
|
22
22
|
|
23
23
|
const MaskData = require("maskdata");
|
24
24
|
|
@@ -34,7 +34,8 @@ const maskOptions = {
|
|
34
34
|
};
|
35
35
|
|
36
36
|
|
37
|
-
var configSecret = process.env.GLOBAL_SECRET || config.secret;
|
37
|
+
var configSecret = process.env.GLOBAL_SECRET_OR_PUB_KEY || process.env.GLOBAL_SECRET || config.secret;
|
38
|
+
|
38
39
|
|
39
40
|
var maskedconfigSecret = MaskData.maskPhone(configSecret, maskOptions);
|
40
41
|
winston.info('Authentication Global Secret : ' + maskedconfigSecret);
|
@@ -113,8 +114,18 @@ module.exports = function(passport) {
|
|
113
114
|
return done(null, null);
|
114
115
|
}
|
115
116
|
|
116
|
-
winston.debug("bot id: "+ AudienceId );
|
117
|
-
Faq_kb.findById(AudienceId).select('+secret')
|
117
|
+
winston.debug("bot id AudienceId: "+ AudienceId );
|
118
|
+
let qbot = Faq_kb.findById(AudienceId).select('+secret');
|
119
|
+
|
120
|
+
if (cacheEnabler.faq_kb) {
|
121
|
+
let id_project = decoded.id_project;
|
122
|
+
winston.debug("decoded.id_project:"+decoded.id_project);
|
123
|
+
qbot.cache(cacheUtil.defaultTTL, id_project+":faq_kbs:id:"+AudienceId+":secret")
|
124
|
+
winston.debug('faq_kb AudienceId cache enabled');
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
qbot.exec(function (err, faq_kb){ //TODO add cache_bot_here
|
118
129
|
if (err) {
|
119
130
|
winston.error("auth Faq_kb err: ", {error: err, decoded:decoded} );
|
120
131
|
return done(null, null);
|
@@ -179,17 +190,17 @@ module.exports = function(passport) {
|
|
179
190
|
|
180
191
|
else if (decoded.aud == "https://tiledesk.com") {
|
181
192
|
winston.debug("configSecret: "+ maskedconfigSecret );
|
182
|
-
done(null, configSecret);
|
193
|
+
done(null, configSecret); //pub_jwt pp_jwt
|
183
194
|
}
|
184
195
|
|
185
196
|
else {
|
186
197
|
winston.debug("configSecret: "+ maskedconfigSecret );
|
187
|
-
done(null, configSecret);
|
198
|
+
done(null, configSecret); //pub_jwt pp_jwt
|
188
199
|
}
|
189
200
|
}
|
190
201
|
else {
|
191
202
|
winston.debug("configSecret: "+ maskedconfigSecret );
|
192
|
-
done(null, configSecret);
|
203
|
+
done(null, configSecret); //pub_jwt pp_jwt
|
193
204
|
}
|
194
205
|
}
|
195
206
|
}
|
@@ -246,7 +257,18 @@ module.exports = function(passport) {
|
|
246
257
|
|
247
258
|
if (subject == "bot") {
|
248
259
|
winston.debug("Passport JWT bot");
|
249
|
-
|
260
|
+
|
261
|
+
let qbot = Faq_kb.findOne({_id: identifier}); //TODO add cache_bot_here
|
262
|
+
|
263
|
+
if (cacheEnabler.faq_kb) {
|
264
|
+
let id_project = jwt_payload.id_project;
|
265
|
+
winston.debug("jwt_payload.id_project:"+jwt_payload.id_project);
|
266
|
+
qbot.cache(cacheUtil.defaultTTL, id_project+":faq_kbs:id:"+identifier)
|
267
|
+
winston.debug('faq_kb cache enabled');
|
268
|
+
}
|
269
|
+
|
270
|
+
qbot.exec(function(err, faq_kb) {
|
271
|
+
|
250
272
|
if (err) {
|
251
273
|
winston.error("Passport JWT bot err", err);
|
252
274
|
return done(err, false);
|
@@ -325,9 +347,15 @@ module.exports = function(passport) {
|
|
325
347
|
|
326
348
|
} else {
|
327
349
|
winston.debug("Passport JWT generic user");
|
328
|
-
User.findOne({_id: identifier, status: 100})
|
350
|
+
let quser = User.findOne({_id: identifier, status: 100}) //TODO user_cache_here
|
329
351
|
//@DISABLED_CACHE .cache(cacheUtil.defaultTTL, "users:id:"+identifier)
|
330
|
-
|
352
|
+
|
353
|
+
if (cacheEnabler.user) {
|
354
|
+
quser.cache(cacheUtil.defaultTTL, "users:id:"+identifier)
|
355
|
+
winston.debug('user cache enabled');
|
356
|
+
}
|
357
|
+
|
358
|
+
quser.exec(function(err, user) {
|
331
359
|
if (err) {
|
332
360
|
winston.error("Passport JWT generic err ", err);
|
333
361
|
return done(err, false);
|
@@ -357,7 +385,7 @@ module.exports = function(passport) {
|
|
357
385
|
var email = userid.toLowerCase();
|
358
386
|
winston.debug("email lowercase: " + email);
|
359
387
|
|
360
|
-
User.findOne({ email: email, status: 100}, 'email firstname lastname password emailverified id')
|
388
|
+
User.findOne({ email: email, status: 100}, 'email firstname lastname password emailverified id') //TODO user_cache_here. NOT used frequently. ma attento select. ATTENTO QUI NN USEREI LA SELECT altrimenti con JWT ho tuttto USER mentre con basich auth solo aluni campi
|
361
389
|
//@DISABLED_CACHE .cache(cacheUtil.defaultTTL, "users:email:"+email)
|
362
390
|
.exec(function (err, user) {
|
363
391
|
|
package/models/faq_kb.js
CHANGED
@@ -95,6 +95,11 @@ Faq_kbSchema.virtual('fullName').get(function () {
|
|
95
95
|
return (this.name);
|
96
96
|
});
|
97
97
|
|
98
|
+
Faq_kbSchema.index({certified: 1, public: 1}); //suggested by atlas
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
98
103
|
var faq_kb = mongoose.model('faq_kb', Faq_kbSchema);
|
99
104
|
|
100
105
|
if (process.env.MONGOOSE_SYNCINDEX) {
|
package/models/presence.js
CHANGED
package/models/project.js
CHANGED
@@ -68,6 +68,9 @@ var ProjectSchema = new Schema({
|
|
68
68
|
type: String,
|
69
69
|
select: false
|
70
70
|
},
|
71
|
+
attributes: {
|
72
|
+
type: Object,
|
73
|
+
},
|
71
74
|
// apiKey: { //You do want to block anonymous traffic. https://cloud.google.com/endpoints/docs/openapi/when-why-api-key#:~:text=API%20keys%20identify%20an%20application's,patterns%20in%20your%20API's%20traffic
|
72
75
|
// type: String,
|
73
76
|
// select: false,
|
package/models/user.js
CHANGED
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.
|
4
|
+
"version": "2.3.74",
|
5
5
|
"scripts": {
|
6
6
|
"start": "node ./bin/www",
|
7
7
|
"pretest": "mongodb-runner start",
|
@@ -43,7 +43,7 @@
|
|
43
43
|
"@tiledesk/tiledesk-chatbot-util": "^0.8.33",
|
44
44
|
"@tiledesk/tiledesk-json-rules-engine": "^4.0.3",
|
45
45
|
"@tiledesk/tiledesk-rasa-connector": "^1.0.10",
|
46
|
-
"@tiledesk/tiledesk-tybot-connector": "^0.1.
|
46
|
+
"@tiledesk/tiledesk-tybot-connector": "^0.1.50",
|
47
47
|
"@tiledesk/tiledesk-dialogflow-connector": "^1.8.3",
|
48
48
|
"app-root-path": "^3.0.0",
|
49
49
|
"bcrypt-nodejs": "0.0.3",
|
@@ -2,6 +2,7 @@
|
|
2
2
|
var messageEvent = require("../../event/messageEvent");
|
3
3
|
var projectEvent = require("../../event/projectEvent");
|
4
4
|
var botEvent = require("../../event/botEvent");
|
5
|
+
const faqBotEvent = require('../../event/faqBotEvent');
|
5
6
|
var departmentEvent = require("../../event/departmentEvent");
|
6
7
|
var authEvent = require("../../event/authEvent");
|
7
8
|
var labelEvent = require("../../event/labelEvent");
|
@@ -14,6 +15,7 @@
|
|
14
15
|
var cachegoose = require('cachegoose');
|
15
16
|
|
16
17
|
var cacheUtil = require('../../utils/cacheUtil');
|
18
|
+
var RoleConstants = require("../../models/roleConstants");
|
17
19
|
|
18
20
|
|
19
21
|
|
@@ -28,6 +30,7 @@
|
|
28
30
|
winston.debug("Created cache for project.create reply",reply);
|
29
31
|
});
|
30
32
|
|
33
|
+
// TODO COMMENTA NON USATO
|
31
34
|
key = "projects:query:*";
|
32
35
|
winston.verbose("Deleting cache for project.create with key: " + key);
|
33
36
|
client.del(key, function (err, reply) {
|
@@ -48,12 +51,17 @@
|
|
48
51
|
|
49
52
|
});
|
50
53
|
|
54
|
+
// TODO COMMENTA NON USATO
|
51
55
|
key = "projects:query:*";
|
52
|
-
winston.verbose("Deleting cache for project.
|
56
|
+
winston.verbose("Deleting cache for project.update with key: " + key);
|
53
57
|
client.del(key, function (err, reply) {
|
54
|
-
winston.debug("Deleted cache for project.
|
55
|
-
winston.verbose("Deleted cache for project.
|
58
|
+
winston.debug("Deleted cache for project.update",reply);
|
59
|
+
winston.verbose("Deleted cache for project.update",{err:err});
|
56
60
|
});
|
61
|
+
|
62
|
+
// TODO invalidate widgets here
|
63
|
+
winston.verbose("Deleting widgets cache for project.update");
|
64
|
+
invalidateWidgets(client, project.id); //tested
|
57
65
|
});
|
58
66
|
|
59
67
|
});
|
@@ -67,6 +75,7 @@
|
|
67
75
|
winston.verbose("Deleted cache for project.delete",{err:err});
|
68
76
|
});
|
69
77
|
|
78
|
+
// TODO COMMENTA NON USATO
|
70
79
|
key = "projects:query:*";
|
71
80
|
winston.verbose("Deleting cache for project.create with key: " + key);
|
72
81
|
client.del(key, function (err, reply) {
|
@@ -74,6 +83,10 @@
|
|
74
83
|
winston.verbose("Deleted cache for project.create",{err:err});
|
75
84
|
});
|
76
85
|
});
|
86
|
+
|
87
|
+
// TODO invalidate widgets here
|
88
|
+
winston.verbose("Deleting widgets cache for project.delete");
|
89
|
+
invalidateWidgets(client, project.id);
|
77
90
|
});
|
78
91
|
|
79
92
|
projectEvent.on("project.downgrade", function(project) {
|
@@ -86,12 +99,17 @@
|
|
86
99
|
winston.verbose("Updated cache for project.downgrade",{err:err});
|
87
100
|
});
|
88
101
|
|
102
|
+
// TODO COMMENTA NON USATO
|
89
103
|
key = "projects:query:*";
|
90
|
-
winston.verbose("Deleting cache for project.
|
104
|
+
winston.verbose("Deleting cache for project.downgrade with key: " + key);
|
91
105
|
client.del(key, function (err, reply) {
|
92
|
-
winston.debug("Deleted cache for project.
|
93
|
-
winston.verbose("Deleted cache for project.
|
94
|
-
});
|
106
|
+
winston.debug("Deleted cache for project.downgrade",reply);
|
107
|
+
winston.verbose("Deleted cache for project.downgrade",{err:err});
|
108
|
+
});
|
109
|
+
|
110
|
+
// TODO invalidate widgets here
|
111
|
+
winston.verbose("Deleting widgets cache for project.downgrade");
|
112
|
+
invalidateWidgets(client, project.id);
|
95
113
|
});
|
96
114
|
});
|
97
115
|
|
@@ -153,6 +171,18 @@
|
|
153
171
|
winston.verbose("Updated cache for project_user.update",{err:err});
|
154
172
|
});
|
155
173
|
}
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
// TODO invalidate widgets headers
|
178
|
+
// only if role is agent, owner, admin ATTENTION
|
179
|
+
if (role == RoleConstants.OWNER || role == RoleConstants.ADMIN || role == RoleConstants.SUPERVISOR || role == RoleConstants.AGENT) {
|
180
|
+
winston.verbose("Deleting widgets cache for project_user.update");
|
181
|
+
invalidateWidgets(client, project_user.id_project); //tested
|
182
|
+
}else {
|
183
|
+
winston.verbose("NOT invalidating widget cache for non admins project_user role");//tested
|
184
|
+
}
|
185
|
+
|
156
186
|
});
|
157
187
|
});
|
158
188
|
|
@@ -171,12 +201,13 @@
|
|
171
201
|
winston.verbose("Created cache for user.signup",{err:err});
|
172
202
|
});
|
173
203
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
});
|
204
|
+
// NOT IN USE (TESTED)
|
205
|
+
// var key = "users:email:"+user.email;
|
206
|
+
// winston.verbose("Creating cache for user.signup with key: " + key);
|
207
|
+
// client.set(key, user, cacheUtil.defaultTTL, (err, reply) => {
|
208
|
+
// winston.debug("Created cache for user.signup",reply);
|
209
|
+
// winston.verbose("Created cache for user.signup",{err:err});
|
210
|
+
// });
|
180
211
|
});
|
181
212
|
});
|
182
213
|
|
@@ -192,12 +223,13 @@
|
|
192
223
|
winston.verbose("Updated cache for user.update",{err:err});
|
193
224
|
});
|
194
225
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
});
|
226
|
+
// NOT IN USE (TESTED)
|
227
|
+
// var key = "users:email:"+user.email;
|
228
|
+
// winston.verbose("Updating cache for user.update with key: " + key);
|
229
|
+
// client.set(key, user, cacheUtil.defaultTTL, (err, reply) => {
|
230
|
+
// winston.debug("Updated cache for user.update",reply);
|
231
|
+
// winston.verbose("Updated cache for user.update",{err:err});
|
232
|
+
// });
|
201
233
|
});
|
202
234
|
});
|
203
235
|
|
@@ -212,12 +244,13 @@
|
|
212
244
|
winston.verbose("Deleted cache for user.delete",{err:err});
|
213
245
|
});
|
214
246
|
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
});
|
247
|
+
// NOT IN USE (TESTED)
|
248
|
+
// var key = "users:email:"+user.email;
|
249
|
+
// winston.verbose("Deleting cache for user.delete with key: " + key);
|
250
|
+
// client.del(key, (err, reply) => {
|
251
|
+
// winston.debug("Deleted cache for user.delete",reply);
|
252
|
+
// winston.verbose("Deleted cache for user.delete",{err:err});
|
253
|
+
// });
|
221
254
|
});
|
222
255
|
});
|
223
256
|
|
@@ -235,8 +268,8 @@
|
|
235
268
|
});
|
236
269
|
|
237
270
|
|
238
|
-
var key = "requests:
|
239
|
-
winston.verbose("Creating cache for request.create.simple with key: " + key);
|
271
|
+
var key = "requests:request_id:"+request.request_id+":simple"; //without project for chat21 webhook
|
272
|
+
winston.verbose("Creating cache for request.create.simple without project with key : " + key);
|
240
273
|
|
241
274
|
client.set(key, request, cacheUtil.defaultTTL, (err, reply) => {
|
242
275
|
winston.debug("Created cache for request.create.simple",reply);
|
@@ -270,6 +303,7 @@
|
|
270
303
|
winston.verbose("Created cache for request.create",{err:err});
|
271
304
|
});
|
272
305
|
|
306
|
+
// TODO COMMENTA NON USATO
|
273
307
|
key = request.id_project+":requests:query:*";
|
274
308
|
winston.verbose("Deleting cache for request.create with key: " + key);
|
275
309
|
client.del(key, function (err, reply) {
|
@@ -297,11 +331,12 @@
|
|
297
331
|
winston.verbose("Created cache for request.update",{err:err});
|
298
332
|
});
|
299
333
|
|
334
|
+
// TODO COMMENTA NON USATO
|
300
335
|
key = request.id_project+":requests:query:*";
|
301
|
-
winston.verbose("Deleting cache for request.
|
336
|
+
winston.verbose("Deleting cache for request.update with key: " + key);
|
302
337
|
client.del(key, function (err, reply) {
|
303
|
-
winston.debug("Deleted cache for request.
|
304
|
-
winston.verbose("Deleted cache for request.
|
338
|
+
winston.debug("Deleted cache for request.update",reply);
|
339
|
+
winston.verbose("Deleted cache for request.update",{err:err});
|
305
340
|
});
|
306
341
|
});
|
307
342
|
});
|
@@ -323,11 +358,12 @@
|
|
323
358
|
winston.verbose("Created cache for request.close",{err:err});
|
324
359
|
});
|
325
360
|
|
361
|
+
// TODO COMMENTA NON USATO
|
326
362
|
key = request.id_project+":requests:query:*";
|
327
363
|
winston.verbose("Deleting cache for request.create with key: " + key);
|
328
364
|
client.del(key, function (err, reply) {
|
329
|
-
winston.debug("Deleted cache for request.
|
330
|
-
winston.verbose("Deleted cache for request.
|
365
|
+
winston.debug("Deleted cache for request.close",reply);
|
366
|
+
winston.verbose("Deleted cache for request.close",{err:err});
|
331
367
|
});
|
332
368
|
});
|
333
369
|
});
|
@@ -362,6 +398,10 @@
|
|
362
398
|
winston.debug("Created cache for faq_kb.create",reply);
|
363
399
|
winston.verbose("Created cache for faq_kb.create",{err:err});
|
364
400
|
});
|
401
|
+
|
402
|
+
// TODO invalidate widgets here
|
403
|
+
winston.verbose("Deleting widgets cache for faqbot.create");
|
404
|
+
invalidateWidgets(client, faq_kb.id_project); //tested
|
365
405
|
});
|
366
406
|
});
|
367
407
|
|
@@ -374,19 +414,69 @@
|
|
374
414
|
client.set(key, faq_kb, cacheUtil.defaultTTL, (err, reply) => {
|
375
415
|
winston.debug("Created cache for faq_kb.create",reply);
|
376
416
|
winston.verbose("Created cache for faq_kb.update",{err:err});
|
377
|
-
});
|
417
|
+
});
|
418
|
+
|
419
|
+
|
420
|
+
key = faq_kb.id_project+":faq_kbs:id:"+faq_kb._id+":secret";
|
421
|
+
winston.verbose("Deleting cache for faq_kb.update secret with key: " + key);
|
422
|
+
client.del(key, function (err, reply) { //tested
|
423
|
+
winston.debug("Deleted cache for faq_kb.update secret",reply);
|
424
|
+
winston.verbose("Deleted cache for faq_kb.update secret",{err:err});
|
425
|
+
});
|
426
|
+
|
427
|
+
// TODO invalidate widgets here
|
428
|
+
winston.verbose("Deleting widgets cache for faqbot.update");
|
429
|
+
invalidateWidgets(client, faq_kb.id_project); //TESTED
|
378
430
|
});
|
379
431
|
});
|
380
432
|
|
381
433
|
|
382
|
-
botEvent.on("faqbot.delete", function(faq_kb) {
|
434
|
+
botEvent.on("faqbot.delete", function(faq_kb) { //LOGIC deletion for chatbot is used
|
383
435
|
setImmediate(() => {
|
384
436
|
var key = faq_kb.id_project+":faq_kbs:id:"+faq_kb._id;
|
385
|
-
winston.verbose("
|
386
|
-
client.
|
387
|
-
winston.debug("
|
388
|
-
winston.verbose("
|
437
|
+
winston.verbose("Deleting cache for faqbot.delete with key: " + key);
|
438
|
+
client.del(key, (err, reply) => {
|
439
|
+
winston.debug("Deleted cache for faqbot.delete",reply);
|
440
|
+
winston.verbose("Deleted cache for faqbot.delete",{err:err});
|
389
441
|
});
|
442
|
+
|
443
|
+
|
444
|
+
key = faq_kb.id_project+":faq_kbs:id:"+faq_kb._id+":secret";
|
445
|
+
winston.verbose("Deleting cache for faq_kb.delete secret with key: " + key);
|
446
|
+
client.del(key, function (err, reply) {
|
447
|
+
winston.debug("Deleted cache for faq_kb.delete secret",reply);
|
448
|
+
winston.verbose("Deleted cache for faq_kb.delete secret",{err:err});
|
449
|
+
});
|
450
|
+
|
451
|
+
// TODO invalidate widgets here
|
452
|
+
winston.verbose("Deleting widgets cache for faqbot.delete");
|
453
|
+
invalidateWidgets(client, faq_kb.id_project); //tested
|
454
|
+
});
|
455
|
+
});
|
456
|
+
|
457
|
+
|
458
|
+
|
459
|
+
faqBotEvent.on("faq.create", function(faq) {
|
460
|
+
setImmediate(() => {
|
461
|
+
// TODO invalidate widgets here
|
462
|
+
winston.verbose("Deleting widgets cache for faq.create");
|
463
|
+
invalidateWidgets(client, faq.id_project); //tested
|
464
|
+
});
|
465
|
+
});
|
466
|
+
|
467
|
+
faqBotEvent.on("faq.update", function(faq) {
|
468
|
+
setImmediate(() => {
|
469
|
+
// TODO invalidate widgets here
|
470
|
+
winston.verbose("Deleting widgets cache for faq.update");
|
471
|
+
invalidateWidgets(client, faq.id_project);//tested
|
472
|
+
});
|
473
|
+
});
|
474
|
+
|
475
|
+
faqBotEvent.on("faq.delete", function(faq) {
|
476
|
+
setImmediate(() => {
|
477
|
+
// TODO invalidate widgets here
|
478
|
+
winston.verbose("Deleting widgets cache for faq.delete",faq);
|
479
|
+
invalidateWidgets(client, faq.id_project);//tested
|
390
480
|
});
|
391
481
|
});
|
392
482
|
|
@@ -400,12 +490,17 @@
|
|
400
490
|
winston.verbose("Created cache for department.create",{err:err});
|
401
491
|
});
|
402
492
|
|
493
|
+
// TODO COMMENTA NON USATO
|
403
494
|
key = department.id_project+":departments:query:*";
|
404
495
|
winston.verbose("Deleting cache for department.create with key: " + key);
|
405
496
|
client.del(key, function (err, reply) {
|
406
497
|
winston.debug("Deleted cache for department.create",reply);
|
407
498
|
winston.verbose("Deleted cache for department.create",{err:err});
|
408
499
|
});
|
500
|
+
|
501
|
+
// TODO invalidate widgets here
|
502
|
+
winston.verbose("Deleting widgets cache for department.create");
|
503
|
+
invalidateWidgets(client, department.id_project);
|
409
504
|
});
|
410
505
|
});
|
411
506
|
|
@@ -420,12 +515,17 @@
|
|
420
515
|
winston.verbose("Created cache for department.update",{err:err});
|
421
516
|
});
|
422
517
|
|
518
|
+
// TODO COMMENTA NON USATO
|
423
519
|
key = department.id_project+":departments:query:*";
|
424
520
|
winston.verbose("Deleting cache for department.update with key: " + key);
|
425
521
|
client.del(key, function (err, reply) {
|
426
522
|
winston.debug("Deleted cache for department.update",reply);
|
427
523
|
winston.verbose("Deleted cache for department.update",{err:err});
|
428
524
|
});
|
525
|
+
|
526
|
+
// TODO invalidate widgets here
|
527
|
+
winston.verbose("Deleting widgets cache for department.update");
|
528
|
+
invalidateWidgets(client, department.id_project); //tested
|
429
529
|
});
|
430
530
|
});
|
431
531
|
|
@@ -433,24 +533,31 @@
|
|
433
533
|
departmentEvent.on("department.delete", function(department) {
|
434
534
|
setImmediate(() => {
|
435
535
|
var key = department.id_project+":departments:id:"+department._id;
|
436
|
-
winston.verbose("
|
437
|
-
client.
|
438
|
-
winston.debug("
|
439
|
-
winston.verbose("
|
536
|
+
winston.verbose("Deleting cache for department.delete with key: " + key);
|
537
|
+
client.del(key, (err, reply) => {
|
538
|
+
winston.debug("Deleted cache for department.delete",reply);
|
539
|
+
winston.verbose("Deleted cache for department.delete",{err:err});
|
440
540
|
});
|
441
541
|
|
542
|
+
// TODO COMMENTA NON USATO
|
442
543
|
key = department.id_project+":departments:query:*";
|
443
544
|
winston.verbose("Deleting cache for department.delete with key: " + key);
|
444
545
|
client.del(key, function (err, reply) {
|
445
546
|
winston.debug("Deleted cache for department.delete",reply);
|
446
547
|
winston.verbose("Deleted cache for department.delete",{err:err});
|
447
548
|
});
|
549
|
+
|
550
|
+
// TODO invalidate widgets here
|
551
|
+
winston.verbose("Deleting widgets cache for department.delete");
|
552
|
+
invalidateWidgets(client, department.id_project);
|
448
553
|
});
|
449
554
|
});
|
450
555
|
|
451
556
|
|
452
557
|
labelEvent.on("label.create", function(label) {
|
453
558
|
setImmediate(() => {
|
559
|
+
|
560
|
+
// TODO COMMENTA NON USATO
|
454
561
|
var key = label.id_project+":labels:query:*";
|
455
562
|
winston.verbose("Deleting cache for label.create with key: " + key);
|
456
563
|
client.del(key, function (err, reply) {
|
@@ -464,6 +571,8 @@
|
|
464
571
|
|
465
572
|
labelEvent.on("label.update", function(label) {
|
466
573
|
setImmediate(() => {
|
574
|
+
|
575
|
+
// TODO COMMENTA NON USATO
|
467
576
|
var key = label.id_project+":labels:query:*";
|
468
577
|
winston.verbose("Deleting cache for label.update with key: " + key);
|
469
578
|
client.del(key, function (err, reply) {
|
@@ -475,7 +584,9 @@
|
|
475
584
|
|
476
585
|
|
477
586
|
labelEvent.on("label.clone", function(label) {
|
478
|
-
setImmediate(() => {
|
587
|
+
setImmediate(() => {
|
588
|
+
|
589
|
+
// TODO COMMENTA NON USATO
|
479
590
|
var key = label.id_project+":labels:query:*";
|
480
591
|
winston.verbose("Deleting cache for label.clone with key: " + key);
|
481
592
|
client.del(key, function (err, reply) {
|
@@ -488,6 +599,8 @@
|
|
488
599
|
|
489
600
|
labelEvent.on("label.delete", function(label) {
|
490
601
|
setImmediate(() => {
|
602
|
+
|
603
|
+
// TODO COMMENTA NON USATO
|
491
604
|
var key = label.id_project+":labels:query:*";
|
492
605
|
winston.verbose("Deleting cache for label.delete with key: " + key);
|
493
606
|
client.del(key, function (err, reply) {
|
@@ -575,6 +688,17 @@
|
|
575
688
|
|
576
689
|
}
|
577
690
|
|
691
|
+
|
692
|
+
function invalidateWidgets(client, project_id) {
|
693
|
+
key = project_id+":widgets";
|
694
|
+
winston.verbose("Deleting cache for widgets with key: " + key);
|
695
|
+
client.del(key, function (err, reply) {
|
696
|
+
winston.debug("Deleted cache for widgets",reply);
|
697
|
+
winston.verbose("Deleted cache for widgets",{err:err});
|
698
|
+
});
|
699
|
+
}
|
700
|
+
|
701
|
+
|
578
702
|
//jwt
|
579
703
|
|
580
704
|
// fai cache faq
|
@@ -616,8 +740,12 @@ module.exports = function (mongoose, option) {
|
|
616
740
|
|
617
741
|
var client = cachegoose._cache;
|
618
742
|
listen(client);
|
743
|
+
|
744
|
+
return cachegoose;
|
619
745
|
}else {
|
620
746
|
winston.info("Mongoose Cachegoose disabled");
|
747
|
+
|
748
|
+
return;
|
621
749
|
}
|
622
750
|
|
623
751
|
// console.log("init",init);
|