@tiledesk/tiledesk-server 2.4.8 → 2.4.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -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" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
3
-
4
- <head>
5
- <meta name="viewport" content="width=device-width" />
6
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
7
- <title>New email from Tiledesk</title>
8
-
9
- <style type="text/css">
10
- img {
11
- max-width: 100%;
12
- margin-left:16px;
13
- text-align:center !important;
14
- }
15
- img.CToWUd {
16
- margin-bottom: 16px;
17
- max-width: 200px !important;
18
- width: 200px !important;
19
- min-width: 200px !important;
20
- outline: none;
21
- text-decoration: none;
22
- border: none;
23
- height: auto;
24
- margin-left: 0px;
25
- }
26
- body {
27
- -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; width: 100% !important; height: 100%; line-height: 1.6em;
28
- }
29
- body {
30
- background-color: #f6f6f6;
31
- }
32
-
33
- @media only screen and (max-width: 640px) {
34
- body {
35
- padding: 0 !important;
36
- }
37
- h1 {
38
- font-weight: 800 !important; margin: 20px 0 5px !important;
39
- text-align:center !important;
40
- }
41
- h2 {
42
- font-weight: 800 !important; margin: 20px 0 5px !important;
43
- }
44
- h3 {
45
- font-weight: 800 !important; margin: 20px 0 5px !important;
46
- }
47
- h4 {
48
- font-weight: 800 !important; margin: 20px 0 5px !important;
49
- }
50
- h1 {
51
- font-size: 22px !important;
52
- }
53
- h2 {
54
- font-size: 18px !important;
55
- }
56
- h3 {
57
- font-size: 16px !important;
58
- }
59
- .container {
60
- padding: 0 !important; width: 100% !important;
61
- }
62
- .content {
63
- padding: 0 !important;
64
- }
65
- .content-wrap {
66
- padding: 10px !important;
67
- }
68
- .invoice {
69
- width: 100% !important;
70
- }
71
- }
72
- </style>
73
- </head>
74
-
75
- <body itemscope itemtype="http://schema.org/EmailMessage" 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;" bgcolor="#f6f6f6">
76
-
77
- <table class="body-wrap" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; width: 100%; background-color: #f6f6f6; margin: 0;" bgcolor="#f6f6f6">
78
- <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
79
- <td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0;" valign="top"></td>
80
- <td class="container" width="600" 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;" valign="top">
81
- <div class="content" 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;">
82
- <table class="main" width="100%" cellpadding="0" cellspacing="0" 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;" bgcolor="#fff">
83
-
84
- <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
85
-
86
- <div style="text-align:center">
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
- </div>
91
- </tr>
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
- <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
106
- <td class="content-wrap" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 20px;" valign="top">
107
- <table width="100%" cellpadding="0" cellspacing="0" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
108
-
109
- <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
110
- <td class="content-block" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0;" valign="top">
111
- <strong style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">Hi {{savedUser.firstname}} {{savedUser.lastname}},</strong>
112
- <!-- <br> welcome on Tiledesk.com. -->
113
- <br><br> Thank you for signin up with Tiledesk.
114
- <br><br> To complete the setup, <span><a href="{{baseScope.baseUrl}}/#/verify/email/{{savedUser._id}}"> click here to verify your email address. </a> </span>
115
- <br><br>Give us your feedback! We need your advice. Send an email to <a href="mailto:info@tiledesk.com">info@tiledesk.com</a>
116
- <br><br> The Tiledesk Team
117
- </td>
118
- </tr>
119
-
120
- <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
121
- <td class="content-block" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0;" valign="top">
122
- </td>
123
- </tr>
124
- </table>
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
- <div class="footer" 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;">
129
- <table width="100%" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
130
- <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
131
- <td class="aligncenter content-block" 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;" align="center" valign="top">
132
- <span><a href="http://www.tiledesk.com" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 12px; color: #999; text-decoration: underline; margin: 0;" > Tiledesk.com </a></span>
133
- <br><span><a href="%unsubscribe_url%" 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>
134
- </td>
135
- </tr>
136
- </table>
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; align-items: center;">
187
+ <span>Powered by </span>
188
+ <span style="display: flex;"><img
189
+ src="https://tiledesk.com/wp-content/uploads/2023/05/tiledesk-solo_logo_new_gray.png" width="15"
190
+ height="15" style="margin-left: 6px;" /></span>
191
+ <span style="font-weight: bold; margin-left: 2px;">Tiledesk</span>
137
192
  </div>
138
- </div>
139
- </td>
140
- <td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0;" valign="top"></td>
141
- </tr>
142
- </table>
143
- </body>
144
- </html>
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:'Project_user not found for projectid ' + projectId});
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