@tiledesk/tiledesk-server 2.1.40 → 2.2.3
Sign up to get free protection for your applications and to get access to all the features.
- package/.circleci/config.yml +54 -0
- package/.env.sample +1 -1
- package/.github/workflows/docker-community-push-latest.yml +22 -0
- package/.github/workflows/{docker-image-push.yml → docker-image-en-tag-push.yml} +1 -1
- package/.github/workflows/docker-image-tag-community-tag-push.yml +21 -0
- package/.github/workflows/{docker-push-latest.yml → docker-push-en-push-latest.yml} +1 -1
- package/CHANGELOG.md +195 -1
- package/Dockerfile +1 -1
- package/Dockerfile-en +1 -1
- package/README.md +5 -7
- package/app.js +12 -1
- package/channels/channelManager.js +1 -1
- package/channels/chat21/chat21Contact.js +34 -8
- package/channels/chat21/chat21Handler.js +48 -5
- package/channels/chat21/chat21WebHook.js +34 -9
- package/channels/chat21/nativeauth.js +2 -2
- package/channels/chat21/package-lock.json +3013 -0
- package/config/email.js +2 -0
- package/config/global.js +3 -0
- package/config/labels/widget.json +170 -16
- package/event/messageEvent.js +18 -1
- package/middleware/passport.js +10 -4
- package/migrations/1619185894304-request-remove-duplicated-request-by-request_id--autosync.js +67 -0
- package/models/actionsConstants.js +7 -0
- package/models/department.js +3 -0
- package/models/faq.js +8 -2
- package/models/faq_kb.js +6 -0
- package/models/message.js +10 -4
- package/models/messageConstants.js +9 -3
- package/models/request.js +33 -3
- package/package.json +31 -28
- package/pubmodules/emailNotification/requestNotification.js +483 -56
- package/pubmodules/messageActions/messageActionsInterceptor.js +20 -7
- package/pubmodules/messageTransformer/index.js +5 -1
- package/pubmodules/messageTransformer/messageTransformerInterceptor.js +4 -2
- package/pubmodules/messageTransformer/microLanguageAttributesTransformerInterceptor.js +67 -0
- package/pubmodules/messageTransformer/microLanguageTransformerInterceptor.js +67 -0
- package/pubmodules/pubModulesManager.js +66 -13
- package/pubmodules/rules/conciergeBot.js +81 -49
- package/routes/auth.js +46 -11
- package/routes/campaigns.js +117 -25
- package/routes/department.js +2 -2
- package/routes/faq.js +19 -0
- package/routes/faq_kb.js +13 -4
- package/routes/faqpub.js +1 -1
- package/routes/files.js +17 -2
- package/routes/images.js +1 -1
- package/routes/jwt.js +0 -1
- package/routes/logs.js +26 -0
- package/routes/message.js +7 -2
- package/routes/messagesRoot.js +73 -16
- package/routes/project_user.js +36 -1
- package/routes/request.js +88 -12
- package/routes/requestUtilRoot.js +30 -0
- package/routes/urls.js +12 -0
- package/routes/users.js +5 -1
- package/services/BotSubscriptionNotifier.js +1 -0
- package/services/departmentService.js +29 -5
- package/services/emailService.js +1170 -239
- package/services/faqBotHandler.js +176 -61
- package/services/faqBotSupport.js +182 -117
- package/services/faqService.js +18 -14
- package/services/messageService.js +57 -9
- package/services/modulesManager.js +86 -23
- package/services/requestService.js +58 -17
- package/template/email/assignedEmailMessage.html +205 -0
- package/template/email/assignedRequest.html +44 -14
- package/template/email/beenInvitedExistingUser.html +2 -2
- package/template/email/beenInvitedNewUser.html +1 -1
- package/template/email/newMessage.html +31 -12
- package/template/email/passwordChanged.html +2 -3
- package/template/email/pooledEmailMessage.html +208 -0
- package/template/email/pooledRequest.html +41 -14
- package/template/email/resetPassword.html +2 -3
- package/template/email/sendTranscript.html +1 -1
- package/template/email/test.html +1 -1
- package/template/email/ticket.html +191 -0
- package/template/email/ticket.txt +11 -0
- package/template/email/verify.html +1 -1
- package/test/authentication.js +76 -4
- package/test/authenticationJwt.js +76 -2
- package/test/campaignsRoute.js +226 -0
- package/test/faqService.js +3 -3
- package/test/faqkbRoute.js +3 -2
- package/test/messageRootRoute.js +193 -0
- package/test/messageRoute.js +75 -0
- package/test/messageService.js +39 -2
- package/test/requestRoute.js +27 -9
- package/test/requestService.js +472 -11
- package/test-int/bot.js +673 -8
- package/websocket/webSocketServer.js +7 -4
@@ -17,11 +17,23 @@ var ProjectUserUtil = require("../../utils/project_userUtil");
|
|
17
17
|
var RequestUtil = require("../../utils/requestUtil");
|
18
18
|
const authEvent = require('../../event/authEvent');
|
19
19
|
|
20
|
+
var syncJoinAndLeaveGroupEvent = false;
|
21
|
+
if (process.env.SYNC_JOIN_LEAVE_GROUP_EVENT === true || process.env.SYNC_JOIN_LEAVE_GROUP_EVENT ==="true") {
|
22
|
+
syncJoinAndLeaveGroupEvent = true;
|
23
|
+
}
|
24
|
+
winston.info("Chat21 Sync JoinAndLeave Support Group Event: " + syncJoinAndLeaveGroupEvent);
|
25
|
+
|
26
|
+
var allowReopenChat = false;
|
27
|
+
if (process.env.ALLOW_REOPEN_CHAT === true || process.env.ALLOW_REOPEN_CHAT ==="true") {
|
28
|
+
allowReopenChat = true;
|
29
|
+
}
|
30
|
+
winston.info("Chat21 allow reopen chat: " + allowReopenChat);
|
31
|
+
|
20
32
|
|
21
33
|
router.post('/', function (req, res) {
|
22
34
|
|
23
35
|
|
24
|
-
|
36
|
+
winston.debug("req.body.event_type: " + req.body.event_type);
|
25
37
|
|
26
38
|
//Deprecated
|
27
39
|
if (req.body.event_type == "message-sent" || req.body.event_type == "new-message") {
|
@@ -38,7 +50,7 @@ router.post('/', function (req, res) {
|
|
38
50
|
|
39
51
|
var message = req.body.data;
|
40
52
|
|
41
|
-
|
53
|
+
winston.debug("message text: " + message.text);
|
42
54
|
|
43
55
|
|
44
56
|
// before request_id id_project unique commented
|
@@ -77,10 +89,6 @@ router.post('/', function (req, res) {
|
|
77
89
|
|
78
90
|
var departmentid = "default";
|
79
91
|
|
80
|
-
// TODO 2020-04-20T14:38:56.954323+00:00 app[web.1]: info: MessageTransformerInterceptor message.create.simple.before {"beforeMessage":{"sender":"e06e10e8-24e9-47b1-b0c4-0ab8f8f576d2","senderFullname":"dario","recipient":"support-group-M5N0kHtNohGt8iCJiQy","text":"test 3","id_project":"5b55e806c93dde00143163dd","createdBy":"e06e10e8-24e9-47b1-b0c4-0ab8f8f576d2","status":200,"attributes":{"client":"Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4106.0 Mobile Safari/537.36","departmentId":"5c04ed747608f10015378fe8","departmentName":"Dipartimento 1","projectId":"5b55e806c93dde00143163dd","requester_id":"e06e10e8-24e9-47b1-b0c4-0ab8f8f576d2","sourcePage":"http://localhost:4200/test-custom-auth.html?tiledesk_callouttimer=2&tiledesk_isLogEnabled=true","userEmail":"test1@tiledesk.com","userFullname":"dario","senderAuthInfo":{"authType":"USER","authVar":{"token":{"aud":"chat21-pre-01","auth_time":1587392396,"exp":1587395996,"firebase":{"sign_in_provider":"custom"},"iat":1587392396,"iss":"https://securetoken.google.com/chat21-pre-01","sub":"e06e10e8-24e9-47b1-b0c4-0ab8f8f576d2","user_id":"e06e10e8-24e9-47b1-b0c4-0ab8f8f576d2"},"uid":"e06e10e8-24e9-47b1-b0c4-0ab8f8f576d2"}}},"type":"text","metadata":"","language":"it-IT"}}
|
81
|
-
// 2020-04-20T14:38:56.986907+00:00 app[web.1]: error: undefined {"driver":true,"name":"MongoError","index":0,"code":17262,"errmsg":"language override unsupported: IT-IT"}
|
82
|
-
// 2020-04-20T14:38:56.987274+00:00 app[web.1]: error: Error creating the request object.language override unsupported: IT-IT {"driver":true,"name":"MongoError","index":0,"code":17262,"errmsg":"language override unsupported: IT-IT","stack":"MongoError: language override unsupported: IT-IT\n at Function.create (/app/node_modules/mongodb/lib/core/error.js:44:12)\n at toError (/app/node_modules/mongodb/lib/utils.js:150:22)\n at coll.s.topology.insert (/app/node_modules/mongodb/lib/operations/common_functions.js:265:39)\n at handler (/app/node_modules/mongodb/lib/core/topologies/replset.js:1209:22)\n at /app/node_modules/mongodb/lib/core/connection/pool.js:420:18\n at processTicksAndRejections (internal/process/next_tick.js:74:9)"}
|
83
|
-
// 2020-04-20T14:38:57.027369+00:00 app[we
|
84
92
|
|
85
93
|
var language = message.language;
|
86
94
|
winston.debug("chat21 language", language);
|
@@ -348,16 +356,16 @@ router.post('/', function (req, res) {
|
|
348
356
|
var projectId = RequestUtil.getProjectIdFromRequestId(recipient_id);
|
349
357
|
|
350
358
|
var isObjectId = mongoose.Types.ObjectId.isValid(projectId);
|
351
|
-
winston.
|
359
|
+
winston.debug("isObjectId:"+ isObjectId);
|
352
360
|
|
353
|
-
winston.
|
361
|
+
winston.debug("attributes",conversation.attributes);
|
354
362
|
|
355
363
|
if (!projectId || !isObjectId) { //back compatibility when projectId were always presents in the attributes (firebase)
|
356
364
|
projectId = conversation.attributes.projectId;
|
357
365
|
winston.verbose('getting projectId from attributes (back compatibility): '+ projectId);
|
358
366
|
}
|
359
367
|
|
360
|
-
winston.
|
368
|
+
winston.debug('projectId: '+ projectId);
|
361
369
|
|
362
370
|
if (!projectId) {
|
363
371
|
return res.status(500).send({success: false, msg: "Error projectid is not presents in attributes " });
|
@@ -415,6 +423,11 @@ router.post('/', function (req, res) {
|
|
415
423
|
|
416
424
|
winston.debug("req.body", JSON.stringify(req.body));
|
417
425
|
|
426
|
+
if (!syncJoinAndLeaveGroupEvent) {
|
427
|
+
winston.debug("syncJoinAndLeaveGroupEvent is disabled");
|
428
|
+
return res.status(200).send({success: true, msg: "syncJoinAndLeaveGroupEvent is disabled" });
|
429
|
+
}
|
430
|
+
|
418
431
|
var data = req.body.data;
|
419
432
|
//winston.debug("data",data);
|
420
433
|
|
@@ -480,6 +493,12 @@ router.post('/', function (req, res) {
|
|
480
493
|
|
481
494
|
winston.debug("req.body", JSON.stringify(req.body));
|
482
495
|
|
496
|
+
if (!syncJoinAndLeaveGroupEvent) {
|
497
|
+
winston.debug("syncJoinAndLeaveGroupEvent is disabled");
|
498
|
+
return res.status(200).send({success: true, msg: "syncJoinAndLeaveGroupEvent is disabled" });
|
499
|
+
}
|
500
|
+
|
501
|
+
|
483
502
|
|
484
503
|
var data = req.body.data;
|
485
504
|
// winston.debug("data",data);
|
@@ -519,6 +538,11 @@ router.post('/', function (req, res) {
|
|
519
538
|
|
520
539
|
winston.debug("req.body",req.body);
|
521
540
|
|
541
|
+
if (!allowReopenChat) {
|
542
|
+
winston.debug("allowReopenChat is disabled");
|
543
|
+
return res.status(200).send({success: true, msg: "allowReopenChat is disabled" });
|
544
|
+
}
|
545
|
+
|
522
546
|
|
523
547
|
var conversation = req.body.data;
|
524
548
|
// winston.debug("conversation",conversation);
|
@@ -698,6 +722,7 @@ else if (req.body.event_type == "presence-change") {
|
|
698
722
|
|
699
723
|
project_user.presence = update
|
700
724
|
|
725
|
+
|
701
726
|
project_user.save(function (err, savedProjectUser) {
|
702
727
|
if (err) {
|
703
728
|
winston.error('Error saving project_user ', err)
|
@@ -46,7 +46,7 @@ router.post('/createCustomToken', function (req, res) {
|
|
46
46
|
]
|
47
47
|
|
48
48
|
const now = Math.round(new Date().getTime()/1000);
|
49
|
-
console.log("now: ", now)
|
49
|
+
// console.log("now: ", now)
|
50
50
|
const exp = now + 60 * 60 * 24 * 30;
|
51
51
|
|
52
52
|
var payload = {
|
@@ -76,7 +76,7 @@ router.post('/createCustomToken', function (req, res) {
|
|
76
76
|
"kid": "tiledesk-key", //"legacy-token-key",
|
77
77
|
"tiledesk_api_roles": "user"
|
78
78
|
}
|
79
|
-
|
79
|
+
winston.debug("payload:\n", payload)
|
80
80
|
var token = jwt.sign(
|
81
81
|
payload,
|
82
82
|
jwtSecret,
|