@tiledesk/tiledesk-server 2.4.8 → 2.4.9
Sign up to get free protection for your applications and to get access to all the features.
- package/event/botEvent.js +12 -2
- package/middleware/has-role.js +6 -0
- package/models/faq_kb.js +4 -0
- package/models/lead.js +5 -0
- package/package.json +2 -2
- package/public/wstest/index.html +5 -41
- package/pubmodules/queue/reconnect.js +24 -0
- package/pubmodules/queue/reconnectFanout.js +17 -0
- package/routes/faq_kb.js +42 -0
- package/routes/lead.js +51 -0
- package/services/trainingService.js +7 -2
- package/template/email/assignedEmailMessage.html +253 -149
- package/template/email/assignedRequest.html +272 -172
- package/template/email/beenInvitedExistingUser.html +213 -130
- package/template/email/beenInvitedNewUser.html +200 -119
- package/template/email/emailDirect.html +207 -114
- package/template/email/newMessage.html +250 -157
- package/template/email/newMessageFollower.html +351 -225
- package/template/email/passwordChanged.html +177 -95
- package/template/email/pooledEmailMessage.html +250 -151
- package/template/email/pooledRequest.html +270 -164
- package/template/email/resetPassword.html +200 -114
- package/template/email/sendTranscript.html +299 -197
- package/template/email/ticket.html +263 -160
- package/template/email/verify.html +208 -126
- package/websocket/webSocketServer.js +70 -3
@@ -1,97 +1,136 @@
|
|
1
1
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2
|
-
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
2
|
+
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
|
3
|
+
style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
|
4
|
+
|
5
|
+
<head>
|
6
|
+
<meta name="viewport" content="width=device-width" />
|
7
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
8
|
+
<title>New email from Tiledesk</title>
|
9
|
+
|
10
|
+
<style type="text/css">
|
11
|
+
img {
|
12
|
+
max-width: 100%;
|
13
|
+
margin-left: 16px;
|
14
|
+
text-align: center !important;
|
15
|
+
}
|
16
|
+
|
17
|
+
img.CToWUd {
|
18
|
+
margin-bottom: 16px;
|
19
|
+
max-width: 200px !important;
|
20
|
+
width: 200px !important;
|
21
|
+
min-width: 200px !important;
|
22
|
+
outline: none;
|
23
|
+
text-decoration: none;
|
24
|
+
border: none;
|
25
|
+
height: auto;
|
26
|
+
margin-left: 0px;
|
27
|
+
}
|
28
|
+
|
29
|
+
body {
|
30
|
+
-webkit-font-smoothing: antialiased;
|
31
|
+
-webkit-text-size-adjust: none;
|
32
|
+
width: 100% !important;
|
33
|
+
height: 100%;
|
34
|
+
line-height: 1.6em;
|
35
|
+
}
|
36
|
+
|
37
|
+
body {
|
38
|
+
background-color: #f6f6f6;
|
39
|
+
}
|
40
|
+
|
41
|
+
@media only screen and (max-width: 640px) {
|
42
|
+
body {
|
43
|
+
padding: 0 !important;
|
44
|
+
}
|
45
|
+
|
46
|
+
h1 {
|
47
|
+
font-weight: 800 !important;
|
48
|
+
margin: 20px 0 5px !important;
|
49
|
+
text-align: center !important;
|
50
|
+
}
|
51
|
+
|
52
|
+
h2 {
|
53
|
+
font-weight: 800 !important;
|
54
|
+
margin: 20px 0 5px !important;
|
55
|
+
}
|
56
|
+
|
57
|
+
h3 {
|
58
|
+
font-weight: 800 !important;
|
59
|
+
margin: 20px 0 5px !important;
|
60
|
+
}
|
61
|
+
|
62
|
+
h4 {
|
63
|
+
font-weight: 800 !important;
|
64
|
+
margin: 20px 0 5px !important;
|
65
|
+
}
|
66
|
+
|
67
|
+
h1 {
|
68
|
+
font-size: 22px !important;
|
69
|
+
}
|
70
|
+
|
71
|
+
h2 {
|
72
|
+
font-size: 18px !important;
|
73
|
+
}
|
74
|
+
|
75
|
+
h3 {
|
76
|
+
font-size: 16px !important;
|
77
|
+
}
|
78
|
+
|
79
|
+
.container {
|
80
|
+
padding: 0 !important;
|
81
|
+
width: 100% !important;
|
82
|
+
}
|
83
|
+
|
84
|
+
.content {
|
85
|
+
padding: 0 !important;
|
86
|
+
}
|
87
|
+
|
88
|
+
.content-wrap {
|
89
|
+
padding: 10px !important;
|
90
|
+
}
|
91
|
+
|
92
|
+
.invoice {
|
93
|
+
width: 100% !important;
|
94
|
+
}
|
95
|
+
}
|
96
|
+
</style>
|
97
|
+
</head>
|
98
|
+
|
99
|
+
<body itemscope itemtype="http://schema.org/EmailMessage"
|
100
|
+
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; width: 100% !important; height: 100%; line-height: 1.6em; background-color: #f6f6f6; margin: 0;"
|
101
|
+
bgcolor="#f6f6f6">
|
102
|
+
|
103
|
+
<table class="body-wrap"
|
104
|
+
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; width: 100%; background-color: #f6f6f6; margin: 0;"
|
105
|
+
bgcolor="#f6f6f6">
|
106
|
+
<tr
|
107
|
+
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
|
108
|
+
<td
|
109
|
+
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0;"
|
110
|
+
valign="top"></td>
|
111
|
+
<td class="container" width="600"
|
112
|
+
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; display: block !important; max-width: 600px !important; clear: both !important; margin: 0 auto;"
|
113
|
+
valign="top">
|
114
|
+
<div class="content"
|
115
|
+
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; max-width: 600px; display: block; margin: 0 auto; padding: 20px;">
|
116
|
+
<table class="main" width="100%" cellpadding="0" cellspacing="0"
|
117
|
+
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; border-radius: 3px; background-color: #fff; margin: 0; border: 1px solid #e9e9e9;"
|
118
|
+
bgcolor="#fff">
|
119
|
+
|
120
|
+
<tr
|
121
|
+
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
|
122
|
+
|
123
|
+
<div style="text-align:center">
|
124
|
+
<!--
|
87
125
|
<a href="http://www.tiledesk.com" style="color:#2daae1;font-weight:bold;text-decoration:none;word-break:break-word" target="_blank">
|
88
126
|
<img src="https://tiledesk.com/tiledesk-logo.png" class="CToWUd">
|
89
127
|
</a>
|
90
|
-
|
91
|
-
|
128
|
+
-->
|
129
|
+
</div>
|
130
|
+
</tr>
|
131
|
+
|
92
132
|
|
93
|
-
|
94
|
-
<!-- <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
|
133
|
+
<!-- <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
|
95
134
|
|
96
135
|
<td class="alert alert-warning" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 16px; vertical-align: top; font-weight: 500; text-align: center; border-radius: 3px 3px 0 0; margin: 0;" align="center"; valign="top">
|
97
136
|
<div>
|
@@ -100,45 +139,88 @@
|
|
100
139
|
|
101
140
|
</td>
|
102
141
|
</tr> -->
|
103
|
-
|
104
142
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
143
|
+
|
144
|
+
<tr
|
145
|
+
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
|
146
|
+
<td class="content-wrap"
|
147
|
+
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 20px;"
|
148
|
+
valign="top">
|
149
|
+
<table width="100%" cellpadding="0" cellspacing="0"
|
150
|
+
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
|
151
|
+
|
152
|
+
<tr
|
153
|
+
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
|
154
|
+
<td class="content-block"
|
155
|
+
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0;"
|
156
|
+
valign="top">
|
157
|
+
<strong
|
158
|
+
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">Hi
|
159
|
+
{{savedUser.firstname}} {{savedUser.lastname}},</strong>
|
160
|
+
<!-- <br> welcome on Tiledesk.com. -->
|
161
|
+
<br><br> Thank you for signin up with Tiledesk.
|
162
|
+
<br><br> To complete the setup, <span><a
|
163
|
+
href="{{baseScope.baseUrl}}/#/verify/email/{{savedUser._id}}"> click here to verify your email
|
164
|
+
address. </a> </span>
|
165
|
+
<br><br>Give us your feedback! We need your advice. Send an email to <a
|
166
|
+
href="mailto:info@tiledesk.com">info@tiledesk.com</a>
|
167
|
+
<br><br> The Tiledesk Team
|
168
|
+
</td>
|
169
|
+
</tr>
|
170
|
+
|
171
|
+
<tr
|
172
|
+
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
|
173
|
+
<td class="content-block"
|
174
|
+
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0;"
|
175
|
+
valign="top">
|
125
176
|
</td>
|
126
177
|
</tr>
|
127
178
|
</table>
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
</
|
179
|
+
</td>
|
180
|
+
</tr>
|
181
|
+
|
182
|
+
<tr>
|
183
|
+
<td>
|
184
|
+
<hr style="width:94%;height:1px;border:none;background-color: #cacaca;">
|
185
|
+
|
186
|
+
<div style="display: flex; padding: 20px 18px; color: #888888;">
|
187
|
+
<span>Powered by </span>
|
188
|
+
<span style="display: flex;"><img
|
189
|
+
src="https://panel.tiledesk.com/v3/dashboard/assets/img/logos/tiledesk-solo_logo_new_gray.svg"
|
190
|
+
width="18" height="auto" style="margin-left: 6px;" /></span>
|
191
|
+
<span style="font-weight: bold; margin-left: 2px;">Tiledesk</span>
|
137
192
|
</div>
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
193
|
+
|
194
|
+
</td>
|
195
|
+
</tr>
|
196
|
+
|
197
|
+
|
198
|
+
</table>
|
199
|
+
<div class="footer"
|
200
|
+
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; width: 100%; clear: both; color: #999; margin: 0; padding: 20px;">
|
201
|
+
<table width="100%"
|
202
|
+
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
|
203
|
+
<tr
|
204
|
+
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
|
205
|
+
<td class="aligncenter content-block"
|
206
|
+
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 12px; vertical-align: top; color: #999; text-align: center; margin: 0;"
|
207
|
+
align="center" valign="top">
|
208
|
+
<span><a href="http://www.tiledesk.com"
|
209
|
+
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 12px; color: #999; text-decoration: underline; margin: 0;">
|
210
|
+
Tiledesk.com </a></span>
|
211
|
+
<br><span><a href="%unsubscribe_url%"
|
212
|
+
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 12px; color: #999; text-decoration: underline; margin: 0;">Unsubscribe</a></span>
|
213
|
+
</td>
|
214
|
+
</tr>
|
215
|
+
</table>
|
216
|
+
</div>
|
217
|
+
</div>
|
218
|
+
</td>
|
219
|
+
<td
|
220
|
+
style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0;"
|
221
|
+
valign="top"></td>
|
222
|
+
</tr>
|
223
|
+
</table>
|
224
|
+
</body>
|
225
|
+
|
226
|
+
</html>
|
@@ -5,12 +5,14 @@ var Project = require("../models/project");
|
|
5
5
|
var EventModel = require("../pubmodules/events/event");
|
6
6
|
var Request = require("../models/request");
|
7
7
|
var Message = require("../models/message");
|
8
|
+
var Faq_kb = require("../models/faq_kb");
|
8
9
|
const WebSocket = require('ws');
|
9
10
|
var url = require('url');
|
10
11
|
var validtoken = require('../middleware/valid-token');
|
11
12
|
var messageEvent = require("../event/messageEvent");
|
12
13
|
var eventEvent = require("../pubmodules/events/eventEvent");
|
13
14
|
var requestEvent = require("../event/requestEvent");
|
15
|
+
var botEvent = require("../event/botEvent");
|
14
16
|
var jwt = require('jsonwebtoken');
|
15
17
|
var config = require('../config/database'); // get db config file
|
16
18
|
var winston = require('../config/winston');
|
@@ -183,6 +185,7 @@ class WebSocketServer {
|
|
183
185
|
return reject('WebSocket - Error getting topic. Topic can t be null');
|
184
186
|
}
|
185
187
|
var urlSub = topic.split('/');
|
188
|
+
winston.debug('urlSub: '+urlSub);
|
186
189
|
|
187
190
|
if (!urlSub || (urlSub && urlSub.length==0)) {
|
188
191
|
winston.error('WebSocket - Error getting topic. Topic is not properly configured');
|
@@ -209,7 +212,7 @@ class WebSocketServer {
|
|
209
212
|
|
210
213
|
if (!project) {
|
211
214
|
winston.warn('WebSocket project not found for projectid ' + projectId);
|
212
|
-
return reject({err:'
|
215
|
+
return reject({err:'project not found for projectid ' + projectId});
|
213
216
|
}
|
214
217
|
|
215
218
|
if (topic.endsWith('/messages')) {
|
@@ -530,9 +533,38 @@ class WebSocketServer {
|
|
530
533
|
pubSubServer.handlePublishMessageToClientId (topic, events, clientId, "CREATE");
|
531
534
|
}});
|
532
535
|
|
533
|
-
})
|
536
|
+
})
|
534
537
|
|
535
|
-
} else {
|
538
|
+
} else if (topic.indexOf('/bots/') > -1) {
|
539
|
+
|
540
|
+
// var puId = urlSub[3];
|
541
|
+
// winston.info('puId: '+puId);
|
542
|
+
|
543
|
+
winston.debug('urlSub: '+urlSub);
|
544
|
+
|
545
|
+
var botId = urlSub[3];
|
546
|
+
winston.debug('botId: '+botId);
|
547
|
+
|
548
|
+
var query = { _id: botId, id_project: projectId };
|
549
|
+
|
550
|
+
winston.debug(' query: ',query);
|
551
|
+
|
552
|
+
Faq_kb.findOne(query)
|
553
|
+
.exec(function(err, bot) {
|
554
|
+
if (err) {
|
555
|
+
winston.error('WebSocket error getting bots', err);
|
556
|
+
return reject(err);
|
557
|
+
}
|
558
|
+
|
559
|
+
|
560
|
+
return resolve({publishFunction:function() {
|
561
|
+
// handlePublishMessageToClientId (topic, message, clientId, method) {
|
562
|
+
pubSubServer.handlePublishMessageToClientId (topic, bot, clientId, "CREATE");
|
563
|
+
}});
|
564
|
+
|
565
|
+
});
|
566
|
+
|
567
|
+
} else {
|
536
568
|
|
537
569
|
//request/id
|
538
570
|
|
@@ -785,6 +817,41 @@ class WebSocketServer {
|
|
785
817
|
});
|
786
818
|
|
787
819
|
|
820
|
+
|
821
|
+
|
822
|
+
|
823
|
+
|
824
|
+
|
825
|
+
|
826
|
+
var botUpdateKey = 'faqbot.update';
|
827
|
+
if (botEvent.queueEnabled) {
|
828
|
+
botUpdateKey = 'faqbot.update.queue.pubsub';
|
829
|
+
}
|
830
|
+
|
831
|
+
winston.info('botUpdateKey: ' + botUpdateKey);
|
832
|
+
botEvent.on(botUpdateKey, async function(bot) {
|
833
|
+
setImmediate(async () => {
|
834
|
+
|
835
|
+
// TODO setImmediate(() => {
|
836
|
+
|
837
|
+
let botJSON = Object.assign({}, bot);
|
838
|
+
|
839
|
+
if (bot.toObject) {
|
840
|
+
botJSON = bot.toObject();
|
841
|
+
}
|
842
|
+
|
843
|
+
let topic = '/'+bot.id_project+'/bots/'+bot._id;
|
844
|
+
winston.info('botEvent websocket server: '+botUpdateKey + " on topic " + topic , botJSON);
|
845
|
+
|
846
|
+
|
847
|
+
pubSubServer.handlePublishMessage (topic, botJSON, undefined, true, "UPDATE");
|
848
|
+
});
|
849
|
+
});
|
850
|
+
|
851
|
+
|
852
|
+
|
853
|
+
|
854
|
+
|
788
855
|
// https://github.com/websockets/ws/blob/master/examples/express-session-parse/index.js
|
789
856
|
|
790
857
|
|