@tiledesk/tiledesk-server 2.10.40 → 2.10.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -0
- package/models/faq.js +8 -0
- package/models/faq_kb.js +23 -16
- package/package.json +1 -1
- package/routes/faq.js +11 -0
- package/routes/faq_kb.js +10 -4
package/CHANGELOG.md
CHANGED
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,15 +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
135
|
index: true
|
129
|
-
}
|
136
|
+
}
|
130
137
|
},{
|
131
138
|
timestamps: true
|
132
|
-
}
|
133
|
-
|
139
|
+
});
|
140
|
+
|
134
141
|
|
135
142
|
Faq_kbSchema.pre("save", async function (next) {
|
136
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
@@ -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) {
|