@tiledesk/tiledesk-server 2.2.39 → 2.3.1-8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. package/CHANGELOG.md +121 -0
  2. package/LICENSE +14 -657
  3. package/README.md +17 -3
  4. package/app.js +21 -60
  5. package/channels/chat21/chat21Handler.js +18 -3
  6. package/channels/chat21/chat21WebHook.js +31 -15
  7. package/channels/chat21/package-lock.json +663 -706
  8. package/channels/chat21/package.json +2 -2
  9. package/deploy.sh +2 -0
  10. package/event/botEvent.js +1 -1
  11. package/event/subscriptionEvent.js +11 -0
  12. package/fonts/Roboto-Italic.ttf +0 -0
  13. package/fonts/Roboto-Medium.ttf +0 -0
  14. package/fonts/Roboto-MediumItalic.ttf +0 -0
  15. package/fonts/Roboto-Regular.ttf +0 -0
  16. package/middleware/ipFilter.js +220 -0
  17. package/middleware/passport.js +11 -2
  18. package/models/lead.js +2 -0
  19. package/models/project.js +10 -0
  20. package/models/project_user.js +4 -0
  21. package/models/request.js +50 -12
  22. package/models/subscriptionLog.js +34 -0
  23. package/models/tagLibrary.js +42 -0
  24. package/package.json +6 -12
  25. package/pubmodules/activities/activityArchiver.js +314 -0
  26. package/pubmodules/activities/index.js +3 -0
  27. package/pubmodules/activities/models/activity.js +88 -0
  28. package/pubmodules/activities/routes/activity.js +710 -0
  29. package/pubmodules/activities/test/activityRoute.js +85 -0
  30. package/pubmodules/analytics/analytics.js +1719 -0
  31. package/pubmodules/analytics/index.js +3 -0
  32. package/pubmodules/canned/cannedResponse.js +55 -0
  33. package/pubmodules/canned/cannedResponseRoute.js +163 -0
  34. package/pubmodules/canned/index.js +3 -0
  35. package/pubmodules/emailNotification/requestNotification.js +215 -28
  36. package/pubmodules/events/eventRoute.js +37 -7
  37. package/pubmodules/messageActions/messageActionsInterceptor.js +4 -2
  38. package/pubmodules/pubModulesManager.js +129 -5
  39. package/pubmodules/rasa/listener.js +5 -5
  40. package/pubmodules/rules/conciergeBot.js +4 -4
  41. package/pubmodules/scheduler/tasks/closeAgentUnresponsiveRequestTask.js +3 -1
  42. package/pubmodules/scheduler/tasks/closeBotUnresponsiveRequestTask.js +3 -1
  43. package/pubmodules/tilebot/index.js +11 -0
  44. package/pubmodules/tilebot/listener.js +69 -0
  45. package/pubmodules/trigger/default.js +271 -0
  46. package/pubmodules/trigger/event/actionEventEmitter.js +10 -0
  47. package/pubmodules/trigger/event/flowEventEmitter.js +10 -0
  48. package/pubmodules/trigger/event/triggerEventEmitter.js +10 -0
  49. package/pubmodules/trigger/index.js +3 -0
  50. package/pubmodules/trigger/models/trigger.js +149 -0
  51. package/pubmodules/trigger/rulesTrigger.js +1181 -0
  52. package/pubmodules/trigger/start.js +118 -0
  53. package/pubmodules/trigger/triggerRoute.js +150 -0
  54. package/routes/auth.js +7 -2
  55. package/routes/department.js +51 -0
  56. package/routes/faq.js +7 -0
  57. package/routes/faq_kb.js +1 -1
  58. package/routes/group.js +140 -0
  59. package/routes/lead.js +24 -1
  60. package/routes/message.js +6 -3
  61. package/routes/project.js +118 -0
  62. package/routes/project_user.js +9 -0
  63. package/routes/public-request.js +280 -2
  64. package/routes/request.js +122 -16
  65. package/routes/subscription.js +140 -0
  66. package/routes/tag.js +138 -0
  67. package/routes/user-request.js +3 -2
  68. package/routes/users.js +1 -1
  69. package/routes/widget.js +80 -3
  70. package/routes/widgetLoader.js +31 -0
  71. package/services/banUserNotifier.js +86 -0
  72. package/services/emailService.js +189 -11
  73. package/services/faqService.js +2 -2
  74. package/services/geoService.js +30 -4
  75. package/services/leadService.js +2 -0
  76. package/services/modulesManager.js +7 -188
  77. package/services/requestService.js +364 -6
  78. package/services/subscriptionNotifier.js +485 -0
  79. package/template/email/assignedEmailMessage.html +1 -1
  80. package/template/email/assignedRequest.html +1 -1
  81. package/template/email/newMessage.html +1 -1
  82. package/template/email/newMessageFollower.html +236 -0
  83. package/template/email/passwordChanged.html +1 -1
  84. package/template/email/pooledEmailMessage.html +1 -1
  85. package/template/email/pooledRequest.html +1 -1
  86. package/template/email/resetPassword.html +2 -2
  87. package/template/email/ticket.html +1 -1
  88. package/test/cannedRoute.js +166 -0
  89. package/test/messageRoute.js +69 -0
  90. package/test/requestService.js +3 -1
  91. package/utils/orgUtil.js +3 -3
  92. package/views/messages.jade +2 -2
  93. package/websocket/webSocketServer.js +23 -5
@@ -0,0 +1,236 @@
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 Ticket from TileDesk</title>
8
+
9
+ <style type="text/css">
10
+ img {
11
+ max-width: 100%;
12
+ margin-left:16px;
13
+ margin-bottom:16px;
14
+ text-align:center !important;
15
+ }
16
+ body {
17
+ -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; width: 100% !important; height: 100%; line-height: 1.6em;
18
+ }
19
+ body {
20
+ background-color: #f6f6f6;
21
+ }
22
+
23
+ @media only screen and (max-width: 640px) {
24
+ body {
25
+ padding: 0 !important;
26
+ }
27
+ h1 {
28
+ font-weight: 800 !important; margin: 20px 0 5px !important;
29
+ text-align:center !important;
30
+ }
31
+ h2 {
32
+ font-weight: 800 !important; margin: 20px 0 5px !important;
33
+ }
34
+ h3 {
35
+ font-weight: 800 !important; margin: 20px 0 5px !important;
36
+ }
37
+ h4 {
38
+ font-weight: 800 !important; margin: 20px 0 5px !important;
39
+ }
40
+ h1 {
41
+ font-size: 22px !important;
42
+ }
43
+ h2 {
44
+ font-size: 18px !important;
45
+ }
46
+ h3 {
47
+ font-size: 16px !important;
48
+ }
49
+ .container {
50
+ padding: 0 !important; width: 100% !important;
51
+ }
52
+ .content {
53
+ padding: 0 !important;
54
+ }
55
+ .content-wrap {
56
+ padding: 10px !important;
57
+ }
58
+ .invoice {
59
+ width: 100% !important;
60
+ }
61
+ }
62
+ </style>
63
+ </head>
64
+
65
+ <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">
66
+
67
+ {{#if baseScope.replyEnabled}}
68
+ <div>\# Please type your reply above this line \#</div>
69
+ {{/if}}
70
+
71
+ <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">
72
+
73
+ <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
74
+ <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">
75
+
76
+ <div style="text-align:center">
77
+ <a href="http://www.tiledesk.com" style="color:#2daae1;font-weight:bold;text-decoration:none;word-break:break-word" target="_blank">
78
+ <img src="https://tiledesk.com/wp-content/uploads/2022/07/tiledesk_v2.png" style="width:20%;outline:none;text-decoration:none;border:none;min-height:36px" class="CToWUd">
79
+ </a>
80
+ </div>
81
+ </td>
82
+ </tr>
83
+
84
+ <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
85
+
86
+ <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">
87
+ <div>
88
+ <h2>You are a follower of the ticket number: #{{message.request.ticket_id}}</h2>
89
+ </div>
90
+
91
+ </td>
92
+ </tr>
93
+
94
+ <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
95
+ <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">
96
+ <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;">
97
+
98
+
99
+ <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
100
+ <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; padding: 0 0 20px;" valign="top">
101
+ Sender: <strong style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">{{message.senderFullname}}</strong>
102
+ </td>
103
+ </tr>
104
+
105
+
106
+
107
+ <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
108
+ <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; padding: 0 0 20px;" valign="top">
109
+ {{#ifEquals message.type "text"}}
110
+ <div style="white-space: pre-wrap;">{{{msgText}}}</div>
111
+ {{/ifEquals}}
112
+ {{#ifEquals message.type "image"}}
113
+ <img src="{{message.metadata.src}}"/>
114
+ {{#if msgText}}
115
+ <div style="white-space: pre-wrap;">{{{msgText}}}</div>
116
+ {{/if}}
117
+ {{/ifEquals}}
118
+ {{#ifEquals message.type "file"}}
119
+ <a href="{{message.metadata.src}}">{{message.metadata.name}}</a>
120
+ {{/ifEquals}}
121
+ {{#ifEquals message.type "frame"}}
122
+ <a href="{{message.metadata.src}}">{{message.metadata.name}}</a>
123
+ {{#if msgText}}
124
+ <div style="white-space: pre-wrap;">{{{msgText}}}</div>
125
+ {{/if}}
126
+ {{/ifEquals}}
127
+
128
+ {{#if message.attributes}}
129
+ {{#if message.attributes.attachment}}
130
+ {{#if message.attributes.attachment.buttons}}
131
+ {{#each message.attributes.attachment.buttons}}
132
+ {{#ifEquals this.type "url"}}
133
+ <li><a href="{{this.link}}" class="dynamic_button">{{this.value}}</a></li>
134
+ {{else}}
135
+ <li><a href="mailto:{{../message.request.request_id}}@{{../baseScope.inboundDomain}}?subject=Re:%20{{../message.request.subject}}&body={{this.value}}" class="dynamic_button">{{this.value}}</a></li>
136
+ {{/ifEquals}}
137
+ {{/each}}
138
+
139
+
140
+ {{/if}}
141
+ {{/if}}
142
+ {{/if}}
143
+
144
+ <!-- {{#if message.attributes.intent_info}}
145
+ {{#if message.attributes.intent_info.others}}
146
+ Others:
147
+ {{#each message.attributes.intent_info.others}}
148
+ <li><span>{{this.answer}}</span></li>
149
+ {{/each}}
150
+ {{/if}}
151
+ {{/if}} -->
152
+
153
+
154
+
155
+
156
+
157
+ </td>
158
+ </tr>
159
+
160
+
161
+
162
+
163
+
164
+
165
+ <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
166
+ <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; padding: 0 0 20px;" valign="top">
167
+ Project name : <strong style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">{{project.name}}</strong>
168
+ </td>
169
+ </tr>
170
+
171
+
172
+ <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
173
+ <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; padding: 0 0 20px;" valign="top">
174
+ Department name : <strong style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">{{message.request.department.name}}</strong>
175
+ </td>
176
+ </tr>
177
+
178
+ <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
179
+ <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; padding: 0 0 20px;" valign="top">
180
+ Source page : <strong style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">{{message.request.sourcePage}}</strong>
181
+ </td>
182
+ </tr>
183
+
184
+ <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
185
+ <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; padding: 0 0 20px;" valign="top">
186
+ Contact name : <strong style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">{{message.request.lead.fullname}}</strong>
187
+ </td>
188
+ </tr>
189
+
190
+
191
+
192
+
193
+ <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
194
+ <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; padding: 0 0 20px;" valign="top">
195
+ Channel : <strong style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
196
+
197
+ {{#ifEquals message.request.channel.name "chat21"}}
198
+ Chat
199
+ {{else}}
200
+ {{message.request.channel.name}}
201
+ {{/ifEquals}}
202
+
203
+
204
+ </strong>
205
+ </td>
206
+ </tr>
207
+
208
+
209
+
210
+ <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
211
+ <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; padding: 0 0 20px;" valign="top">
212
+ Priority : <strong style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">{{message.request.priority}}</strong>
213
+ </td>
214
+ </tr>
215
+
216
+
217
+ <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
218
+ <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; padding: 0 0 20px;" valign="top">
219
+ </td>
220
+ </tr>
221
+ </table>
222
+ </td>
223
+ </tr>
224
+ </table>
225
+ <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;">
226
+ <table width="100%" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
227
+ <tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
228
+ <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; padding: 0 0 20px;" align="center" valign="top">
229
+ <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>
230
+ <!-- <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> -->
231
+ </td>
232
+ </tr>
233
+ </table>
234
+
235
+ </body>
236
+ </html>
@@ -72,7 +72,7 @@
72
72
 
73
73
  <div style="text-align:center">
74
74
  <a href="http://www.tiledesk.com" style="color:#2daae1;font-weight:bold;text-decoration:none;word-break:break-word" target="_blank">
75
- <img src="https://tiledesk.com/tiledesk-logo-x1.png" style="width:50%;outline:none;text-decoration:none;border:none;" class="CToWUd">
75
+ <img src="https://tiledesk.com/wp-content/uploads/2022/07/tiledesk_v2.png" style="width:50%;outline:none;text-decoration:none;border:none;" class="CToWUd">
76
76
  </a>
77
77
  </div>
78
78
  <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">
@@ -82,7 +82,7 @@
82
82
 
83
83
  <div style="text-align:center">
84
84
  <a href="http://www.tiledesk.com" style="color:#2daae1;font-weight:bold;text-decoration:none;word-break:break-word" target="_blank">
85
- <img src="https://tiledesk.com/tiledesk-logo-x1.png" style="width:10%;outline:none;text-decoration:none;border:none;min-height:36px" class="CToWUd">
85
+ <img src="https://tiledesk.com/wp-content/uploads/2022/07/tiledesk_v2.png" style="width:10%;outline:none;text-decoration:none;border:none;min-height:36px" class="CToWUd">
86
86
  </a>
87
87
  </div>
88
88
  </tr>
@@ -82,7 +82,7 @@
82
82
 
83
83
  <div style="text-align:center">
84
84
  <a href="http://www.tiledesk.com" style="color:#2daae1;font-weight:bold;text-decoration:none;word-break:break-word" target="_blank">
85
- <img src="https://tiledesk.com/tiledesk-logo-x1.png" style="width:10%;outline:none;text-decoration:none;border:none;min-height:36px" class="CToWUd">
85
+ <img src="https://tiledesk.com/wp-content/uploads/2022/07/tiledesk_v2.png" style="max-width:200px;outline:none;text-decoration:none;border:none;height:auto;margin-left:0px;" class="CToWUd">
86
86
  </a>
87
87
  </div>
88
88
  </tr>
@@ -71,7 +71,7 @@
71
71
 
72
72
  <div style="text-align:center">
73
73
  <a href="http://www.tiledesk.com" style="color:#2daae1;font-weight:bold;text-decoration:none;word-break:break-word" target="_blank">
74
- <img src="https://tiledesk.com/tiledesk-logo-x1.png" style="width:50%;outline:none;text-decoration:none;border:none;" class="CToWUd">
74
+ <img src="https://tiledesk.com/wp-content/uploads/2022/07/tiledesk_v2.png" style="width:50%;outline:none;text-decoration:none;border:none;" class="CToWUd">
75
75
  </a>
76
76
  </div>
77
77
 
@@ -99,7 +99,7 @@
99
99
  Reset My Password
100
100
  </a>
101
101
  </div>
102
- <br><br>If you did not forgot your password you can safely ignore this email.
102
+ <br><br>If you didn't forget your password you can safely ignore this email.
103
103
  <br><br><span style="font-size:12px; ">If you're having trouble clicking the "Reset My Password" button, copy and paste the URL below into your web browser: </span>
104
104
  <br>
105
105
  <span style="color:#03a5e8; font-size:12px; ">{{baseScope.baseUrl}}/#/resetpassword/{{resetPswRequestId}}</span>
@@ -75,7 +75,7 @@
75
75
 
76
76
  <div style="text-align:center">
77
77
  <a href="http://www.tiledesk.com" style="color:#2daae1;font-weight:bold;text-decoration:none;word-break:break-word" target="_blank">
78
- <img src="https://tiledesk.com/tiledesk-logo-x1.png" style="width:20%;outline:none;text-decoration:none;border:none;min-height:36px" class="CToWUd">
78
+ <img src="https://tiledesk.com/wp-content/uploads/2022/07/tiledesk_v2.png" style="width:20%;outline:none;text-decoration:none;border:none;min-height:36px" class="CToWUd">
79
79
  </a>
80
80
  </div>
81
81
  </td>
@@ -0,0 +1,166 @@
1
+ //During the test the env variable is set to test
2
+ process.env.NODE_ENV = 'test';
3
+
4
+ //Require the dev-dependencies
5
+ let chai = require('chai');
6
+ let expect = require('chai').expect;
7
+
8
+ let chaiHttp = require('chai-http');
9
+ let server = require('../app');
10
+ const projectService = require('../services/projectService');
11
+ const userService = require('../services/userService');
12
+ var RoleConstants = require("../models/roleConstants");
13
+ const Project_user = require('../models/project_user');
14
+ let should = chai.should();
15
+
16
+
17
+
18
+ chai.use(chaiHttp);
19
+
20
+ describe('CannedRoute', () => {
21
+
22
+ it('new canned by owner/admin', (done) => {
23
+ var email = "test-signup-" + Date.now() + "@email.com";
24
+ var pwd = "pwd";
25
+
26
+ userService.signup(email, pwd, "Test Firstname", "Test Lastname").then(savedUser => {
27
+ projectService.create("test1", savedUser._id).then(savedProject => {
28
+
29
+ chai.request(server)
30
+ .post('/' + savedProject._id + '/canned/')
31
+ .auth(email, pwd)
32
+ .set('content-type', 'application/json')
33
+ .send({ "title": "Test Title", "text": "Test Text" })
34
+ .end((err, res) => {
35
+ console.log("res.body", res.body);
36
+ res.should.have.status(200);
37
+ res.body.should.be.a('object');
38
+ res.body.should.have.property('title').eql("Test Title");
39
+ res.body.should.have.property('text').eql("Test Text");
40
+ res.body.should.have.property('createdBy').eql(savedUser._id.toString());
41
+ res.body.should.have.property('shared').eql(true);
42
+
43
+ done();
44
+ })
45
+ })
46
+ })
47
+ })
48
+
49
+ it('new canned by agent', (done) => {
50
+ var email = "test-signup-" + Date.now() + "@email.com";
51
+ var pwd = "pwd";
52
+
53
+ userService.signup(email, pwd, "Test Firstname", "Test Lastname").then(savedUser => {
54
+ projectService.create("test1", savedUser._id).then(savedProject => {
55
+
56
+ console.log("RoleConstants.AGENT: ", RoleConstants.AGENT);
57
+ Project_user.findOneAndUpdate({id_project: savedProject._id, id_user: savedUser._id }, { role: RoleConstants.AGENT }, function(err, savedProject_user){
58
+ chai.request(server)
59
+ .post('/' + savedProject._id + '/canned/')
60
+ .auth(email, pwd)
61
+ .set('content-type', 'application/json')
62
+ .send({ title: "Test Title", text: "Test Text" })
63
+ .end((err, res) => {
64
+ console.log("res.body", res.body);
65
+ res.body.should.be.a('object');
66
+ res.body.should.have.property('title').eql("Test Title");
67
+ res.body.should.have.property('text').eql("Test Text");
68
+ res.body.should.have.property('createdBy').eql(savedUser._id.toString());
69
+ res.body.should.have.property('shared').eql(false);
70
+
71
+ done();
72
+ })
73
+ })
74
+ })
75
+ })
76
+ })
77
+
78
+ it('get canned', (done) => {
79
+
80
+ var email_owner = "owner-signup-" + Date.now() + "@email.com";
81
+ var email_agent = "agent-signup-" + Date.now() + "@email.com";
82
+ var pwd = "pwd";
83
+
84
+ userService.signup(email_owner, pwd, "Owner Firstname", "Owner Lastname").then(savedOwner => {
85
+ userService.signup(email_agent, pwd, "Agent Firstname", "Agent Lastname").then(savedAgent => {
86
+ projectService.create("test1", savedOwner._id).then(savedProject => {
87
+
88
+ // invite Agent on savedProject (?)
89
+ chai.request(server)
90
+ .post('/' + savedProject._id + "/project_users/invite")
91
+ .auth(email_owner, pwd)
92
+ .set('content-type', 'application/json')
93
+ .send({ email: email_agent, role: "agent", userAvailable: false })
94
+ .end((err, res) => {
95
+ console.log("res.boy", res.body)
96
+ res.should.have.status(200);
97
+
98
+
99
+ chai.request(server)
100
+ .post('/' + savedProject._id + "/canned/")
101
+ .auth(email_owner, pwd)
102
+ .set('content-type', 'application/json')
103
+ .send({ title: "Test1 Title", text: "Test1 Text" })
104
+ .end((err, res) => {
105
+
106
+ console.log("res.body", res.body);
107
+ res.should.have.status(200);
108
+ res.body.should.be.a('object');
109
+
110
+ chai.request(server)
111
+ .post('/' + savedProject._id + "/canned/")
112
+ .auth(email_agent, pwd)
113
+ .set('content-type', 'application/json')
114
+ .send({ title: "Test2 Title", text: "Test2 Text" })
115
+ .end((err, res) => {
116
+
117
+ console.log("res.body", res.body);
118
+ res.should.have.status(200);
119
+ res.body.should.be.a('object');
120
+
121
+ chai.request(server)
122
+ .get('/' + savedProject._id + "/canned/")
123
+ .auth(email_owner, pwd)
124
+ .set('content-type', 'application-json')
125
+ .send()
126
+ .end((err, res) => {
127
+
128
+ console.log("res.body", res.body);
129
+ res.should.have.status(200);
130
+ //res.body.should.be.a('array');
131
+
132
+ expect(res.body).to.be.an('array')
133
+ expect(res.body.length).to.equal(1);
134
+
135
+ chai.request(server)
136
+ .get('/' + savedProject._id + "/canned/")
137
+ .auth(email_agent, pwd)
138
+ .set('content-type', 'application-json')
139
+ .send()
140
+ .end((err, res) => {
141
+
142
+ console.log("res.body", res.body);
143
+ console.log("\n --> body.length", res.body.length);
144
+ res.should.have.status(200);
145
+ //res.body.should.be.a('array');
146
+
147
+ expect(res.body).to.be.an('array')
148
+ expect(res.body.length).to.equal(2);
149
+
150
+ done();
151
+
152
+ })
153
+
154
+
155
+ })
156
+
157
+
158
+ })
159
+
160
+ })
161
+ })
162
+ })
163
+ })
164
+ })
165
+ }).timeout(5000);
166
+ })
@@ -720,6 +720,75 @@ it('createWithPriority', function (done) {
720
720
 
721
721
 
722
722
 
723
+
724
+ // mocha test/messageRoute.js --grep 'createSimpleWithFollowers'
725
+
726
+ it('createSimpleWithFollowers', function (done) {
727
+ // this.timeout(10000);
728
+
729
+ var email = "test-message-create-" + Date.now() + "@email.com";
730
+ var pwd = "pwd";
731
+
732
+ userService.signup( email ,pwd, "Test Firstname", "Test lastname").then(function(savedUser) {
733
+ projectService.createAndReturnProjectAndProjectUser("message-create", savedUser._id).then(function(savedProjectAndPU) {
734
+
735
+ var savedProject = savedProjectAndPU.project;
736
+
737
+ chai.request(server)
738
+ .post('/'+ savedProject._id + '/requests/req123-createSimpleWithFollowers/messages')
739
+ .auth(email, pwd)
740
+ .set('content-type', 'application/json')
741
+ .send({"text":"text", "followers": [savedProjectAndPU.project_user._id.toString()]})
742
+ .end(function(err, res) {
743
+ //console.log("res", res);
744
+ console.log("res.body", JSON.stringify(res.body));
745
+ res.should.have.status(200);
746
+ res.body.should.be.a('object');
747
+
748
+ expect(res.body.sender).to.equal(savedUser._id.toString());
749
+ // expect(res.body.sender).to.equal(savedProjectAndPU.project_user._id.toString());
750
+ // expect(res.body.senderFullname).to.equal("senderFullname");
751
+ expect(res.body.recipient).to.equal("req123-createSimpleWithFollowers");
752
+ expect(res.body.text).to.equal("text");
753
+ expect(res.body.id_project).to.equal(savedProject._id.toString());
754
+ expect(res.body.createdBy).to.equal(savedUser._id.toString());
755
+ expect(res.body.status).to.equal(0);
756
+
757
+ expect(res.body.request.request_id).to.equal("req123-createSimpleWithFollowers");
758
+ expect(res.body.request.requester._id).to.equal(savedProjectAndPU.project_user._id.toString());
759
+ // expect(res.body.request.requester_id).to.equal("sender");
760
+ expect(res.body.request.first_text).to.equal("text");
761
+ expect(res.body.request.id_project).to.equal(savedProject._id.toString());
762
+ expect(res.body.request.createdBy).to.equal(savedUser._id.toString());
763
+
764
+ // expect(res.body.request.messages_count).to.equal(1);
765
+
766
+ expect(res.body.request.status).to.equal(200);
767
+ expect(res.body.request.snapshot.agents.length).to.equal(1);
768
+ expect(res.body.request.participants.length).to.equal(1);
769
+ expect(res.body.request.department).to.not.equal(null);
770
+ expect(res.body.request.lead).to.not.equal(null);
771
+
772
+ expect(res.body.channel_type).to.equal("group");
773
+ expect(res.body.channel.name).to.equal("chat21");
774
+ expect(res.body.request.channel.name).to.equal("chat21");
775
+
776
+
777
+ expect(res.body.request.location).to.equal(undefined);
778
+
779
+ expect(res.body.request.followers[0]).to.equal(savedProjectAndPU.project_user._id.toString());
780
+
781
+
782
+ done();
783
+ });
784
+ });
785
+ });
786
+ });
787
+
788
+
789
+
790
+
791
+
723
792
  it('getall', function (done) {
724
793
  // this.timeout(10000);
725
794
 
@@ -686,13 +686,15 @@ describe('RequestService', function () {
686
686
  savedProject._id, "5badfe5d553d1844ad654072"),
687
687
  messageService.create("5badfe5d553d1844ad654072", "test sender", savedRequest.request_id, "hello2",
688
688
  savedProject._id, "5badfe5d553d1844ad654072")]).then(function(all) {
689
- requestService.closeRequestByRequestId(savedRequest.request_id, savedProject._id).then(function(closedRequest) {
689
+ // closeRequestByRequestId(request_id, id_project, skipStatsUpdate, notify, closed_by)
690
+ requestService.closeRequestByRequestId(savedRequest.request_id, savedProject._id, false, true, "user1").then(function(closedRequest) {
690
691
  winston.debug("resolve closedRequest", closedRequest.toObject());
691
692
  expect(closedRequest.status).to.equal(1000);
692
693
  expect(closedRequest.closed_at).to.not.equal(null);
693
694
  expect(closedRequest.transcript).to.contains("hello1");
694
695
  expect(closedRequest.transcript).to.contains("hello2");
695
696
  expect(closedRequest.snapshot.agents).to.equal(undefined);
697
+ expect(closedRequest.closed_by).to.equal("user1");
696
698
 
697
699
  done();
698
700
  }).catch(function(err){
package/utils/orgUtil.js CHANGED
@@ -36,10 +36,10 @@ class OrgUtil {
36
36
  // winston.info("host: "+ host );
37
37
 
38
38
  let origin = req.get('origin');
39
- winston.info("origin: "+ origin );
39
+ winston.debug("origin: "+ origin );
40
40
 
41
41
  // winston.info("email: " + email.baseUrl);
42
- winston.info("this.ORGANIZATION_BASE_URL: " + this.ORGANIZATION_BASE_URL);
42
+ winston.debug("this.ORGANIZATION_BASE_URL: " + this.ORGANIZATION_BASE_URL);
43
43
  // global.organizationBaseUrl
44
44
  // if (host !=email.baseUrl ) {
45
45
  if (origin && origin.indexOf(this.ORGANIZATION_BASE_URL)>-1) {
@@ -49,7 +49,7 @@ class OrgUtil {
49
49
  winston.info("origin found: "+ origin );
50
50
  return origin;
51
51
  }
52
- winston.info("origin not found: "+ origin );
52
+ winston.debug("origin not found: "+ origin );
53
53
 
54
54
  // winston.info("host not found: "+ host );
55
55
  // if (host.indexOf("localhost1")>-1) {
@@ -2,7 +2,7 @@ extends layout
2
2
 
3
3
  block content
4
4
  div(class="transcript-container")
5
- img.className#IdName(src="https://tiledesk.com/tiledesk-logo-x1.png" alt="tiledesk logo")
5
+ img.className#IdName(src="https://tiledesk.com/wp-content/uploads/2022/07/tiledesk_v2.png" alt="tiledesk logo")
6
6
 
7
7
  div(class="transcript-wrapper")
8
8
  h1(class="transcript-title") Chat Transcript
@@ -10,7 +10,7 @@ block content
10
10
 
11
11
  each message in messages
12
12
  p(class="transcript-p")
13
- span(class="transcript-chat-date") [#{message.createdAt.toLocaleString('it', { timeZone: 'UTC' })}]
13
+ span(class="transcript-chat-date") [#{message.createdAt.toLocaleString('en', { timeZone: 'UTC' })}]
14
14
  span(class="transcript-chat-sender") #{message.senderFullname}:
15
15
  span(class="transcript-chat-msg") #{message.text}
16
16