@tiledesk/tiledesk-server 2.2.2 → 2.2.3

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # 2.2.3
2
+ - Email inboud fix (others disabled and inboudDomain variable fix and token query string encode fix)
3
+
4
+ # 2.2.2
5
+ - log fix
6
+
7
+ # 2.2.1
8
+ - log fix
1
9
 
2
10
  # 2.2.0
3
11
  - Cache circleci fix
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-server",
3
3
  "description": "The Tiledesk server module",
4
- "version": "2.2.2",
4
+ "version": "2.2.3",
5
5
  "scripts": {
6
6
  "start": "node ./bin/www",
7
7
  "pretest": "mongodb-runner start",
@@ -261,6 +261,7 @@ sendToUserEmailChannelEmail(projectid, message) {
261
261
  jwtid: uuidv4()
262
262
  };
263
263
 
264
+
264
265
  var recipient = lead.lead_id;
265
266
  winston.debug("recipient:"+ recipient);
266
267
 
@@ -291,12 +292,13 @@ sendToUserEmailChannelEmail(projectid, message) {
291
292
  winston.debug("sourcePage "+sourcePage);
292
293
 
293
294
 
294
- var tokenQueryString;
295
- if(sourcePage && sourcePage.indexOf('?')>-1) { //controllo superfluo ma lascio per indipendenza
296
- tokenQueryString = "&tiledesk_jwt="+encodeURIComponent("JWT "+token)
295
+ var tokenQueryString;
296
+ if(sourcePage && sourcePage.indexOf('?')>-1) { //controllo superfluo visto che lo metto prima? ma lascio comunque per indipendenza
297
+ tokenQueryString = encodeURIComponent("&tiledesk_jwt=JWT "+token)
297
298
  }else {
298
- tokenQueryString = "?tiledesk_jwt="+encodeURIComponent("JWT "+token);
299
+ tokenQueryString = encodeURIComponent("?tiledesk_jwt=JWT "+token);
299
300
  }
301
+ winston.debug("tokenQueryString: "+tokenQueryString);
300
302
 
301
303
  emailService.sendEmailChannelNotification(message.request.lead.email, message, project, tokenQueryString, sourcePage);
302
304
 
@@ -610,11 +612,12 @@ sendUserEmail(projectid, message) {
610
612
 
611
613
  var tokenQueryString;
612
614
  if(sourcePage && sourcePage.indexOf('?')>-1) { //controllo superfluo visto che lo metto prima? ma lascio comunque per indipendenza
613
- tokenQueryString = "&tiledesk_jwt="+encodeURIComponent("JWT "+token)
615
+ tokenQueryString = encodeURIComponent("&tiledesk_jwt=JWT "+token)
614
616
  }else {
615
- tokenQueryString = "?tiledesk_jwt="+encodeURIComponent("JWT "+token);
617
+ tokenQueryString = encodeURIComponent("?tiledesk_jwt=JWT "+token);
616
618
  }
617
-
619
+ winston.debug("tokenQueryString: "+tokenQueryString);
620
+
618
621
  emailService.sendNewMessageNotification(lead.email, message, project, tokenQueryString, sourcePage);
619
622
  }
620
623
 
@@ -775,8 +778,27 @@ sendAgentEmail(projectid, savedRequest) {
775
778
  winston.warn("User not found", savedRequest.participants[0]);
776
779
  } else {
777
780
  winston.verbose("Sending sendNewAssignedRequestNotification to user with email", user.email);
778
- // if (user.emailverified) { enable it? send anyway to improve engagment for new account
779
- emailService.sendNewAssignedRequestNotification(user.email, savedRequest, project);
781
+ // if (user.emailverified) { enable it? send anyway to improve engagment for new account
782
+
783
+
784
+ // var signOptions = {
785
+ // issuer: 'https://tiledesk.com',
786
+ // subject: 'user',
787
+ // audience: 'https://tiledesk.com',
788
+ // jwtid: uuidv4()
789
+ // };
790
+
791
+ // let userObject = {_id: user._id, firstname: user.firstname, lastname: user.lastname, email: user.email, attributes: user.attributes};
792
+ // winston.debug("userObject ",userObject);
793
+
794
+
795
+ // var agentToken = jwt.sign(userObject, configSecret, signOptions);
796
+ // winston.debug("agentToken "+agentToken);
797
+
798
+
799
+
800
+
801
+ emailService.sendNewAssignedRequestNotification(user.email, savedRequest, project);
780
802
  // }
781
803
  }
782
804
  });
package/routes/urls.js CHANGED
@@ -4,7 +4,7 @@ var winston = require('../config/winston');
4
4
 
5
5
 
6
6
  router.get('/redirect', function (req, res) {
7
- winston.debug(req.body);
7
+ winston.debug("redirect: "+ req.query.path);
8
8
  res.redirect(req.query.path);
9
9
  });
10
10
 
@@ -74,15 +74,15 @@ class EmailService {
74
74
  }
75
75
  winston.info('EmailService replyEnabled : '+ this.replyEnabled);
76
76
 
77
- // unused? is empty why?
77
+ // this is used as fixed reply to url, but this is unused we always return support-group-dynamic
78
78
  this.replyTo = process.env.EMAIL_REPLY_TO || config.replyTo;
79
79
  winston.info('EmailService replyTo address: '+ this.replyTo);
80
80
 
81
- this.inboudDomain = process.env.EMAIL_INBOUND_DOMAIN || config.inboundDomain;
82
- winston.info('EmailService inboudDomain : '+ this.inboudDomain);
81
+ this.inboundDomain = process.env.EMAIL_INBOUND_DOMAIN || config.inboundDomain;
82
+ winston.info('EmailService inboundDomain : '+ this.inboundDomain);
83
83
 
84
- this.inboudDomainWithAt = "@"+this.inboudDomain;
85
- winston.verbose('EmailService inboudDomainWithAt : '+ this.inboudDomainWithAt);
84
+ this.inboundDomainDomainWithAt = "@"+this.inboundDomain;
85
+ winston.verbose('EmailService inboundDomainDomainWithAt : '+ this.inboundDomainDomainWithAt);
86
86
 
87
87
  this.pass = process.env.EMAIL_PASSWORD;
88
88
 
@@ -346,7 +346,11 @@ class EmailService {
346
346
 
347
347
  let messageId = "notification" + "@" + MESSAGE_ID_DOMAIN;
348
348
 
349
- let replyTo = request.request_id + this.inboudDomainWithAt;
349
+ let replyTo;
350
+ if (this.replyEnabled) { //fai anche per gli altri
351
+ replyTo = request.request_id + this.inboundDomainDomainWithAt;
352
+ }
353
+
350
354
  let headers;
351
355
  if (request) {
352
356
 
@@ -356,7 +360,11 @@ class EmailService {
356
360
  replyTo = request.attributes.email_replyTo;
357
361
  }
358
362
 
359
- headers = {"X-TILEDESK-PROJECT-ID": project._id, "X-TILEDESK-REQUEST-ID": request.request_id, "X-TILEDESK-TICKET-ID":request.ticket_id };
363
+ headers = {
364
+ "X-TILEDESK-PROJECT-ID": project._id,
365
+ "X-TILEDESK-REQUEST-ID": request.request_id,
366
+ "X-TILEDESK-TICKET-ID":request.ticket_id,
367
+ };
360
368
 
361
369
  winston.verbose("messageId: " + messageId);
362
370
  winston.verbose("replyTo: " + replyTo);
@@ -488,7 +496,11 @@ class EmailService {
488
496
 
489
497
  let messageId = message._id + "@" + MESSAGE_ID_DOMAIN;
490
498
 
491
- let replyTo = message.request.request_id + this.inboudDomainWithAt;
499
+ let replyTo;
500
+ if (this.replyEnabled) {
501
+ replyTo = message.request.request_id + this.inboundDomainDomainWithAt;
502
+ }
503
+
492
504
  let headers;
493
505
  if (message.request) {
494
506
 
@@ -629,7 +641,11 @@ class EmailService {
629
641
 
630
642
  let messageId = "notification-pooled" + new Date().getTime() + "@" + MESSAGE_ID_DOMAIN;
631
643
 
632
- let replyTo = request.request_id + this.inboudDomainWithAt;
644
+ let replyTo;
645
+ if (this.replyEnabled) {
646
+ replyTo = request.request_id + this.inboundDomainDomainWithAt;
647
+ }
648
+
633
649
  let headers;
634
650
  if (request) {
635
651
 
@@ -765,7 +781,11 @@ class EmailService {
765
781
 
766
782
  let messageId = message._id + "@" + MESSAGE_ID_DOMAIN;
767
783
 
768
- let replyTo = message.request.request_id + this.inboudDomainWithAt;
784
+ let replyTo;
785
+ if (this.replyEnabled) {
786
+ replyTo = message.request.request_id + this.inboundDomainDomainWithAt;
787
+ }
788
+
769
789
  let headers;
770
790
  if (message.request) {
771
791
 
@@ -904,7 +924,11 @@ class EmailService {
904
924
 
905
925
  let messageId = message._id + "@" + MESSAGE_ID_DOMAIN;
906
926
 
907
- let replyTo = message.request.request_id + this.inboudDomainWithAt;
927
+ let replyTo;
928
+ if (this.replyEnabled) {
929
+ replyTo = message.request.request_id + this.inboundDomainDomainWithAt;
930
+ }
931
+
908
932
  let headers;
909
933
  if (message.request) {
910
934
 
@@ -1015,6 +1039,8 @@ class EmailService {
1015
1039
  }
1016
1040
 
1017
1041
  winston.debug("msgText: " + msgText);
1042
+ winston.debug("baseScope: " + JSON.stringify(baseScope));
1043
+
1018
1044
 
1019
1045
  var replacements = {
1020
1046
  message: message,
@@ -1033,7 +1059,11 @@ class EmailService {
1033
1059
 
1034
1060
  let messageId = message._id + "@" + MESSAGE_ID_DOMAIN;
1035
1061
 
1036
- let replyTo = message.request.request_id + this.inboudDomainWithAt;
1062
+ let replyTo;
1063
+ if (this.replyEnabled) {
1064
+ replyTo = message.request.request_id + this.inboundDomainDomainWithAt;
1065
+ }
1066
+
1037
1067
  let headers;
1038
1068
  if (message.request) {
1039
1069
 
@@ -132,8 +132,7 @@
132
132
  {{#ifEquals this.type "url"}}
133
133
  <li><a href="{{this.link}}" class="dynamic_button">{{this.value}}</a></li>
134
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
- <!-- <li><a href="https://api.tiledesk.com/v2/{{project.id}}/link?secret_token={{tokenQueryString}}" class="dynamic_button">{{this.value}}</a></li> -->
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>
137
136
  {{/ifEquals}}
138
137
  {{/each}}
139
138
 
@@ -142,14 +141,14 @@
142
141
  {{/if}}
143
142
  {{/if}}
144
143
 
145
- {{#if message.attributes.intent_info}}
144
+ <!-- {{#if message.attributes.intent_info}}
146
145
  {{#if message.attributes.intent_info.others}}
147
146
  Others:
148
147
  {{#each message.attributes.intent_info.others}}
149
148
  <li><span>{{this.answer}}</span></li>
150
149
  {{/each}}
151
150
  {{/if}}
152
- {{/if}}
151
+ {{/if}} -->
153
152
 
154
153
 
155
154