@chat21/chat21-web-widget 5.0.53-rc.4 → 5.0.53

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.
Files changed (45) hide show
  1. package/CHANGELOG.md +3 -14
  2. package/package.json +1 -1
  3. package/src/app/app.component.ts +8 -18
  4. package/src/app/app.module.ts +8 -10
  5. package/src/app/component/conversation-detail/conversation/conversation.component.ts +1 -15
  6. package/src/app/component/conversation-detail/conversation-content/conversation-content.component.spec.ts +2 -2
  7. package/src/app/component/last-message/last-message.component.html +72 -83
  8. package/src/app/component/last-message/last-message.component.scss +42 -98
  9. package/src/app/component/last-message/last-message.component.spec.ts +2 -2
  10. package/src/app/component/last-message/last-message.component.ts +25 -49
  11. package/src/app/component/list-all-conversations/list-all-conversations.component.ts +1 -1
  12. package/src/app/component/message/bubble-message/bubble-message.component.html +5 -0
  13. package/src/app/component/message/html/html.component.spec.ts +1 -1
  14. package/src/app/component/message/info-message/info-message.component.spec.ts +1 -1
  15. package/src/app/component/message/text/text.component.scss +0 -4
  16. package/src/app/component/message/text/text.component.spec.ts +2 -2
  17. package/src/app/component/message-attachment/message-attachment.component.html +1 -1
  18. package/src/app/component/message-attachment/message-attachment.component.ts +0 -2
  19. package/src/app/{pipe → directives}/html-entites-encode.pipe.spec.ts +0 -0
  20. package/src/app/{pipe → directives}/html-entities-encode.pipe.ts +0 -0
  21. package/src/app/{pipe → directives}/marked.pipe.spec.ts +0 -0
  22. package/src/app/{pipe → directives}/marked.pipe.ts +0 -0
  23. package/src/app/{pipe → directives}/safe-html.pipe.spec.ts +0 -0
  24. package/src/app/{pipe → directives}/safe-html.pipe.ts +0 -0
  25. package/src/app/providers/global-settings.service.ts +12 -11
  26. package/src/app/utils/globals.ts +0 -3
  27. package/src/app/utils/rules.ts +5 -88
  28. package/src/assets/js/chat21client.js +4 -27
  29. package/src/assets/twp/index-dev.html +1 -1
  30. package/src/assets/twp/index.html +1 -1
  31. package/src/chat21-core/models/conversation.ts +2 -2
  32. package/src/chat21-core/models/upload.ts +0 -1
  33. package/src/chat21-core/providers/abstract/presence.service.ts +0 -1
  34. package/src/chat21-core/providers/firebase/firebase-conversation-handler.ts +106 -78
  35. package/src/chat21-core/providers/firebase/firebase-presence.service.ts +0 -4
  36. package/src/chat21-core/providers/mqtt/mqtt-conversation-handler.ts +29 -2
  37. package/src/chat21-core/providers/mqtt/mqtt-presence.service.ts +156 -13
  38. package/src/chat21-core/providers/tiledesk/tiledesk-requests.service.ts +4 -21
  39. package/src/chat21-core/utils/utils-message.ts +0 -36
  40. package/src/iframe-style.css +2 -2
  41. package/src/models/project.ts +1 -4
  42. package/src/app/providers/events.service.spec.ts +0 -16
  43. package/src/app/providers/events.service.ts +0 -76
  44. package/src/launch_old.js +0 -446
  45. package/src/models/rule.ts +0 -18
@@ -28,7 +28,7 @@ import {
28
28
  conversationMessagesRef
29
29
  } from '../../utils/utils';
30
30
  import { v4 as uuidv4 } from 'uuid';
31
- import { messageType, checkIfIsMemberJoinedGroup, hideInfoMessage, isJustRecived, isSender } from '../../utils/utils-message';
31
+ import { messageType, checkIfIsMemberJoinedGroup, hideInfoMessage, isJustRecived } from '../../utils/utils-message';
32
32
 
33
33
  // @Injectable({ providedIn: 'root' })
34
34
  @Injectable()
@@ -187,6 +187,7 @@ export class FirebaseConversationHandler extends ConversationHandlerService {
187
187
  type: typeMsg,
188
188
  attributes: attributes,
189
189
  channel_type: channelType
190
+ // isSender: true
190
191
  });
191
192
 
192
193
  // const message = new MessageModel(
@@ -309,7 +310,7 @@ export class FirebaseConversationHandler extends ConversationHandlerService {
309
310
  // }
310
311
 
311
312
  // verifico che il sender è il logged user
312
- msg.isSender = isSender(msg.sender, this.loggedUser.uid);
313
+ msg.isSender = this.isSender(msg.sender, this.loggedUser.uid);
313
314
  //check if message contains only an emojii
314
315
  // msg.emoticon = isEmojii(msg.text)
315
316
 
@@ -334,7 +335,7 @@ export class FirebaseConversationHandler extends ConversationHandlerService {
334
335
  // }
335
336
 
336
337
  // verifico che il sender è il logged user
337
- msg.isSender = isSender(msg.sender, this.loggedUser.uid);
338
+ msg.isSender = this.isSender(msg.sender, this.loggedUser.uid);
338
339
  //check if message contains only an emojii
339
340
  // msg.emoticon = isEmojii(msg.text)
340
341
 
@@ -452,91 +453,118 @@ export class FirebaseConversationHandler extends ConversationHandlerService {
452
453
  }
453
454
  }
454
455
 
455
-
456
- unsubscribe(key: string) {
457
- this.listSubsriptions.forEach(sub => {
458
- this.logger.debug('[FIREBASEConversationHandlerSERVICE] unsubscribe: ', sub.uid, key);
459
- if (sub.uid === key) {
460
- this.logger.debug('[FIREBASEConversationHandlerSERVICE] unsubscribe: ', sub.uid, key);
461
- sub.unsubscribe(key, null);
462
- return;
456
+ /**
457
+ * controllo se il messaggio è stato inviato da loggerUser
458
+ * richiamato dalla pagina elenco messaggi della conversazione
459
+ */
460
+ private isSender(sender: string, currentUserId: string) {
461
+ if (currentUserId) {
462
+ if (sender === currentUserId) {
463
+ return true;
464
+ } else {
465
+ return false;
463
466
  }
464
- });
467
+ } else {
468
+ return false;
469
+ }
465
470
  }
466
471
 
467
472
 
468
- private addCommandMessage(msg: MessageModel){
469
- const that = this;
470
- const commands = msg.attributes.commands;
471
- let i=0;
472
- function execute(command){
473
- if(command.type === "message"){
474
- that.logger.debug('[FIREBASEConversationHandlerSERVICE] addCommandMessage --> type="message"', command, i)
475
- if (i >= 2) {
476
-
477
- //check if previus wait message type has time value, otherwize set to 1000ms
478
- !commands[i-1].time? commands[i-1].time= 1000 : commands[i-1].time
479
- command.message.timestamp = commands[i-2].message.timestamp + commands[i-1].time;
480
-
481
- /** CHECK IF MESSAGE IS JUST RECEIVED: IF false, set next message time (if object exist) to 0 -> this allow to show it immediately */
482
- if(!isJustRecived(that.startTime.getTime(), msg.timestamp)){
483
- let previewsTimeMsg = msg.timestamp;
484
- commands[i-2]? previewsTimeMsg = commands[i-2].message.timestamp : null;
485
- command.message.timestamp = previewsTimeMsg + 100
486
- commands[i+1]? commands[i+1].time = 0 : null
487
- }
488
- } else { /**MANAGE FIRST MESSAGE */
489
- command.message.timestamp = msg.timestamp;
490
- if(!isJustRecived(that.startTime.getTime(), msg.timestamp)){
491
- commands[i+1]? commands[i+1].time = 0 : null
492
- }
473
+ /** */
474
+ // updateMetadataMessage(uid: string, metadata: any) {
475
+ // metadata.status = true;
476
+ // const message = {
477
+ // metadata: metadata
478
+ // };
479
+ // const firebaseMessages = firebase.database().ref(this.urlNodeFirebase + uid);
480
+ // firebaseMessages.set(message);
481
+ // }
482
+
483
+
484
+ unsubscribe(key: string) {
485
+ this.listSubsriptions.forEach(sub => {
486
+ this.logger.debug('[FIREBASEConversationHandlerSERVICE] unsubscribe: ', sub.uid, key);
487
+ if (sub.uid === key) {
488
+ this.logger.debug('[FIREBASEConversationHandlerSERVICE] unsubscribe: ', sub.uid, key);
489
+ sub.unsubscribe(key, null);
490
+ return;
491
+ }
492
+ });
493
+ }
494
+
495
+
496
+ private addCommandMessage(msg: MessageModel){
497
+ const that = this;
498
+ const commands = msg.attributes.commands;
499
+ let i=0;
500
+ function execute(command){
501
+ if(command.type === "message"){
502
+ that.logger.debug('[FIREBASEConversationHandlerSERVICE] addCommandMessage --> type="message"', command, i)
503
+ if (i >= 2) {
504
+
505
+ //check if previus wait message type has time value, otherwize set to 1000ms
506
+ !commands[i-1].time? commands[i-1].time= 1000 : commands[i-1].time
507
+ command.message.timestamp = commands[i-2].message.timestamp + commands[i-1].time;
508
+
509
+ /** CHECK IF MESSAGE IS JUST RECEIVED: IF false, set next message time (if object exist) to 0 -> this allow to show it immediately */
510
+ if(!isJustRecived(that.startTime.getTime(), msg.timestamp)){
511
+ let previewsTimeMsg = msg.timestamp;
512
+ commands[i-2]? previewsTimeMsg = commands[i-2].message.timestamp : null;
513
+ command.message.timestamp = previewsTimeMsg + 100
514
+ commands[i+1]? commands[i+1].time = 0 : null
515
+ }
516
+ } else { /**MANAGE FIRST MESSAGE */
517
+ command.message.timestamp = msg.timestamp;
518
+ if(!isJustRecived(that.startTime.getTime(), msg.timestamp)){
519
+ commands[i+1]? commands[i+1].time = 0 : null
520
+ }
521
+ }
522
+ that.generateMessageObject(msg, command.message, function () {
523
+ i += 1
524
+ if (i < commands.length) {
525
+ execute(commands[i])
493
526
  }
494
- that.generateMessageObject(msg, command.message, function () {
495
- i += 1
496
- if (i < commands.length) {
497
- execute(commands[i])
498
- }
499
- else {
500
- that.logger.debug('[FIREBASEConversationHandlerSERVICE] addCommandMessage --> last command executed (wait), exit')
501
- }
502
- })
503
- }else if(command.type === "wait"){
504
- that.logger.debug('[FIREBASEConversationHandlerSERVICE] addCommandMessage --> type="wait"', command, i, commands.length)
505
- //publish waiting event to simulate user typing
506
- if(isJustRecived(that.startTime.getTime(), msg.timestamp)){
507
- that.messageWait.next({uid: that.conversationWith, uidUserTypingNow: msg.sender, nameUserTypingNow: msg.sender_fullname, waitTime: command.time, command: command})
527
+ else {
528
+ that.logger.debug('[FIREBASEConversationHandlerSERVICE] addCommandMessage --> last command executed (wait), exit')
508
529
  }
509
- setTimeout(function() {
510
- i += 1
511
- if (i < commands.length) {
512
- execute(commands[i])
513
- }
514
- else {
515
- that.logger.debug('[FIREBASEConversationHandlerSERVICE] addCommandMessage --> last command executed (send message), exit')
516
- }
517
- },command.time)
530
+ })
531
+ }else if(command.type === "wait"){
532
+ that.logger.debug('[FIREBASEConversationHandlerSERVICE] addCommandMessage --> type="wait"', command, i, commands.length)
533
+ //publish waiting event to simulate user typing
534
+ if(isJustRecived(that.startTime.getTime(), msg.timestamp)){
535
+ that.messageWait.next({uid: that.conversationWith, uidUserTypingNow: msg.sender, nameUserTypingNow: msg.sender_fullname, waitTime: command.time, command: command})
518
536
  }
537
+ setTimeout(function() {
538
+ i += 1
539
+ if (i < commands.length) {
540
+ execute(commands[i])
541
+ }
542
+ else {
543
+ that.logger.debug('[FIREBASEConversationHandlerSERVICE] addCommandMessage --> last command executed (send message), exit')
544
+ }
545
+ },command.time)
519
546
  }
520
- execute(commands[0]) //START render first message
521
547
  }
548
+ execute(commands[0]) //START render first message
549
+ }
522
550
 
523
- private generateMessageObject(message, command_message, callback) {
524
- let parentUid = message.uid
525
- command_message.uid = uuidv4();
526
- if(command_message.text) command_message.text = command_message.text.trim()//remove black msg with only spaces
527
- command_message.language = message.language;
528
- command_message.recipient = message.recipient;
529
- command_message.recipient_fullname = message.recipient_fullname;
530
- command_message.sender = message.sender;
531
- command_message.sender_fullname = message.sender_fullname;
532
- command_message.channel_type = message.channel_type;
533
- command_message.status = message.status;
534
- command_message.isSender = message.isSender;
535
- command_message.attributes? command_message.attributes.commands = true : command_message.attributes = {commands : true}
536
- command_message.attributes.parentUid = parentUid //added to manage message STATUS UPDATES
537
- this.addedNew(command_message)
538
- callback();
539
- }
551
+ private generateMessageObject(message, command_message, callback) {
552
+ let parentUid = message.uid
553
+ command_message.uid = uuidv4();
554
+ if(command_message.text) command_message.text = command_message.text.trim()//remove black msg with only spaces
555
+ command_message.language = message.language;
556
+ command_message.recipient = message.recipient;
557
+ command_message.recipient_fullname = message.recipient_fullname;
558
+ command_message.sender = message.sender;
559
+ command_message.sender_fullname = message.sender_fullname;
560
+ command_message.channel_type = message.channel_type;
561
+ command_message.status = message.status;
562
+ command_message.isSender = message.isSender;
563
+ command_message.attributes? command_message.attributes.commands = true : command_message.attributes = {commands : true}
564
+ command_message.attributes.parentUid = parentUid //added to manage message STATUS UPDATES
565
+ this.addedNew(command_message)
566
+ callback();
567
+ }
540
568
 
541
569
 
542
570
  private isValidMessage(msgToCkeck:MessageModel): boolean{
@@ -180,8 +180,4 @@ export class FirebasePresenceService extends PresenceService {
180
180
  return connectionsRef;
181
181
  }
182
182
 
183
- public imHere(){
184
- //NOT IMPLEMENTED FOR FIREBASE ENGINE
185
- }
186
-
187
183
  }
@@ -24,7 +24,7 @@ import {
24
24
  conversationMessagesRef
25
25
  } from '../../utils/utils';
26
26
  import { v4 as uuidv4 } from 'uuid';
27
- import { messageType, checkIfIsMemberJoinedGroup, hideInfoMessage, isJustRecived, isSender } from '../../utils/utils-message';
27
+ import { messageType, checkIfIsMemberJoinedGroup, hideInfoMessage, isJustRecived } from '../../utils/utils-message';
28
28
 
29
29
 
30
30
  // @Injectable({ providedIn: 'root' })
@@ -308,7 +308,7 @@ export class MQTTConversationHandler extends ConversationHandlerService {
308
308
  // }
309
309
  // verifico che il sender è il logged user
310
310
  this.logger.log("[MQTTConversationHandlerSERVICE] ****>msg.sender:" + msg.sender);
311
- msg.isSender = isSender(msg.sender, this.loggedUser.uid);
311
+ msg.isSender = this.isSender(msg.sender, this.loggedUser.uid);
312
312
  // traduco messaggi se sono del server
313
313
  if (messageType(MESSAGE_TYPE_INFO, msg)) {
314
314
  this.translateInfoSupportMessages(msg);
@@ -420,6 +420,33 @@ export class MQTTConversationHandler extends ConversationHandlerService {
420
420
  }
421
421
  }
422
422
 
423
+ /**
424
+ * controllo se il messaggio è stato inviato da loggerUser
425
+ * richiamato dalla pagina elenco messaggi della conversazione
426
+ */
427
+ private isSender(sender: string, currentUserId: string) {
428
+ if (currentUserId) {
429
+ if (sender === currentUserId) {
430
+ return true;
431
+ } else {
432
+ return false;
433
+ }
434
+ } else {
435
+ return false;
436
+ }
437
+ }
438
+
439
+
440
+ /** */
441
+ // updateMetadataMessage(uid: string, metadata: any) {
442
+ // metadata.status = true;
443
+ // const message = {
444
+ // metadata: metadata
445
+ // };
446
+ // const firebaseMessages = firebase.database().ref(this.urlNodeFirebase + uid);
447
+ // firebaseMessages.set(message);
448
+ // }
449
+
423
450
 
424
451
  unsubscribe(key: string) {
425
452
  this.logger.log('[MQTTConversationHandlerSERVICE] unsubscribe: ', key);
@@ -1,4 +1,3 @@
1
- import { Chat21Service } from 'src/chat21-core/providers/mqtt/chat-service';
2
1
  import { Injectable } from '@angular/core';
3
2
  import { BehaviorSubject, Observable } from 'rxjs';
4
3
 
@@ -20,7 +19,6 @@ import { LoggerInstance } from '../logger/loggerInstance';
20
19
  // @Injectable({ providedIn: 'root' })
21
20
  @Injectable()
22
21
  export class MQTTPresenceService extends PresenceService {
23
-
24
22
 
25
23
  // BehaviorSubject
26
24
  BSIsOnline: BehaviorSubject<any> = new BehaviorSubject<any>(null);
@@ -32,7 +30,7 @@ export class MQTTPresenceService extends PresenceService {
32
30
  private logger: LoggerService = LoggerInstance.getInstance();
33
31
 
34
32
  constructor(
35
- public chat21Service: Chat21Service
33
+ // private events: EventsService
36
34
  ) {
37
35
  super();
38
36
  }
@@ -49,11 +47,40 @@ export class MQTTPresenceService extends PresenceService {
49
47
  }
50
48
 
51
49
  lastOnlineForUser(userid: string) {
52
-
50
+ // console.log('lastOnlineForUser', userid);
51
+ // const that = this;
52
+ // const urlNodeLastOnLine = this.urlNodePresence + userid + '/lastOnline';
53
+ // console.log('urlNodeLastOnLine: ', urlNodeLastOnLine);
54
+ // const lastOnlineRef = firebase.database().ref().child(urlNodeLastOnLine);
55
+ // lastOnlineRef.on('value', (child) => {
56
+ // if (child.val()) {
57
+ // that.events.publish('last-connection-date-' + userid, userid, child.val());
58
+ // } else {
59
+ // that.events.publish('last-connection-date-' + userid, userid, '');
60
+ // }
61
+ // });
53
62
  }
54
63
 
55
64
  public setPresence(userid: string): void {
56
-
65
+ // console.log(' setPresence: ', userid);
66
+ // this.onlineConnectionsRef = this.referenceOnlineForUser(userid);
67
+ // this.lastOnlineConnectionsRef = this.referenceLastOnlineForUser(userid);
68
+ // const connectedRefURL = '/.info/connected';
69
+ // const conn = firebase.database().ref(connectedRefURL);
70
+ // conn.on('value', (dataSnapshot) => {
71
+ // // console.log('self.deviceConnectionRef: ', dataSnapshot.val());
72
+ // if (dataSnapshot.val()) {
73
+ // if (this.onlineConnectionsRef) {
74
+ // this.keyConnectionRef = this.onlineConnectionsRef.push(true);
75
+ // this.keyConnectionRef.onDisconnect().remove();
76
+ // const now: Date = new Date();
77
+ // const timestamp = now.valueOf();
78
+ // this.lastOnlineConnectionsRef.onDisconnect().set(timestamp);
79
+ // } else {
80
+ // console.log('This is an error. self.deviceConnectionRef already set. Cannot be set again.');
81
+ // }
82
+ // }
83
+ // });
57
84
  }
58
85
 
59
86
  /**
@@ -61,14 +88,130 @@ export class MQTTPresenceService extends PresenceService {
61
88
  * richiamato prima del logout
62
89
  */
63
90
  public removePresence(): void {
64
-
65
- }
66
-
67
- public imHere(): void {
68
- this.logger.debug('[MQTT-PRESENCE] imHere', this.tenant);
69
- setTimeout(() => {
70
- this.chat21Service.chatClient.ImHere()
71
- }, 2000);
91
+ // if (this.onlineConnectionsRef) {
92
+ // const now: Date = new Date();
93
+ // const timestamp = now.valueOf();
94
+ // this.lastOnlineConnectionsRef.set(timestamp);
95
+ // this.onlineConnectionsRef.off();
96
+ // this.onlineConnectionsRef.remove();
97
+ // console.log('goOffline onlineConnectionsRef', this.onlineConnectionsRef);
98
+ // }
72
99
  }
73
100
 
74
101
  }
102
+
103
+
104
+ /**
105
+ * controlla se esiste una connessione per l'utente analizzato,
106
+ * verificando se esiste un nodo in presence/uid/connections
107
+ * mi sottosrivo al nodo
108
+ * se non esiste pubblico utente offline
109
+ * se esiste pubblico utente online
110
+ * @param userid
111
+ */
112
+
113
+
114
+ /**
115
+ * mi sottoscrivo al nodo presence/uid/lastOnline
116
+ * e recupero la data dell'ultimo stato online
117
+ * pubblico lastConnectionDate
118
+ * @param userid
119
+ */
120
+
121
+
122
+ /**
123
+ * calcolo tempo trascorso tra ora e timestamp passato
124
+ * @param timestamp
125
+ */
126
+
127
+
128
+ // /**
129
+ // * recupero la reference di lastOnline del currentUser
130
+ // * usata in setupMyPresence
131
+ // * @param userid
132
+ // */
133
+ // lastOnlineRefForUser(userid){
134
+ // let lastOnlineRefURL = this.urlNodeFirebase+"/presence/"+userid+"/lastOnline";
135
+ // const lastOnlineRef = firebase.database().ref().child(lastOnlineRefURL);
136
+ // return lastOnlineRef;
137
+ // }
138
+
139
+ // /**
140
+ // * recupero la reference di connections (online/offline) del currentUser
141
+ // * usata in setupMyPresence
142
+ // * @param userid
143
+ // */
144
+ // onlineRefForUser(userid){
145
+ // let myConnectionsRefURL = this.urlNodeFirebase+"/presence/"+userid+"/connections";
146
+ // const connectionsRef = firebase.database().ref().child(myConnectionsRefURL);
147
+ // return connectionsRef;
148
+ // }
149
+
150
+ // /**
151
+ // * 1 - imposto reference online/offline
152
+ // * 2 - imposto reference lastConnection
153
+ // * 3 - mi sincronizzo con /.info/connected
154
+ // * 4 - se il valore esiste l'utente è online
155
+ // * 5 - aggiungo nodo a connection (true)
156
+ // * 6 - aggiungo job su onDisconnect di deviceConnectionRef che rimuove nodo connection
157
+ // * 7 - aggiungo job su onDisconnect di lastOnlineRef che imposta timestamp
158
+ // * 8 - salvo reference connected nel singlelton !!!!! DA FARE
159
+ // * @param userid
160
+ // */
161
+ // setupMyPresence(userid){
162
+ // let that = this;
163
+ // this.myConnectionsRef = this.onlineRefForUser(userid);
164
+ // this.lastOnlineRef = this.lastOnlineRefForUser(userid);
165
+ // let connectedRefURL = "/.info/connected";
166
+ // let conn = firebase.database().ref(connectedRefURL);
167
+ // conn.on('value', function(dataSnapshot) {
168
+ // //console.log("KEY: ",dataSnapshot,that.deviceConnectionRef);
169
+ // if(dataSnapshot.val()){
170
+ // console.log("self.deviceConnectionRef: ", that.myConnectionsRef);
171
+ // //if (!that.myConnectionsRef || that.myConnectionsRef==='undefined') {
172
+ // if (that.myConnectionsRef) {
173
+ // //this.deviceConnectionRef = myConnectionsRef.set(true);
174
+ // let conection = true;
175
+ // //that.deviceConnectionRef =
176
+ // const keyMyConnectionRef = that.myConnectionsRef.push(conection);
177
+ // //!!! quando faccio logout devo disconnettermi
178
+ // keyMyConnectionRef.onDisconnect().remove();
179
+ // // when I disconnect, update the last time I was seen online
180
+ // let now: Date = new Date();
181
+ // let timestamp = now.valueOf();
182
+ // that.lastOnlineRef.onDisconnect().set(timestamp);
183
+ // } else {
184
+ // console.log("This is an error. self.deviceConnectionRef already set. Cannot be set again.");
185
+ // }
186
+ // }
187
+ // });
188
+ // }
189
+
190
+ /**
191
+ * rimuovo la references su lastOnline
192
+ * rimuovo la references su connection
193
+ */
194
+ // goOffline() {
195
+ // console.log("goOffline.", this.myConnectionsRef)
196
+ // // this.removeConnectionReference();
197
+ // this.removeLastOnlineReference();
198
+ // }
199
+
200
+ // removeConnectionReference(){
201
+ // if(this.myConnectionsRef){
202
+ // this.myConnectionsRef.off();
203
+ // console.log("goOffline 1", this.myConnectionsRef)
204
+ // this.myConnectionsRef.remove();
205
+ // console.log("goOffline 2", this.myConnectionsRef)
206
+ // }
207
+ // this.myConnectionsRef = null;
208
+ // }
209
+
210
+ // removeLastOnlineReference(){
211
+ // if(this.lastOnlineRef){
212
+ // this.lastOnlineRef.off();
213
+ // this.lastOnlineRef.remove();
214
+ // }
215
+ // this.lastOnlineRef = null;
216
+ // }
217
+ // }
@@ -1,6 +1,5 @@
1
1
  import { HttpClient, HttpHeaders } from '@angular/common/http';
2
2
  import { Injectable } from '@angular/core';
3
- import { map } from 'rxjs/operators';
4
3
  import { AppStorageService } from '../abstract/app-storage.service';
5
4
  import { LoggerService } from '../abstract/logger.service';
6
5
  import { LoggerInstance } from '../logger/loggerInstance';
@@ -12,7 +11,7 @@ export class TiledeskRequestsService {
12
11
  public SERVER_BASE_URL: string;
13
12
 
14
13
  // private
15
- private URL_TILEDESK_REQUEST: string;
14
+ private URL_TILEDESK_CLOSE_REQUEST: string;
16
15
  private tiledeskToken: string;
17
16
 
18
17
  private logger: LoggerService = LoggerInstance.getInstance()
@@ -25,7 +24,7 @@ export class TiledeskRequestsService {
25
24
  initialize(serverBaseUrl: string, projectId: string,) {
26
25
  this.logger.debug('[TILEDESK-REQUEST-SERV] - initialize', projectId);
27
26
  this.SERVER_BASE_URL = serverBaseUrl;
28
- this.URL_TILEDESK_REQUEST = this.SERVER_BASE_URL + projectId +'/requests/';
27
+ this.URL_TILEDESK_CLOSE_REQUEST = this.SERVER_BASE_URL + projectId +'/requests/';
29
28
  }
30
29
 
31
30
 
@@ -38,8 +37,8 @@ export class TiledeskRequestsService {
38
37
  Authorization: this.tiledeskToken,
39
38
  });
40
39
  const requestOptions = { headers: headers };
41
-
42
- const url = this.URL_TILEDESK_REQUEST + supportgroupid + '/closeg'
40
+ const that = this;
41
+ const url = this.URL_TILEDESK_CLOSE_REQUEST + supportgroupid + '/closeg'
43
42
  return new Promise((resolve, reject) => {
44
43
  this.logger.debug('[TILEDESK-REQUEST-SERV] - closeSupportGroup URLLLL', url, requestOptions);
45
44
  this.http.put(url, null, requestOptions).subscribe((data) => {
@@ -50,20 +49,4 @@ export class TiledeskRequestsService {
50
49
  });
51
50
  });
52
51
  }
53
-
54
- public sendMessageToRequest(request_id: string, token: string, message: any): Promise<any> {
55
- const url = this.URL_TILEDESK_REQUEST + request_id + '/messages'
56
- this.logger.log('[TILEDESK-SERVICE] - SEND MESSAGE TO A REQUEST url ', url);
57
- const httpOptions = {
58
- headers: new HttpHeaders({
59
- 'Content-Type': 'application/json',
60
- Authorization: token
61
- })
62
- };
63
- const body = message;
64
- return this.http.post(url, body, httpOptions).toPromise().then(res => {
65
- this.logger.log('[TILEDESK-SERVICE] - SEND MESSAGE TO A REQUEST res ', res);
66
- return res
67
- })
68
- }
69
52
  }
@@ -1,7 +1,3 @@
1
- import { convertMessage } from 'src/app/utils/utils';
2
- import { MessageModel } from './../models/message';
3
- import { ConversationModel } from './../models/conversation';
4
- import { v4 as uuidv4 } from 'uuid';
5
1
  import {
6
2
  MESSAGE_TYPE_INFO,
7
3
  MESSAGE_TYPE_MINE,
@@ -73,18 +69,6 @@ export function isMine(message: any) {
73
69
  return false;
74
70
  }
75
71
 
76
- export function isSender(sender: string, currentUserId: string) {
77
- if (currentUserId) {
78
- if (sender === currentUserId) {
79
- return true;
80
- } else {
81
- return false;
82
- }
83
- } else {
84
- return false;
85
- }
86
- }
87
-
88
72
  /** */
89
73
  export function messageType(msgType: string, message: any) {
90
74
 
@@ -193,23 +177,3 @@ export function hideInfoMessage(msg, infoMessageKeyEnabled): boolean{
193
177
  }
194
178
  return true
195
179
  }
196
-
197
-
198
- export function conversationToMessage(conversation: ConversationModel, currentUserId: string): MessageModel{
199
- let message: any = {}
200
- message.uid = conversation['message_id']? conversation['message_id'] : uuidv4()
201
- message.text = conversation.text? conversation.text.trim(): conversation.last_message_text.trim()
202
- message.sender = conversation.sender
203
- message.sender_fullname = conversation.sender_fullname
204
- message.recipient = conversation.recipient
205
- message.recipient_fullname = conversation.recipient_fullname
206
- message.status = +conversation.status
207
- message.timestamp = conversation.timestamp
208
- message.metadata = conversation['metadata']
209
- message.channel_type = conversation.channel_type
210
- message.type = conversation.type
211
- message.isSender = isSender(message.sender, currentUserId)
212
- message.attributes = conversation.attributes
213
-
214
- return message as MessageModel
215
- }
@@ -69,8 +69,8 @@
69
69
  max-width: 400px;
70
70
  }
71
71
  #tiledesk-container.closed #tiledeskdiv.messagePreview {
72
- width: 375px; /*340px*/
73
- height: 400px; /*300px*/
72
+ width: 340px;
73
+ height: 300px;
74
74
  min-width: 340px;
75
75
  }
76
76
 
@@ -1,5 +1,3 @@
1
- import { IRules } from './rule';
2
-
3
1
  export class ProjectModel {
4
2
  constructor(
5
3
  public id?: string,
@@ -24,7 +22,6 @@ export class ProjectModel {
24
22
  public color?: string,
25
23
  public welcomeTitle?: string,
26
24
  public welcomeMsg?: string,
27
- public attributes?: IRules
28
25
  ) { }
29
26
 
30
27
  initialize (
@@ -43,7 +40,7 @@ export class ProjectModel {
43
40
  trialDaysLeft?: number,
44
41
  trialExpired?: boolean,
45
42
  updatedAt?: string,
46
- versions?: string,
43
+ versions?: string
47
44
  ) {
48
45
  this.id = id;
49
46
  this.activeOperatingHours = activeOperatingHours;
@@ -1,16 +0,0 @@
1
- import { TestBed } from '@angular/core/testing';
2
-
3
- import { EventsService } from './events.service';
4
-
5
- describe('EventsService', () => {
6
- let service: EventsService;
7
-
8
- beforeEach(() => {
9
- TestBed.configureTestingModule({});
10
- service = TestBed.inject(EventsService);
11
- });
12
-
13
- it('should be created', () => {
14
- expect(service).toBeTruthy();
15
- });
16
- });