@chat21/chat21-ionic 3.4.1 → 3.4.3-rc.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # chat21-ionic ver 3.0
2
2
 
3
+ ### 3.4.3-rc.1
4
+ - added: encodeUri for project name on chatbot share link
5
+ - added: offlineMsgEmail project email to emable/disable automatic offline msg email
6
+
7
+ ### 3.4.2 in PROD
8
+ - added: chat21client v0.1.12.8
9
+
3
10
  ### 3.4.1 in PROD
4
11
  - bug-fixed: supportMode parameter is not typed as boolean
5
12
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@chat21/chat21-ionic",
3
3
  "author": "Tiledesk SRL",
4
- "version": "3.4.1",
4
+ "version": "3.4.3-rc.1",
5
5
  "license": "MIT License",
6
6
  "homepage": "https://tiledesk.com/",
7
7
  "repository": {
@@ -27,7 +27,7 @@ import { CustomTranslateService } from 'src/chat21-core/providers/custom-transla
27
27
  import { NotificationsService } from 'src/chat21-core/providers/abstract/notifications.service';
28
28
  import { NetworkService } from './services/network-service/network.service';
29
29
  import { ScriptService } from './services/scripts/script.service';
30
- import { AUTH_STATE_OFFLINE, AUTH_STATE_ONLINE, PLATFORM_DESKTOP, PLATFORM_MOBILE, tranlatedLanguage, TYPE_DIRECT, URL_SOUND_CONVERSATION_ADDED, URL_SOUND_CONVERSATION_UNASSIGNED, URL_SOUND_LIST_CONVERSATION } from 'src/chat21-core/utils/constants';
30
+ import { AUTH_STATE_CLOSE, AUTH_STATE_OFFLINE, AUTH_STATE_ONLINE, PLATFORM_DESKTOP, PLATFORM_MOBILE, tranlatedLanguage, TYPE_DIRECT, URL_SOUND_CONVERSATION_ADDED, URL_SOUND_CONVERSATION_UNASSIGNED, URL_SOUND_LIST_CONVERSATION } from 'src/chat21-core/utils/constants';
31
31
  import { ActivatedRoute, Router } from '@angular/router';
32
32
  import { ConversationModel } from 'src/chat21-core/models/conversation';
33
33
  import { LoginPage } from './pages/authentication/login/login.page';
@@ -1073,8 +1073,16 @@ export class AppComponent implements OnInit {
1073
1073
  // this.checkTokenAndGoOffline() //se c'è un tiledeskToken salvato, allora aspetta, altrimenti vai offline
1074
1074
  this.IS_ONLINE = false;
1075
1075
  // console.log('[APP-COMP] IS_ONLINE', this.IS_ONLINE)
1076
- this.goOffLine()
1076
+ this.goOffLine();
1077
1077
  this.triggerOnAuthStateChanged(state)
1078
+ } else if(state && state === AUTH_STATE_CLOSE ){
1079
+ this.logger.info('[APP-COMP] CLOSE - CHANNEL CLOSED: ', this.chatManager);
1080
+ // let IDConv= null
1081
+ // if(this.route && this.route.snapshot && this.route.snapshot.firstChild){
1082
+ // IDConv = this.route.snapshot.firstChild.paramMap.get('IDConv');
1083
+ // this.chatManager.removeConversationHandler(IDConv);
1084
+ // }
1085
+ // this.checkPlatform();
1078
1086
  }
1079
1087
  }, error => {
1080
1088
  this.logger.error('initialize FROM [APP-COMP] - [APP-COMP] ***** BSAuthStateChanged * error * ', error)
@@ -22,7 +22,7 @@
22
22
  </ion-button>
23
23
  </div>
24
24
 
25
- <div *ngIf="section==='chat' && channel !== CHANNEL_TYPE.WHATSAPP && messageString && (leadInfo?.presence['status']==='offline' && leadInfo?.hasEmail)" class="section-option offline-lead-tip" >
25
+ <div *ngIf="offlineMsgEmail && section==='chat' && channel !== CHANNEL_TYPE.WHATSAPP && messageString && (leadInfo?.presence['status']==='offline' && leadInfo?.hasEmail)" class="section-option offline-lead-tip" >
26
26
  {{translationMap.get('EMAIL.EMAIL_OFFLINE_TIP')}}
27
27
  </div>
28
28
 
@@ -54,6 +54,7 @@ export class MessageTextAreaComponent implements OnInit, AfterViewInit, OnChange
54
54
  @Input() leadInfo: {lead_id: string, hasEmail: boolean, email: string, projectId: string, presence: {}};
55
55
  @Input() fileUploadAccept: string;
56
56
  @Input() emailSection: boolean;
57
+ @Input() offlineMsgEmail: boolean;
57
58
  @Input() whatsappTemplatesSection: boolean;
58
59
  @Input() isOpenInfoConversation: boolean;
59
60
  @Input() stylesMap: Map<string, string>;
@@ -159,7 +159,7 @@ export class NavbarComponent implements OnInit {
159
159
  const simulateVisitorBtnElem = <HTMLElement>document.querySelector('.simulate-visitor-btn');
160
160
  simulateVisitorBtnElem.blur();
161
161
  // + '&isOpen=true'
162
- const url = this.appConfigProvider.getConfig().widgetBaseUrl + 'assets/twp/index.html?tiledesk_projectid=' + this.project.id_project.id + '&project_name=' + this.project.id_project.name + '&role=' + this.USER_ROLE
162
+ const url = this.appConfigProvider.getConfig().widgetBaseUrl + 'assets/twp/index.html?tiledesk_projectid=' + this.project.id_project.id + '&project_name=' + encodeURIComponent(this.project.id_project.name) + '&role=' + this.USER_ROLE
163
163
  window.open(url, '_blank');
164
164
  }
165
165
 
@@ -236,6 +236,7 @@
236
236
  [leadInfo]="leadInfo"
237
237
  [fileUploadAccept]="appConfigProvider.getConfig().fileUploadAccept"
238
238
  [emailSection]="isEmailEnabled"
239
+ [offlineMsgEmail]="offlineMsgEmail"
239
240
  [whatsappTemplatesSection]="isWhatsappTemplatesEnabled"
240
241
  [isOpenInfoConversation]="openInfoConversation"
241
242
  [stylesMap]="styleMap"
@@ -160,6 +160,7 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
160
160
  areVisibleCAR: boolean;
161
161
  supportMode: boolean;
162
162
  isEmailEnabled: boolean;
163
+ offlineMsgEmail: boolean;
163
164
  isWhatsappTemplatesEnabled: boolean;
164
165
  //SOUND
165
166
  setTimeoutSound: any;
@@ -524,9 +525,9 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
524
525
  this.disableTextarea = false
525
526
  this._getProjectIdByConversationWith(this.conversationWith)
526
527
  this.initConversationHandler()
527
- this.initGroupsHandler()
528
- this.initSubscriptions()
529
- this.startConversation()
528
+ this.initGroupsHandler();
529
+ this.startConversation();
530
+ this.initSubscriptions();
530
531
  this.getLeadDetail()
531
532
  this.initializeTyping();
532
533
  }
@@ -556,6 +557,7 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
556
557
  if (project) {
557
558
  const projectId = project.id_project
558
559
  this.canShowCanned = this.checkPlanIsExpired(project)
560
+ this.offlineMsgEmail = this.checkOfflineMsgEmailIsEnabled(project)
559
561
  }
560
562
  }, (error) => {
561
563
  this.logger.error('[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT - ERROR ', error)
@@ -588,6 +590,23 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
588
590
  return check
589
591
  }
590
592
 
593
+
594
+ checkOfflineMsgEmailIsEnabled(project: Project): boolean {
595
+ let check: boolean = true
596
+
597
+ //case: check emailSection env variable
598
+ if(!this.isEmailEnabled){
599
+ return check= false
600
+ }
601
+
602
+ //case: check offlineMsgEmail project property
603
+ if(project && project.hasOwnProperty('offlineMsgEmail')){
604
+ check = project.offlineMsgEmail
605
+ }
606
+
607
+ return check
608
+ }
609
+
591
610
  // getProjectIdSelectedConversation(conversationWith: string): string{
592
611
  // const conversationWith_segments = conversationWith.split('-')
593
612
  // // Removes the last element of the array if is = to the separator
@@ -879,7 +898,6 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
879
898
  conv.attributes['project_name'],
880
899
  conv.attributes['request_channel']
881
900
  )
882
-
883
901
  }
884
902
  if (!conv) {
885
903
  this.logger.debug('[CONV-COMP] setHeaderContent getConversationDetail: conv not exist --> search in archived list', this.conversationWith, this.conv_type)
@@ -1120,8 +1138,7 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1120
1138
 
1121
1139
  if ((msg && msg.trim() !== '') || type !== TYPE_MSG_TEXT) {
1122
1140
 
1123
-
1124
- if (this.isEmailEnabled &&
1141
+ if (this.offlineMsgEmail &&
1125
1142
  this.leadInfo && this.leadInfo.presence && this.leadInfo.presence['status'] === 'offline' &&
1126
1143
  this.leadInfo.email && !emailSectionMsg && !channelIsNotWeb) {
1127
1144
  this.logger.log('[CONVS-DETAIL] - SEND MESSAGE --> SENDING EMAIL', msg, this.leadInfo.email)
@@ -1317,7 +1334,7 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1317
1334
  updateLeadInfo(msg) {
1318
1335
  if (msg.attributes && msg.attributes.hasOwnProperty("updateUserFullname")) {
1319
1336
  const userFullname = msg.attributes['updateUserFullname'];
1320
- this.logger.debug('[CONVS-DETAIL] newMessageAdded --> updateUserFullname', userFullname)
1337
+ this.logger.debug('[CONVS-DETAIL] newMessageAdded --> updateUserFullname', userFullname, this.conversation)
1321
1338
  this.conversationWithFullname = userFullname //update info for next sendMessage object
1322
1339
  //updates conversation header info
1323
1340
  this.conversationAvatar = setConversationAvatar(
@@ -7,7 +7,7 @@ export const BRAND_BASE_INFO: { [key: string] : string | boolean} ={
7
7
  FAVICON: "https://tiledesk.com/wp-content/uploads/2022/07/tiledesk_v13-300x300.png",
8
8
  META_TITLE:"Tiledesk - Open Source Live Chat",
9
9
  DOCS: true,
10
- LOGOUT_ENABLED: false
10
+ LOGOUT_ENABLED: true
11
11
  }
12
12
 
13
13
  export var LOGOS_ITEMS: { [key: string] : { label: string | boolean, icon: string }} ={
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  Chat21Client
3
3
 
4
- v0.1.12.7
4
+ v0.1.12.8
5
5
 
6
6
  @Author Andrea Sponziello
7
7
  @Member Gabriele Panico
@@ -24,6 +24,7 @@ class Chat21Client {
24
24
  this.reconnections = 0 // just to check how many reconnections
25
25
  this.client_id = this.uuidv4();
26
26
  this.log = options.log ? true : false;
27
+
27
28
  if (options && options.MQTTendpoint) {
28
29
  if (options.MQTTendpoint.startsWith('/')) {
29
30
  if (this.log) {
@@ -1021,25 +1022,31 @@ class Chat21Client {
1021
1022
  );
1022
1023
  }
1023
1024
  );
1025
+ this.client.on('error',
1026
+ (error) => {
1027
+ console.error("Chat client error event", error);
1028
+ }
1029
+ );
1030
+ }
1031
+
1032
+ onDisconnect(callback){
1024
1033
  this.client.on('reconnect',
1025
1034
  () => {
1026
1035
  if (this.log) {console.log("Chat client reconnect event");}
1036
+ // callback('reconnect')
1027
1037
  }
1028
1038
  );
1029
1039
  this.client.on('close',
1030
1040
  () => {
1031
1041
  this.connected = false
1032
1042
  if (this.log) {console.log("Chat client close event");}
1043
+ callback('close')
1033
1044
  }
1034
1045
  );
1035
1046
  this.client.on('offline',
1036
1047
  () => {
1037
1048
  if (this.log) {console.log("Chat client offline event");}
1038
- }
1039
- );
1040
- this.client.on('error',
1041
- (error) => {
1042
- console.error("Chat client error event", error);
1049
+ // callback('offline')
1043
1050
  }
1044
1051
  );
1045
1052
  }
@@ -19,6 +19,7 @@ export interface Project {
19
19
  // profile_type?: string;
20
20
  isActiveSubscription?: boolean;
21
21
  profile?: any;
22
+ offlineMsgEmail?: boolean;
22
23
  // subscription_end_date?: any;
23
24
  // subscription_id?: any;
24
25
  // subscription_creation_date?: any;
@@ -246,8 +246,7 @@ z
246
246
  const responseType = 'text';
247
247
  const postData = {};
248
248
  // const that = this;
249
- this.http.post(this.URL_TILEDESK_CREATE_CUSTOM_TOKEN, postData, { headers, responseType})
250
- .subscribe(data => {
249
+ this.http.post(this.URL_TILEDESK_CREATE_CUSTOM_TOKEN, postData, { headers, responseType}).subscribe(data => {
251
250
  this.logger.debug("[MQTTAuthService] connectWithCustomToken: **** data", data)
252
251
  const result = JSON.parse(data);
253
252
  this.connectMQTT(result);
@@ -262,9 +261,17 @@ z
262
261
  this.chat21Service.chatClient.connect(userid, credentials.token, () => {
263
262
  this.logger.debug('[MQTTAuthService] connectMQTT: Chat connected.');
264
263
  this.BSAuthStateChanged.next('online');
264
+ this.onDisconnectMQTT();
265
265
  });
266
266
  }
267
267
 
268
+ onDisconnectMQTT(): any{
269
+ this.chat21Service.chatClient.onDisconnect((state)=> {
270
+ this.logger.debug('[MQTTAuthService] onDisconnect --> ', state)
271
+ this.BSAuthStateChanged.next('close');
272
+ })
273
+ }
274
+
268
275
  // /**
269
276
  // * createCompleteUser
270
277
  // * @param user
@@ -13,7 +13,8 @@ export const PUSH_ENGINE_FIREBASE = 'firebase';
13
13
 
14
14
  // AUTH
15
15
  export const AUTH_STATE_OFFLINE = 'offline';
16
- export const AUTH_STATE_ONLINE = 'online'
16
+ export const AUTH_STATE_ONLINE = 'online';
17
+ export const AUTH_STATE_CLOSE = 'close';
17
18
 
18
19
 
19
20
  // MESSAGES STATUS