@tiledesk/tiledesk-server 2.10.39 → 2.10.41
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +7 -1
- package/models/faq.js +8 -0
- package/models/faq_kb.js +23 -17
- package/package.json +1 -1
- package/routes/faq.js +11 -0
- package/routes/faq_kb.js +11 -5
package/CHANGELOG.md
CHANGED
@@ -5,7 +5,13 @@
|
|
5
5
|
🚀 IN PRODUCTION 🚀
|
6
6
|
(https://www.npmjs.com/package/@tiledesk/tiledesk-server/v/2.3.77)
|
7
7
|
|
8
|
-
# 2.10.
|
8
|
+
# 2.10.41
|
9
|
+
- added agents_available field in faq_kb and faq models
|
10
|
+
|
11
|
+
# 2.10.40
|
12
|
+
- bug fix: empty string for slug and index issue
|
13
|
+
|
14
|
+
# 2.10.39
|
9
15
|
- updated whatsapp-connector to 0.1.76
|
10
16
|
- updated tybot-connector to 0.2.139
|
11
17
|
- added chatbot slug in faq_kb model
|
package/models/faq.js
CHANGED
@@ -101,12 +101,20 @@ var FaqSchema = new Schema({
|
|
101
101
|
attributes: {
|
102
102
|
type: Object,
|
103
103
|
},
|
104
|
+
agents_available: {
|
105
|
+
type: Boolean,
|
106
|
+
required: false,
|
107
|
+
default: function () {
|
108
|
+
return this.isNew ? false : undefined;
|
109
|
+
},
|
110
|
+
}
|
104
111
|
}, {
|
105
112
|
timestamps: true,
|
106
113
|
toJSON: { virtuals: true } //used to polulate messages in toJSON// https://mongoosejs.com/docs/populate.html
|
107
114
|
}
|
108
115
|
);
|
109
116
|
|
117
|
+
|
110
118
|
FaqSchema.virtual('faq_kb', {
|
111
119
|
ref: 'faq_kb', // The model to use
|
112
120
|
localField: 'id_faq_kb', // Find people where `localField`
|
package/models/faq_kb.js
CHANGED
@@ -11,13 +11,13 @@ var Faq_kbSchema = new Schema({
|
|
11
11
|
name: {
|
12
12
|
type: String,
|
13
13
|
required: true,
|
14
|
-
index:true
|
14
|
+
index: true
|
15
15
|
},
|
16
16
|
description: {
|
17
17
|
type: String,
|
18
18
|
// index:true
|
19
19
|
},
|
20
|
-
url: {
|
20
|
+
url: {
|
21
21
|
type: String,
|
22
22
|
// required: true
|
23
23
|
},
|
@@ -25,7 +25,7 @@ var Faq_kbSchema = new Schema({
|
|
25
25
|
type: String,
|
26
26
|
// required: true
|
27
27
|
},
|
28
|
-
webhook_enabled: {
|
28
|
+
webhook_enabled: {
|
29
29
|
type: Boolean,
|
30
30
|
required: false,
|
31
31
|
default: false,
|
@@ -74,13 +74,13 @@ var Faq_kbSchema = new Schema({
|
|
74
74
|
type: Boolean,
|
75
75
|
required: false,
|
76
76
|
default: false,
|
77
|
-
index:true
|
77
|
+
index: true
|
78
78
|
},
|
79
79
|
certified: {
|
80
80
|
type: Boolean,
|
81
81
|
required: false,
|
82
82
|
default: false,
|
83
|
-
index:true
|
83
|
+
index: true
|
84
84
|
},
|
85
85
|
mainCategory: {
|
86
86
|
type: String,
|
@@ -92,18 +92,18 @@ var Faq_kbSchema = new Schema({
|
|
92
92
|
default: 'none'
|
93
93
|
},
|
94
94
|
tags: [{
|
95
|
-
|
96
|
-
|
95
|
+
type: String
|
96
|
+
}],
|
97
97
|
score: {
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
98
|
+
type: Number,
|
99
|
+
required: false,
|
100
|
+
index: true,
|
101
|
+
default: 0
|
102
|
+
},
|
103
103
|
publishedBy: {
|
104
104
|
type: String,
|
105
105
|
},
|
106
|
-
publishedAt: {
|
106
|
+
publishedAt: {
|
107
107
|
type: Date
|
108
108
|
},
|
109
109
|
trained: {
|
@@ -122,16 +122,22 @@ var Faq_kbSchema = new Schema({
|
|
122
122
|
type: Array,
|
123
123
|
required: false
|
124
124
|
},
|
125
|
+
agents_available: {
|
126
|
+
type: Boolean,
|
127
|
+
required: false,
|
128
|
+
default: function () {
|
129
|
+
return this.isNew ? false : undefined;
|
130
|
+
},
|
131
|
+
},
|
125
132
|
slug: {
|
126
133
|
type: String,
|
127
134
|
required: false,
|
128
|
-
default: "",
|
129
135
|
index: true
|
130
|
-
}
|
136
|
+
}
|
131
137
|
},{
|
132
138
|
timestamps: true
|
133
|
-
}
|
134
|
-
|
139
|
+
});
|
140
|
+
|
135
141
|
|
136
142
|
Faq_kbSchema.pre("save", async function (next) {
|
137
143
|
// Check if the document is new and if the slug has not been set manually
|
package/package.json
CHANGED
package/routes/faq.js
CHANGED
@@ -15,6 +15,7 @@ csv = require('csv-express');
|
|
15
15
|
csv.separator = ';';
|
16
16
|
const axios = require("axios").default;
|
17
17
|
var configGlobal = require('../config/global');
|
18
|
+
const roleConstants = require('../models/roleConstants');
|
18
19
|
|
19
20
|
const apiUrl = process.env.API_URL || configGlobal.apiUrl;
|
20
21
|
|
@@ -424,6 +425,9 @@ router.put('/:faqid', function (req, res) {
|
|
424
425
|
if (req.body.attributes != undefined) {
|
425
426
|
update.attributes = req.body.attributes;
|
426
427
|
}
|
428
|
+
if (req.body.agents_available != undefined) {
|
429
|
+
update.agents_available = req.body.agents_available;
|
430
|
+
}
|
427
431
|
|
428
432
|
if (faqid.startsWith("intentId")) {
|
429
433
|
let intent_id = faqid.substring(8);
|
@@ -606,6 +610,13 @@ router.get('/', function (req, res, next) {
|
|
606
610
|
query.intent_display_name = req.query.intent_display_name
|
607
611
|
}
|
608
612
|
|
613
|
+
let project_user = req.projectuser;
|
614
|
+
if (project_user && project_user.role === roleConstants.AGENT) {
|
615
|
+
query.agents_available = {
|
616
|
+
$in: [ null, true ]
|
617
|
+
}
|
618
|
+
}
|
619
|
+
|
609
620
|
|
610
621
|
winston.debug("GET FAQ query", query);
|
611
622
|
|
package/routes/faq_kb.js
CHANGED
@@ -245,7 +245,7 @@ router.put('/:faq_kbid/publish', roleChecker.hasRole('admin'), async (req, res)
|
|
245
245
|
let forkedChatBotId = forked.bot_id;
|
246
246
|
winston.debug("forkedChatBotId: "+forkedChatBotId);
|
247
247
|
|
248
|
-
let updatedForkedChabot = await Faq_kb.findByIdAndUpdate(forkedChatBotId, {trashed: true, publishedBy: req.user.id, publishedAt: new Date().getTime()}, { new: true, upsert: true }).exec();
|
248
|
+
let updatedForkedChabot = await Faq_kb.findByIdAndUpdate(forkedChatBotId, { $unset: { slug: 1 }, trashed: true, publishedBy: req.user.id, publishedAt: new Date().getTime()}, { new: true, upsert: true }).exec();
|
249
249
|
winston.debug("updatedForkedChabot: ",updatedForkedChabot);
|
250
250
|
botEvent.emit('faqbot.update', updatedForkedChabot);
|
251
251
|
|
@@ -325,8 +325,8 @@ router.put('/:faq_kbid', roleChecker.hasRoleOrTypes('admin', ['bot','subscriptio
|
|
325
325
|
update.certifiedTags = req.body.certifiedTags
|
326
326
|
}
|
327
327
|
|
328
|
-
if (req.body.
|
329
|
-
update.
|
328
|
+
if (req.body.agents_available != undefined) {
|
329
|
+
update.agents_available = req.body.agents_available
|
330
330
|
}
|
331
331
|
|
332
332
|
if (req.body.slug != undefined) {
|
@@ -542,13 +542,19 @@ router.get('/', roleChecker.hasRoleOrTypes('agent', ['bot','subscription']), fun
|
|
542
542
|
* if filter only for 'trashed = false',
|
543
543
|
* the bots created before the implementation of the 'trashed' property are not returned
|
544
544
|
*/
|
545
|
-
|
545
|
+
let query = { "id_project": req.projectid, "trashed": { $in: [null, false] } };
|
546
|
+
|
547
|
+
if (restricted_mode === true) {
|
548
|
+
query.agents_available = {
|
549
|
+
$in: [ null, true ]
|
550
|
+
}
|
551
|
+
}
|
546
552
|
|
547
553
|
if (req.query.all != "true") {
|
548
554
|
query.type = { $ne: "identity" }
|
549
555
|
}
|
550
556
|
|
551
|
-
|
557
|
+
let search_obj = {"$search": req.query.text};
|
552
558
|
|
553
559
|
if (req.query.text) {
|
554
560
|
if (req.query.language) {
|