@tiledesk/tiledesk-server 2.1.41 → 2.2.4
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/.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 +198 -1
- package/Dockerfile +1 -1
- package/Dockerfile-en +1 -1
- package/README.md +5 -7
- package/app.js +12 -1
- package/channels/chat21/chat21Contact.js +34 -8
- package/channels/chat21/chat21Handler.js +48 -5
- package/channels/chat21/chat21WebHook.js +34 -5
- package/channels/chat21/nativeauth.js +2 -2
- package/config/email.js +2 -1
- 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/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 +3 -3
- package/models/request.js +33 -3
- package/package.json +31 -28
- package/pubmodules/emailNotification/requestNotification.js +380 -62
- package/pubmodules/messageActions/messageActionsInterceptor.js +20 -7
- package/pubmodules/messageTransformer/index.js +1 -1
- package/pubmodules/messageTransformer/microLanguageAttributesTransformerInterceptor.js +67 -0
- package/pubmodules/pubModulesManager.js +66 -14
- package/pubmodules/rules/conciergeBot.js +81 -49
- package/routes/auth.js +34 -10
- package/routes/campaigns.js +117 -25
- package/routes/faq.js +19 -0
- package/routes/faq_kb.js +13 -4
- package/routes/faqpub.js +1 -1
- 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 +1103 -298
- package/services/faqBotHandler.js +176 -61
- package/services/faqBotSupport.js +181 -117
- package/services/faqService.js +17 -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 +78 -52
- package/template/email/ticket.txt +5 -1
- 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 +5 -5
- 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
- package/template/email/ticket-taking.txt +0 -7
package/template/email/test.html
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2
|
-
<html 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;">
|
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
3
|
|
4
4
|
<body>
|
5
5
|
Hi {{user.name}}, this is a test email from Tiledesk
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2
|
-
<html 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;">
|
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
3
|
|
4
4
|
<head>
|
5
5
|
<meta name="viewport" content="width=device-width" />
|
@@ -64,27 +64,28 @@
|
|
64
64
|
|
65
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
66
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
<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;">
|
67
|
+
{{#if baseScope.replyEnabled}}
|
68
|
+
<div>\# Please type your reply above this line \#</div>
|
69
|
+
{{/if}}
|
70
|
+
|
72
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">
|
73
72
|
|
74
73
|
<tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
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/tiledesk-logo-x1.png" style="width:20%;outline:none;text-decoration:none;border:none;min-height:36px" class="CToWUd">
|
79
|
+
</a>
|
80
|
+
</div>
|
81
|
+
</td>
|
81
82
|
</tr>
|
82
83
|
|
83
84
|
<tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
|
84
85
|
|
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">
|
86
87
|
<div>
|
87
|
-
<h2>Ticket</h2>
|
88
|
+
<h2>Ticket number: #{{message.request.ticket_id}}</h2>
|
88
89
|
</div>
|
89
90
|
|
90
91
|
</td>
|
@@ -95,47 +96,77 @@
|
|
95
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;">
|
96
97
|
|
97
98
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
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>
|
103
104
|
|
105
|
+
|
104
106
|
|
105
|
-
|
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}} -->
|
106
152
|
|
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
|
-
Project name : <strong style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">{{project.name}}</strong>
|
110
|
-
</td>
|
111
|
-
</tr>
|
112
|
-
|
113
|
-
<tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
|
114
|
-
<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">
|
115
|
-
Agent name : <strong style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">{{message.senderFullname}}</strong>
|
116
|
-
</td>
|
117
|
-
</tr>
|
118
153
|
|
119
154
|
|
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; padding: 0 0 20px;" valign="top">
|
122
|
-
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>
|
123
|
-
</td>
|
124
|
-
</tr> -->
|
125
155
|
|
126
|
-
|
127
156
|
|
128
|
-
|
129
|
-
|
130
|
-
<tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
|
131
|
-
<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">
|
157
|
+
</td>
|
158
|
+
</tr>
|
132
159
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
<tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
|
164
|
+
<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">
|
165
|
+
|
166
|
+
Click <a href="{{seamlessPage}}{{tokenQueryString}}">here</a> to continue by chat the conversation.
|
167
|
+
</td>
|
168
|
+
</tr>
|
137
169
|
|
138
|
-
|
139
170
|
|
140
171
|
|
141
172
|
<tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
|
@@ -151,15 +182,10 @@
|
|
151
182
|
<tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
|
152
183
|
<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">
|
153
184
|
<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>
|
154
|
-
<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>
|
185
|
+
<!-- <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> -->
|
155
186
|
</td>
|
156
187
|
</tr>
|
157
188
|
</table>
|
158
|
-
|
159
|
-
</div>
|
160
|
-
</td>
|
161
|
-
<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>
|
162
|
-
</tr>
|
163
|
-
</table>
|
189
|
+
|
164
190
|
</body>
|
165
191
|
</html>
|
@@ -1,7 +1,11 @@
|
|
1
|
-
|
1
|
+
\# Please type your reply above this line \#
|
2
|
+
|
3
|
+
Ticket number: #{{message.request.ticket_id}}
|
2
4
|
|
3
5
|
{{message.senderFullname}}
|
4
6
|
|
5
7
|
{{message.text}}
|
6
8
|
|
9
|
+
Continue the conversation by chat here: {{seamlessPage}}{{tokenQueryString}}
|
10
|
+
|
7
11
|
Powered by Tiledesk : https://tiledesk.com
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2
|
-
|
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
3
|
|
4
4
|
<head>
|
5
5
|
<meta name="viewport" content="width=device-width" />
|
package/test/authentication.js
CHANGED
@@ -87,6 +87,78 @@ describe('Authentication', () => {
|
|
87
87
|
|
88
88
|
|
89
89
|
|
90
|
+
|
91
|
+
|
92
|
+
it('signinValidation', (done) => {
|
93
|
+
|
94
|
+
|
95
|
+
// this.timeout();
|
96
|
+
|
97
|
+
var email = "test-signinko-" + Date.now() + "@email.com";
|
98
|
+
var pwd = "pwd";
|
99
|
+
|
100
|
+
|
101
|
+
chai.request(server)
|
102
|
+
.post('/auth/signin' )
|
103
|
+
.send()
|
104
|
+
.end((err, res) => {
|
105
|
+
//console.log("res", res);
|
106
|
+
console.log("res.body", res.body);
|
107
|
+
res.should.have.status(422);
|
108
|
+
|
109
|
+
|
110
|
+
done();
|
111
|
+
});
|
112
|
+
|
113
|
+
|
114
|
+
});
|
115
|
+
|
116
|
+
|
117
|
+
// mocha test/authentication.js --grep 'signinLowercase'
|
118
|
+
|
119
|
+
it('signinLowercase', (done) => {
|
120
|
+
|
121
|
+
|
122
|
+
// this.timeout();
|
123
|
+
|
124
|
+
var email = "Test-SigninKO-" + Date.now() + "@email.com";
|
125
|
+
var pwd = "pwd";
|
126
|
+
|
127
|
+
userService.signup( email ,pwd, "Test Firstname", "Test lastname").then(function(savedUser) {
|
128
|
+
|
129
|
+
chai.request(server)
|
130
|
+
.post('/auth/signin' )
|
131
|
+
.send({"email":email, "password":pwd})
|
132
|
+
.end((err, res) => {
|
133
|
+
console.log("res.body", res.body);
|
134
|
+
res.should.have.status(200);
|
135
|
+
res.body.should.be.a('object');
|
136
|
+
expect(res.body.success).to.equal(true);
|
137
|
+
expect(res.body.token).to.not.equal(null);
|
138
|
+
expect(res.body.user.email).to.equal(email.toLowerCase());
|
139
|
+
expect(res.body.user.password).to.equal(undefined);
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
chai.request(server)
|
144
|
+
.get('/users/' )
|
145
|
+
.auth(email, pwd)
|
146
|
+
.end((err, res) => {
|
147
|
+
console.log("res.body", res.body);
|
148
|
+
res.should.have.status(200);
|
149
|
+
res.body.should.be.a('object');
|
150
|
+
|
151
|
+
done();
|
152
|
+
});
|
153
|
+
|
154
|
+
});
|
155
|
+
|
156
|
+
});
|
157
|
+
|
158
|
+
});
|
159
|
+
});
|
160
|
+
|
161
|
+
|
90
162
|
});
|
91
163
|
|
92
164
|
|
@@ -129,6 +201,8 @@ describe('/signup', () => {
|
|
129
201
|
|
130
202
|
});
|
131
203
|
|
204
|
+
// mocha test/authentication.js --grep 'signupUpperCaseEmail'
|
205
|
+
|
132
206
|
|
133
207
|
it('signupUpperCaseEmail', (done) => {
|
134
208
|
|
@@ -153,9 +227,7 @@ describe('/signup', () => {
|
|
153
227
|
|
154
228
|
done();
|
155
229
|
});
|
156
|
-
|
157
|
-
|
158
|
-
|
230
|
+
|
159
231
|
});
|
160
232
|
|
161
233
|
|
@@ -184,7 +256,7 @@ describe('/signup', () => {
|
|
184
256
|
});
|
185
257
|
|
186
258
|
|
187
|
-
});
|
259
|
+
// });
|
188
260
|
|
189
261
|
|
190
262
|
|
@@ -379,6 +379,79 @@ it('signinJWt-userYESAudYesSubject', (done) => {
|
|
379
379
|
|
380
380
|
|
381
381
|
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
|
386
|
+
// // mocha test/authenticationJwt.js --grep 'signinJWt-Project-external-user-YESAudYesSubjectAndRole'
|
387
|
+
|
388
|
+
// it('signinJWt-Project-external-user-YESAudYesSubjectAndRole', (done) => {
|
389
|
+
|
390
|
+
|
391
|
+
// // this.timeout();
|
392
|
+
|
393
|
+
// var email = "test-signup-" + Date.now() + "@email.com";
|
394
|
+
// var pwd = "pwd";
|
395
|
+
|
396
|
+
// userService.signup( email ,pwd, "Test Firstname", "Test lastname").then(function(savedUser) {
|
397
|
+
// // create(name, createdBy, settings)
|
398
|
+
// projectService.create("test-signinJWt-user", savedUser._id).then(function(savedProject) {
|
399
|
+
|
400
|
+
// chai.request(server)
|
401
|
+
// .post('/'+ savedProject._id + '/keys/generate')
|
402
|
+
// .auth(email, pwd)
|
403
|
+
// .send()
|
404
|
+
// .end((err, res) => {
|
405
|
+
// //console.log("res", res);
|
406
|
+
// console.log("res.body", res.body);
|
407
|
+
// res.should.have.status(200);
|
408
|
+
// res.body.should.be.a('object');
|
409
|
+
// expect(res.body.jwtSecret).to.not.equal(null);
|
410
|
+
|
411
|
+
|
412
|
+
// var externalUserObj = {_id:"123",name:"andrea", surname:"leo",role : 'agent'};
|
413
|
+
|
414
|
+
// console.log("externalUserObj", externalUserObj);
|
415
|
+
|
416
|
+
|
417
|
+
// var signOptions = {
|
418
|
+
// subject: 'userexternal',
|
419
|
+
// audience: 'https://tiledesk.com/projects/'+savedProject._id ,
|
420
|
+
// };
|
421
|
+
|
422
|
+
|
423
|
+
// var jwtToken = jwt.sign(externalUserObj, res.body.jwtSecret,signOptions);
|
424
|
+
|
425
|
+
|
426
|
+
|
427
|
+
// console.log("jwtToken", jwtToken);
|
428
|
+
|
429
|
+
// chai.request(server)
|
430
|
+
// .get('/testauth/noentitycheck')
|
431
|
+
// .set('Authorization', 'JWT '+jwtToken)
|
432
|
+
// .send()
|
433
|
+
// .end((err, res) => {
|
434
|
+
// console.log("res.body", res.body);
|
435
|
+
// res.should.have.status(200);
|
436
|
+
|
437
|
+
// done();
|
438
|
+
// });
|
439
|
+
|
440
|
+
|
441
|
+
|
442
|
+
|
443
|
+
// });
|
444
|
+
|
445
|
+
|
446
|
+
|
447
|
+
|
448
|
+
|
449
|
+
// });
|
450
|
+
|
451
|
+
|
452
|
+
// });
|
453
|
+
// });
|
454
|
+
|
382
455
|
it('signinJWt-bot-YESAudYesSubject', (done) => {
|
383
456
|
|
384
457
|
|
@@ -389,8 +462,9 @@ it('signinJWt-userYESAudYesSubject', (done) => {
|
|
389
462
|
|
390
463
|
userService.signup( email ,pwd, "Test Firstname", "Test lastname").then(function(savedUser) {
|
391
464
|
// create(name, createdBy, settings)
|
392
|
-
projectService.create("test-signinJWt-user", savedUser._id).then(function(savedProject) {
|
393
|
-
|
465
|
+
projectService.create("test-signinJWt-user", savedUser._id).then(function(savedProject) {
|
466
|
+
// create(name, url, projectid, user_id, type, description, webhook_url, webhook_enabled, language) {
|
467
|
+
faqService.create("testbot", null, savedProject._id, savedUser._id).then(function(savedBot) {
|
394
468
|
var savedBotObj = savedBot.toObject();
|
395
469
|
console.log("savedBotObj", savedBotObj);
|
396
470
|
|
@@ -0,0 +1,226 @@
|
|
1
|
+
//During the test the env variable is set to test
|
2
|
+
process.env.NODE_ENV = 'test';
|
3
|
+
|
4
|
+
var User = require('../models/user');
|
5
|
+
var projectService = require('../services/projectService');
|
6
|
+
var Group = require('../models/group');
|
7
|
+
var userService = require('../services/userService');
|
8
|
+
|
9
|
+
//Require the dev-dependencies
|
10
|
+
let chai = require('chai');
|
11
|
+
let chaiHttp = require('chai-http');
|
12
|
+
let server = require('../app');
|
13
|
+
let should = chai.should();
|
14
|
+
var winston = require('../config/winston');
|
15
|
+
var jwt = require('jsonwebtoken');
|
16
|
+
// chai.config.includeStack = true;
|
17
|
+
|
18
|
+
var expect = chai.expect;
|
19
|
+
var assert = chai.assert;
|
20
|
+
|
21
|
+
chai.use(chaiHttp);
|
22
|
+
|
23
|
+
describe('CampaignsRoute', () => {
|
24
|
+
|
25
|
+
|
26
|
+
// mocha test/campaignsRoute.js --grep 'directSimpleNoOut'
|
27
|
+
|
28
|
+
it('directSimpleNoOut', function (done) {
|
29
|
+
|
30
|
+
var email = "test-message-create-" + Date.now() + "@email.com";
|
31
|
+
var pwd = "pwd";
|
32
|
+
|
33
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
34
|
+
projectService.createAndReturnProjectAndProjectUser("directSimple", savedUser._id).then(function (savedProjectAndPU) {
|
35
|
+
|
36
|
+
var savedProject = savedProjectAndPU.project;
|
37
|
+
var recipient = "5f8972c82db41c003473cb03";
|
38
|
+
|
39
|
+
chai.request(server)
|
40
|
+
.post('/' + savedProject._id + '/campaigns/direct')
|
41
|
+
.auth(email, pwd)
|
42
|
+
.set('content-type', 'application/json')
|
43
|
+
.send({ "text": "ciao", "recipient": recipient })
|
44
|
+
.end(function (err, res) {
|
45
|
+
//console.log("res", res);
|
46
|
+
console.log("res.body", res.body);
|
47
|
+
res.should.have.status(200);
|
48
|
+
res.body.should.be.a('object');
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
expect(res.body.success).to.equal(true);
|
53
|
+
|
54
|
+
|
55
|
+
done();
|
56
|
+
});
|
57
|
+
});
|
58
|
+
});
|
59
|
+
});
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
// mocha test/campaignsRoute.js --grep 'directSimple'
|
67
|
+
|
68
|
+
it('directSimple', function (done) {
|
69
|
+
|
70
|
+
var email = "test-message-create-" + Date.now() + "@email.com";
|
71
|
+
var pwd = "pwd";
|
72
|
+
|
73
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
74
|
+
projectService.createAndReturnProjectAndProjectUser("directSimple", savedUser._id).then(function (savedProjectAndPU) {
|
75
|
+
|
76
|
+
var savedProject = savedProjectAndPU.project;
|
77
|
+
var recipient = "5f8972c82db41c003473cb03";
|
78
|
+
|
79
|
+
chai.request(server)
|
80
|
+
.post('/' + savedProject._id + '/campaigns/direct')
|
81
|
+
.auth(email, pwd)
|
82
|
+
.set('content-type', 'application/json')
|
83
|
+
.send({ "text": "ciao", "recipient": recipient, returnobject: true })
|
84
|
+
.end(function (err, res) {
|
85
|
+
//console.log("res", res);
|
86
|
+
console.log("res.body", res.body);
|
87
|
+
res.should.have.status(200);
|
88
|
+
res.body.should.be.a('object');
|
89
|
+
|
90
|
+
expect(res.body.channel_type).to.equal("direct");
|
91
|
+
expect(res.body.senderFullname).to.equal("Test Firstname Test lastname");
|
92
|
+
expect(res.body.sender).to.equal(savedUser._id.toString());
|
93
|
+
expect(res.body.recipient).to.equal(recipient);
|
94
|
+
|
95
|
+
|
96
|
+
// expect(res.body.success).to.equal(true);
|
97
|
+
|
98
|
+
|
99
|
+
done();
|
100
|
+
});
|
101
|
+
});
|
102
|
+
});
|
103
|
+
});
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
// mocha test/campaignsRoute.js --grep 'directGroupIdNoOut'
|
109
|
+
|
110
|
+
it('directGroupIdNoOut', function (done) {
|
111
|
+
|
112
|
+
var email = "test-message-create-" + Date.now() + "@email.com";
|
113
|
+
var pwd = "pwd";
|
114
|
+
|
115
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
116
|
+
projectService.createAndReturnProjectAndProjectUser("directSimple", savedUser._id).then(function (savedProjectAndPU) {
|
117
|
+
|
118
|
+
var savedProject = savedProjectAndPU.project;
|
119
|
+
|
120
|
+
var userid = savedUser._id;
|
121
|
+
|
122
|
+
var email2 = "test-message-create-" + Date.now() + "@email.com";
|
123
|
+
userService.signup(email2, pwd, "Test Firstname", "Test lastname").then(function (savedUser2) {
|
124
|
+
|
125
|
+
var newGroup = new Group({
|
126
|
+
name: "group1",
|
127
|
+
// members: ["userid1", "userid2"],
|
128
|
+
members: [userid, savedUser2._id.toString()],
|
129
|
+
trashed: false,
|
130
|
+
id_project: savedProject._id,
|
131
|
+
createdBy: userid,
|
132
|
+
updatedBy: userid
|
133
|
+
});
|
134
|
+
newGroup.save(function (err, savedGroup) {
|
135
|
+
console.log("savedGroup", savedGroup)
|
136
|
+
|
137
|
+
|
138
|
+
chai.request(server)
|
139
|
+
.post('/' + savedProject._id + '/campaigns/direct')
|
140
|
+
.auth(email, pwd)
|
141
|
+
.set('content-type', 'application/json')
|
142
|
+
.send({ "text": "ciao", "group_id": savedGroup._id.toString() })
|
143
|
+
.end(function (err, res) {
|
144
|
+
//console.log("res", res);
|
145
|
+
console.log("res.body", res.body);
|
146
|
+
res.should.have.status(200);
|
147
|
+
res.body.should.be.a('object');
|
148
|
+
|
149
|
+
|
150
|
+
expect(res.body.success).to.equal(true);
|
151
|
+
|
152
|
+
|
153
|
+
done();
|
154
|
+
});
|
155
|
+
});
|
156
|
+
});
|
157
|
+
});
|
158
|
+
});
|
159
|
+
});
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
// mocha test/campaignsRoute.js --grep 'directGroupId2'
|
165
|
+
|
166
|
+
it('directGroupId2', function (done) {
|
167
|
+
|
168
|
+
var email = "test-message-create-" + Date.now() + "@email.com";
|
169
|
+
var pwd = "pwd";
|
170
|
+
|
171
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
172
|
+
projectService.createAndReturnProjectAndProjectUser("directSimple", savedUser._id).then(function (savedProjectAndPU) {
|
173
|
+
|
174
|
+
var savedProject = savedProjectAndPU.project;
|
175
|
+
|
176
|
+
var userid = savedUser._id;
|
177
|
+
|
178
|
+
var email2 = "test-message-create-" + Date.now() + "@email.com";
|
179
|
+
userService.signup(email2, pwd, "Test Firstname", "Test lastname").then(function (savedUser2) {
|
180
|
+
|
181
|
+
var newGroup = new Group({
|
182
|
+
name: "group1",
|
183
|
+
// members: ["userid1", "userid2"],
|
184
|
+
members: [userid, savedUser2._id.toString()],
|
185
|
+
trashed: false,
|
186
|
+
id_project: savedProject._id,
|
187
|
+
createdBy: userid,
|
188
|
+
updatedBy: userid
|
189
|
+
});
|
190
|
+
newGroup.save(function (err, savedGroup) {
|
191
|
+
console.log("savedGroup", savedGroup)
|
192
|
+
|
193
|
+
|
194
|
+
chai.request(server)
|
195
|
+
.post('/' + savedProject._id + '/campaigns/direct')
|
196
|
+
.auth(email, pwd)
|
197
|
+
.set('content-type', 'application/json')
|
198
|
+
.send({ "text": "ciao", "group_id": savedGroup._id.toString(), returnobject: true })
|
199
|
+
.end(function (err, res) {
|
200
|
+
//console.log("res", res);
|
201
|
+
console.log("res.body", res.body);
|
202
|
+
res.should.have.status(200);
|
203
|
+
res.body.should.be.a('array');
|
204
|
+
|
205
|
+
expect(res.body.length).to.equal(2);
|
206
|
+
expect(res.body[0].recipient).to.equal(userid.toString());
|
207
|
+
expect(res.body[1].recipient).to.equal(savedUser2._id.toString());
|
208
|
+
// expect(res.body.success).to.equal(true);
|
209
|
+
|
210
|
+
|
211
|
+
done();
|
212
|
+
});
|
213
|
+
});
|
214
|
+
});
|
215
|
+
});
|
216
|
+
});
|
217
|
+
});
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
});
|
225
|
+
|
226
|
+
|
package/test/faqService.js
CHANGED
@@ -28,7 +28,7 @@ describe('FaqService()', function () {
|
|
28
28
|
|
29
29
|
userService.signup( email ,pwd, "Test Firstname", "Test lastname").then(function(savedUser) {
|
30
30
|
projectService.create("test-FaqService", savedUser._id).then(function(savedProject) {
|
31
|
-
faqService.create("testbot", null, savedProject._id, savedUser._id
|
31
|
+
faqService.create("testbot", null, savedProject._id, savedUser._id).then(function(savedBot) {
|
32
32
|
|
33
33
|
var newFaq = new Faq({
|
34
34
|
id_faq_kb: savedBot._id,
|
@@ -94,7 +94,7 @@ it('create-with-intent_display_name-and-search', (done) => {
|
|
94
94
|
|
95
95
|
userService.signup( email ,pwd, "Test Firstname", "Test lastname").then(function(savedUser) {
|
96
96
|
projectService.create("test-FaqService", savedUser._id).then(function(savedProject) {
|
97
|
-
faqService.create("testbot", null, savedProject._id, savedUser._id
|
97
|
+
faqService.create("testbot", null, savedProject._id, savedUser._id).then(function(savedBot) {
|
98
98
|
|
99
99
|
var newFaq = new Faq({
|
100
100
|
id_faq_kb: savedBot._id,
|
@@ -162,7 +162,7 @@ it('create-with-duplicated-intent_display_name-and-search', (done) => {
|
|
162
162
|
|
163
163
|
userService.signup( email ,pwd, "Test Firstname", "Test lastname").then(function(savedUser) {
|
164
164
|
projectService.create("test-FaqService", savedUser._id).then(function(savedProject) {
|
165
|
-
faqService.create("testbot", null, savedProject._id, savedUser._id
|
165
|
+
faqService.create("testbot", null, savedProject._id, savedUser._id).then(function(savedBot) {
|
166
166
|
|
167
167
|
var newFaq0 = new Faq({
|
168
168
|
id_faq_kb: savedBot._id,
|