@tiledesk/tiledesk-server 2.10.9 → 2.10.10
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 +4 -0
- package/app.js +2 -2
- package/package.json +2 -2
- package/routes/email.js +1 -1
- package/routes/faq_kb.js +4 -4
- package/routes/request.js +1 -1
- package/test/app-test.js +50 -0
package/CHANGELOG.md
CHANGED
package/app.js
CHANGED
@@ -458,11 +458,11 @@ var projectSetter = function (req, res, next) {
|
|
458
458
|
if (err) {
|
459
459
|
winston.warn("Problem getting project with id: " + projectid + " req.originalUrl: " + req.originalUrl);
|
460
460
|
}
|
461
|
-
|
462
461
|
winston.debug("projectSetter project:" + project);
|
463
462
|
if (!project) {
|
464
463
|
winston.warn("ProjectSetter project not found with id: " + projectid);
|
465
|
-
next();
|
464
|
+
//next();
|
465
|
+
return res.status(400).send({ error: "Project not found with id: " + projectid })
|
466
466
|
} else {
|
467
467
|
req.project = project;
|
468
468
|
next(); //call next one time for projectSetter function
|
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.10.
|
4
|
+
"version": "2.10.10",
|
5
5
|
"scripts": {
|
6
6
|
"start": "node ./bin/www",
|
7
7
|
"pretest": "mongodb-runner start",
|
@@ -48,7 +48,7 @@
|
|
48
48
|
"@tiledesk/tiledesk-rasa-connector": "^1.0.10",
|
49
49
|
"@tiledesk/tiledesk-telegram-connector": "^0.1.14",
|
50
50
|
"@tiledesk/tiledesk-train-jobworker": "^0.0.11",
|
51
|
-
"@tiledesk/tiledesk-tybot-connector": "^0.2.
|
51
|
+
"@tiledesk/tiledesk-tybot-connector": "^0.2.118",
|
52
52
|
"@tiledesk/tiledesk-whatsapp-connector": "^0.1.73",
|
53
53
|
"@tiledesk/tiledesk-whatsapp-jobworker": "^0.0.8",
|
54
54
|
"@tiledesk/tiledesk-sms-connector": "^0.1.10",
|
package/routes/email.js
CHANGED
@@ -387,7 +387,7 @@ router.post('/internal/send',
|
|
387
387
|
let replyto = req.body.replyto;
|
388
388
|
winston.debug("replyto: " + replyto);
|
389
389
|
|
390
|
-
winston.info("Sending an email with text : " + text + " to " + to);
|
390
|
+
//winston.info("Sending an email with text : " + text + " to " + to);
|
391
391
|
|
392
392
|
let quoteManager = req.app.get('quote_manager');
|
393
393
|
|
package/routes/faq_kb.js
CHANGED
@@ -833,10 +833,10 @@ router.post('/importjson/:id_faq_kb', roleChecker.hasRole('admin'), upload.singl
|
|
833
833
|
|
834
834
|
if (savingResult) {
|
835
835
|
if (savingResult.lastErrorObject.updatedExisting === true) {
|
836
|
-
winston.
|
836
|
+
winston.verbose("updated existing intent")
|
837
837
|
faqBotEvent.emit('faq.update', savingResult.value);
|
838
838
|
} else {
|
839
|
-
winston.
|
839
|
+
winston.verbose("new intent created")
|
840
840
|
faqBotEvent.emit('faq.create', savingResult.value);
|
841
841
|
}
|
842
842
|
}
|
@@ -849,7 +849,7 @@ router.post('/importjson/:id_faq_kb', roleChecker.hasRole('admin'), upload.singl
|
|
849
849
|
let faq = await Faq.create(new_faq).catch((err) => {
|
850
850
|
if (err.code == 11000) {
|
851
851
|
winston.error("Duplicate intent_display_name.");
|
852
|
-
winston.
|
852
|
+
winston.verbose("Skip duplicated intent_display_name");
|
853
853
|
} else {
|
854
854
|
winston.error("Error creating new intent: ", err);
|
855
855
|
}
|
@@ -857,7 +857,7 @@ router.post('/importjson/:id_faq_kb', roleChecker.hasRole('admin'), upload.singl
|
|
857
857
|
})
|
858
858
|
|
859
859
|
if (faq) {
|
860
|
-
winston.
|
860
|
+
winston.verbose("new intent created")
|
861
861
|
faqBotEvent.emit('faq.create', faq);
|
862
862
|
}
|
863
863
|
}
|
package/routes/request.js
CHANGED
@@ -744,7 +744,7 @@ router.post('/:requestid/email/send',
|
|
744
744
|
winston.debug("request_id: " + request_id);
|
745
745
|
|
746
746
|
let subject = req.body.subject;
|
747
|
-
winston.
|
747
|
+
winston.debug("subject: " + subject);
|
748
748
|
|
749
749
|
winston.debug("req.project", req.project);
|
750
750
|
|
package/test/app-test.js
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
process.env.NODE_ENV = 'test';
|
2
|
+
|
3
|
+
let chai = require('chai');
|
4
|
+
let chaiHttp = require('chai-http');
|
5
|
+
let server = require('../app');
|
6
|
+
let should = chai.should();
|
7
|
+
const userService = require('../services/userService');
|
8
|
+
const projectService = require('../services/projectService');
|
9
|
+
|
10
|
+
let log = false;
|
11
|
+
|
12
|
+
let expect = chai.expect;
|
13
|
+
let assert = chai.assert;
|
14
|
+
|
15
|
+
chai.use(chaiHttp);
|
16
|
+
|
17
|
+
describe('Root Test', () => {
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Try to perform a request with an invalid id project.
|
21
|
+
* A fake id or non existent mongo id (like user id) is passed.
|
22
|
+
* This test must respond with status 400 and with an error.
|
23
|
+
*/
|
24
|
+
it("Wrong request url", (done) => {
|
25
|
+
|
26
|
+
var email = "test-signup-" + Date.now() + "@email.com";
|
27
|
+
var pwd = "pwd";
|
28
|
+
|
29
|
+
userService.signup(email, pwd, "Test Firstname", "Test Lastname").then((savedUser) => {
|
30
|
+
projectService.create("test-root-project", savedUser._id).then((savedProject) => {
|
31
|
+
|
32
|
+
let fake_id_project = "fake1234"
|
33
|
+
|
34
|
+
chai.request(server)
|
35
|
+
//.get('/' + savedUser._id + '/faq_kb')
|
36
|
+
.get('/' + fake_id_project + '/faq_kb')
|
37
|
+
.auth(email, pwd)
|
38
|
+
.end((err, res) => {
|
39
|
+
if (err) { console.error("err: ", err); }
|
40
|
+
if (log) { console.log("res.body", res.body); }
|
41
|
+
|
42
|
+
res.should.have.status(400);
|
43
|
+
assert.notEqual(res.body.error, null);
|
44
|
+
expect(res.body.error).to.equal("Project not found with id: " + fake_id_project)
|
45
|
+
done();
|
46
|
+
})
|
47
|
+
})
|
48
|
+
})
|
49
|
+
}).timeout(5000)
|
50
|
+
})
|