@tiledesk/tiledesk-server 2.4.48 → 2.4.49
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/models/openai_kbs.js +8 -1
- package/package.json +1 -1
- package/routes/email.js +23 -20
- package/routes/openai_kbs.js +3 -2
- package/routes/request.js +61 -1
- package/services/faqService.js +3 -0
package/models/openai_kbs.js
CHANGED
package/package.json
CHANGED
package/routes/email.js
CHANGED
|
@@ -303,35 +303,38 @@ if (process.env.ENABLE_TEST_EMAIL_ENDPOINT==true || process.env.ENABLE_TEST_EMAI
|
|
|
303
303
|
|
|
304
304
|
|
|
305
305
|
//TODO add cc
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
306
|
+
router.post('/internal/send',
|
|
307
|
+
async (req, res) => {
|
|
308
|
+
let to = req.body.to;
|
|
309
|
+
winston.debug("to: " + to);
|
|
310
310
|
|
|
311
|
-
|
|
312
|
-
|
|
311
|
+
let text = req.body.text;
|
|
312
|
+
winston.debug("text: " + text);
|
|
313
313
|
|
|
314
|
-
|
|
315
|
-
|
|
314
|
+
let request_id = req.body.request_id;
|
|
315
|
+
winston.debug("request_id: " + request_id);
|
|
316
316
|
|
|
317
|
-
|
|
318
|
-
|
|
317
|
+
let subject = req.body.subject;
|
|
318
|
+
winston.debug("subject: " + subject);
|
|
319
319
|
|
|
320
|
-
|
|
320
|
+
winston.debug("req.project", req.project);
|
|
321
321
|
|
|
322
|
-
|
|
323
|
-
|
|
322
|
+
let newto = await recipientEmailUtil.process(to, req.projectid);
|
|
323
|
+
winston.debug("newto: " + newto);
|
|
324
324
|
|
|
325
|
-
|
|
326
|
-
|
|
325
|
+
let replyto = req.body.replyto;
|
|
326
|
+
winston.debug("replyto: " + replyto);
|
|
327
327
|
|
|
328
|
-
|
|
328
|
+
winston.info("Sending an email with text : " + text + " to " + to);
|
|
329
329
|
|
|
330
|
-
//
|
|
331
|
-
|
|
330
|
+
//sendEmailDirect(to, text, project, request_id, subject, tokenQueryString, sourcePage, payload)
|
|
331
|
+
emailService.sendEmailDirect(newto, text, req.project, request_id, subject, undefined, undefined, undefined, replyto);
|
|
332
332
|
|
|
333
|
-
|
|
333
|
+
res.json({"queued": true});
|
|
334
334
|
|
|
335
|
-
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
|
|
336
339
|
|
|
337
340
|
module.exports = router;
|
package/routes/openai_kbs.js
CHANGED
|
@@ -24,7 +24,8 @@ router.post('/', async (req, res) => {
|
|
|
24
24
|
let new_kbs = new OpenaiKbs({
|
|
25
25
|
name: body.name,
|
|
26
26
|
url: body.url,
|
|
27
|
-
id_project: req.projectid
|
|
27
|
+
id_project: req.projectid,
|
|
28
|
+
gptkey: req.body.gptkey
|
|
28
29
|
})
|
|
29
30
|
|
|
30
31
|
new_kbs.save(function (err, savedKbs) {
|
|
@@ -38,7 +39,7 @@ router.post('/', async (req, res) => {
|
|
|
38
39
|
})
|
|
39
40
|
|
|
40
41
|
router.put('/', async (req, res) => {
|
|
41
|
-
|
|
42
|
+
// to be implemented
|
|
42
43
|
})
|
|
43
44
|
|
|
44
45
|
router.delete('/:kbs_id', async (req, res) => {
|
package/routes/request.js
CHANGED
|
@@ -6,6 +6,8 @@ var Schema = mongoose.Schema,
|
|
|
6
6
|
ObjectId = Schema.ObjectId;
|
|
7
7
|
var moment = require('moment');
|
|
8
8
|
var requestService = require('../services/requestService');
|
|
9
|
+
var emailService = require('../services/emailService');
|
|
10
|
+
|
|
9
11
|
var departmentService = require('../services/departmentService');
|
|
10
12
|
var winston = require('../config/winston');
|
|
11
13
|
const requestEvent = require('../event/requestEvent');
|
|
@@ -646,6 +648,62 @@ router.delete('/:requestid/notes/:noteid', function (req, res) {
|
|
|
646
648
|
|
|
647
649
|
|
|
648
650
|
|
|
651
|
+
//TODO add cc
|
|
652
|
+
router.post('/:requestid/email/send',
|
|
653
|
+
async (req, res) => {
|
|
654
|
+
|
|
655
|
+
|
|
656
|
+
let text = req.body.text;
|
|
657
|
+
winston.debug("text: " + text);
|
|
658
|
+
|
|
659
|
+
let request_id = req.params.requestid;
|
|
660
|
+
winston.debug("request_id: " + request_id);
|
|
661
|
+
|
|
662
|
+
let subject = req.body.subject;
|
|
663
|
+
winston.info("subject: " + subject);
|
|
664
|
+
|
|
665
|
+
winston.debug("req.project", req.project);
|
|
666
|
+
|
|
667
|
+
let replyto = req.body.replyto;
|
|
668
|
+
winston.debug("replyto: " + replyto);
|
|
669
|
+
|
|
670
|
+
|
|
671
|
+
let q = Request.findOne({request_id: request_id, id_project: req.projectid})
|
|
672
|
+
// .select("+snapshot.agents")
|
|
673
|
+
.populate('lead')
|
|
674
|
+
q.exec(function(err, request) {
|
|
675
|
+
if (err) {
|
|
676
|
+
winston.error("error getting request by id ", err);
|
|
677
|
+
return res.status(500).send({ success: false, msg: 'Error getting object.' });
|
|
678
|
+
}
|
|
679
|
+
if (!request) {
|
|
680
|
+
return res.status(404).send({ success: false, msg: 'Object not found.' });
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
winston.info("Sending an email with text : " + text + " to request_id " + request_id);
|
|
686
|
+
|
|
687
|
+
if (!request.lead.email) {
|
|
688
|
+
res.json({"no queued": true});
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
let newto = request.lead.email
|
|
692
|
+
winston.info("Sending an email newto " + newto);
|
|
693
|
+
|
|
694
|
+
//sendEmailDirect(to, text, project, request_id, subject, tokenQueryString, sourcePage, payload)
|
|
695
|
+
emailService.sendEmailDirect(newto, text, req.project, request_id, subject, undefined, undefined, undefined, replyto);
|
|
696
|
+
|
|
697
|
+
res.json({"queued": true});
|
|
698
|
+
|
|
699
|
+
|
|
700
|
+
});
|
|
701
|
+
|
|
702
|
+
|
|
703
|
+
|
|
704
|
+
|
|
705
|
+
});
|
|
706
|
+
|
|
649
707
|
|
|
650
708
|
|
|
651
709
|
|
|
@@ -1029,7 +1087,9 @@ router.get('/', function (req, res, next) {
|
|
|
1029
1087
|
winston.debug('REQUEST ROUTE - QUERY channel', query.channel);
|
|
1030
1088
|
}
|
|
1031
1089
|
|
|
1032
|
-
|
|
1090
|
+
if (req.query.priority) {
|
|
1091
|
+
query.priority = req.query.priority;
|
|
1092
|
+
}
|
|
1033
1093
|
|
|
1034
1094
|
|
|
1035
1095
|
var direction = -1; //-1 descending , 1 ascending
|
package/services/faqService.js
CHANGED