@chat21/chat21-web-widget 5.0.53 → 5.0.54

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 (49) hide show
  1. package/CHANGELOG.md +35 -2
  2. package/deploy_amazon_prod.sh +11 -2
  3. package/package.json +1 -1
  4. package/src/app/app.component.html +1 -1
  5. package/src/app/app.component.ts +18 -8
  6. package/src/app/app.module.ts +10 -8
  7. package/src/app/component/conversation-detail/conversation/conversation.component.ts +15 -1
  8. package/src/app/component/conversation-detail/conversation-content/conversation-content.component.spec.ts +2 -2
  9. package/src/app/component/form/inputs/form-text/form-text.component.scss +3 -1
  10. package/src/app/component/form/inputs/form-textarea/form-textarea.component.scss +1 -1
  11. package/src/app/component/home-conversations/home-conversations.component.html +5 -3
  12. package/src/app/component/last-message/last-message.component.html +83 -72
  13. package/src/app/component/last-message/last-message.component.scss +119 -42
  14. package/src/app/component/last-message/last-message.component.spec.ts +2 -2
  15. package/src/app/component/last-message/last-message.component.ts +49 -25
  16. package/src/app/component/list-all-conversations/list-all-conversations.component.ts +1 -1
  17. package/src/app/component/message/bubble-message/bubble-message.component.html +0 -5
  18. package/src/app/component/message/html/html.component.spec.ts +1 -1
  19. package/src/app/component/message/info-message/info-message.component.spec.ts +1 -1
  20. package/src/app/component/message/text/text.component.scss +4 -0
  21. package/src/app/component/message/text/text.component.spec.ts +2 -2
  22. package/src/app/component/message-attachment/message-attachment.component.html +1 -1
  23. package/src/app/component/message-attachment/message-attachment.component.ts +2 -0
  24. package/src/app/{directives → pipe}/html-entites-encode.pipe.spec.ts +0 -0
  25. package/src/app/{directives → pipe}/html-entities-encode.pipe.ts +0 -0
  26. package/src/app/{directives → pipe}/marked.pipe.spec.ts +0 -0
  27. package/src/app/{directives → pipe}/marked.pipe.ts +0 -0
  28. package/src/app/{directives → pipe}/safe-html.pipe.spec.ts +0 -0
  29. package/src/app/{directives → pipe}/safe-html.pipe.ts +0 -0
  30. package/src/app/providers/events.service.spec.ts +16 -0
  31. package/src/app/providers/events.service.ts +76 -0
  32. package/src/app/providers/global-settings.service.ts +11 -12
  33. package/src/app/utils/globals.ts +3 -0
  34. package/src/app/utils/rules.ts +84 -5
  35. package/src/assets/js/chat21client.js +27 -4
  36. package/src/assets/twp/index.html +5 -5
  37. package/src/chat21-core/models/conversation.ts +2 -2
  38. package/src/chat21-core/models/upload.ts +1 -0
  39. package/src/chat21-core/providers/abstract/presence.service.ts +1 -0
  40. package/src/chat21-core/providers/firebase/firebase-conversation-handler.ts +79 -106
  41. package/src/chat21-core/providers/firebase/firebase-presence.service.ts +4 -0
  42. package/src/chat21-core/providers/mqtt/mqtt-conversation-handler.ts +8 -33
  43. package/src/chat21-core/providers/mqtt/mqtt-presence.service.ts +13 -156
  44. package/src/chat21-core/providers/tiledesk/tiledesk-auth.service.ts +5 -0
  45. package/src/chat21-core/providers/tiledesk/tiledesk-requests.service.ts +21 -4
  46. package/src/chat21-core/utils/utils-message.ts +36 -0
  47. package/src/iframe-style.css +2 -2
  48. package/src/models/project.ts +4 -1
  49. package/src/models/rule.ts +19 -0
@@ -1,13 +1,92 @@
1
+ import { AppStorageService } from 'src/chat21-core/providers/abstract/app-storage.service';
2
+ import { Globals } from './globals';
3
+ import { UserModel } from './../../chat21-core/models/user';
1
4
  import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
2
5
  import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
3
- export class Rules {
6
+ import { TiledeskAuthService } from 'src/chat21-core/providers/tiledesk/tiledesk-auth.service';
7
+ import { TiledeskRequestsService } from 'src/chat21-core/providers/tiledesk/tiledesk-requests.service';
8
+ import { Inject, Injectable } from '@angular/core';
9
+ import { IRules, Rule } from 'src/models/rule';
10
+ import { getDateDifference } from 'src/chat21-core/utils/utils';
11
+
4
12
 
5
- private url = window.location
13
+ @Injectable({
14
+ providedIn: 'root'
15
+ })
16
+ export class Rules {
6
17
 
18
+ private windowContext:Window = window
19
+ private tiledeskToken: string;
20
+ private currentUser: UserModel;
21
+ private request_id: string;
22
+ private rules: Rule[]
7
23
  private logger: LoggerService = LoggerInstance.getInstance()
8
- constructor(){}
24
+ constructor(
25
+ private tiledeskRequestsService: TiledeskRequestsService,
26
+ private appStorageService: AppStorageService,
27
+ private g: Globals
28
+ ){}
29
+
30
+
31
+ initRules(context: Window, tiledeskToken: string, currentUser: UserModel, request_id: string, rules:Rule[]){
32
+ this.logger.info('[RULES] initRules',context, currentUser, rules)
33
+ this.windowContext = context
34
+ this.tiledeskToken = tiledeskToken
35
+ this.currentUser = currentUser
36
+ this.request_id = request_id
37
+ this.rules = rules
38
+ this.checkRules()
39
+ }
40
+
41
+ checkRules(){
42
+ this.rules.forEach((rule, index)=>{
43
+ if(rule.when && new RegExp(rule.when.urlMatches).test(this.windowContext.location.href)){
44
+ if(this.checkIfAlreadyDone(rule)){
45
+ this.doAction(rule.do)
46
+ return;
47
+ }
48
+
49
+ }
50
+ })
51
+ }
9
52
 
10
- initRules(){
11
- console.log('locationnnnnnn', this.url)
53
+ private doAction(action: Rule['do']){
54
+ this.logger.info('[RULES] doAction', this.currentUser, action)
55
+ let message = action.filter(obj => Object.keys(obj).includes('message'))
56
+ if(message && message.length>0){
57
+ message[0]['message'].attributes = { ...this.g.attributes, ...message[0]['message'].attributes}
58
+ message[0]['message'].userAgent = this.g.attributes['client']
59
+ message[0]['message'].request_id = this.request_id
60
+ message[0]['message'].sourcePage = this.g.attributes['sourcePage']
61
+ message[0]['message'].language = this.g.lang
62
+ message[0]['message'].departmentid = this.g.attributes.departmentId
63
+ console.log('message[0]', message[0]['message'])
64
+ this.tiledeskRequestsService.sendMessageToRequest(this.request_id, this.tiledeskToken, message[0]['message'])
65
+ }
12
66
  }
67
+
68
+
69
+ private checkIfAlreadyDone(rule: Rule): boolean{
70
+ let storedRules = JSON.parse(this.appStorageService.getItem('_rules')) || {}
71
+ let canHandleAction: boolean = false
72
+ if(storedRules && storedRules.hasOwnProperty(rule.uid)){
73
+ let timeDifference = getDateDifference(storedRules[rule.uid], Date.now())
74
+ if(timeDifference.hours > rule.when.triggerEvery){
75
+ storedRules[rule.uid]= Date.now()
76
+ canHandleAction = true
77
+ }else{
78
+ canHandleAction = false
79
+ }
80
+ }else{
81
+ canHandleAction = true
82
+ storedRules[rule.uid]= Date.now()
83
+
84
+ }
85
+ this.appStorageService.setItem('_rules', JSON.stringify(storedRules))
86
+ return canHandleAction
87
+ }
88
+
89
+
90
+
91
+
13
92
  }
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  Chat21Client
3
3
 
4
- v0.1.12.3
4
+ v0.1.12.4
5
5
 
6
6
  @Author Andrea Sponziello
7
7
  (c) Tiledesk 2020
@@ -966,7 +966,7 @@ class Chat21Client {
966
966
  if (this.client) {
967
967
  this.client.end()
968
968
  }
969
- const presence_topic = 'apps/tilechat/users/' + this.user_id + '/presence/' + this.client_id
969
+ this.presence_topic = 'apps/tilechat/users/' + this.user_id + '/presence/' + this.client_id
970
970
  let options = {
971
971
  keepalive: 10,
972
972
  // protocolId: 'MQTT',
@@ -975,7 +975,7 @@ class Chat21Client {
975
975
  reconnectPeriod: 1000,
976
976
  // connectTimeout: 30 * 1000,
977
977
  will: {
978
- topic: presence_topic,
978
+ topic: this.presence_topic,
979
979
  payload: '{"disconnected":true}',
980
980
  qos: 1,
981
981
  retain: true
@@ -985,7 +985,7 @@ class Chat21Client {
985
985
  password: jwt,
986
986
  rejectUnauthorized: false
987
987
  }
988
- if (this.log) {console.log("starting mqtt connection with LWT on:", presence_topic, this.endpoint)}
988
+ if (this.log) {console.log("starting mqtt connection with LWT on:", this.presence_topic, this.endpoint)}
989
989
  // client = mqtt.connect('mqtt://127.0.0.1:15675/ws',options)
990
990
  this.client = mqtt.connect(this.endpoint,options)
991
991
 
@@ -999,6 +999,15 @@ class Chat21Client {
999
999
  callback();
1000
1000
  });
1001
1001
  }
1002
+ this.client.publish(
1003
+ this.presence_topic,
1004
+ JSON.stringify({connected: true}),
1005
+ null, (err) => {
1006
+ if (err) {
1007
+ console.error("Error con presence publish:", err);
1008
+ }
1009
+ }
1010
+ );
1002
1011
  }
1003
1012
  );
1004
1013
  this.client.on('reconnect',
@@ -1023,6 +1032,20 @@ class Chat21Client {
1023
1032
  );
1024
1033
  }
1025
1034
 
1035
+ ImHere() {
1036
+ if (this.client) {
1037
+ this.client.publish(
1038
+ this.presence_topic,
1039
+ JSON.stringify({connected: true}),
1040
+ null, (err) => {
1041
+ if (err) {
1042
+ console.error("Error on presence publish:", err);
1043
+ }
1044
+ }
1045
+ );
1046
+ }
1047
+ }
1048
+
1026
1049
  close(callback) {
1027
1050
  if (this.topic_inbox) {
1028
1051
  this.client.unsubscribe(this.topic_inbox, (err) => {
@@ -296,11 +296,11 @@
296
296
  document.getElementById("preloader").style.display = "none";
297
297
  }, 1000);
298
298
  //open widget after 3s if is closed
299
- setTimeout(() => {
300
- if(event_data && event_data.detail && event_data.detail.global && !event_data.detail.global.isOpen){
301
- window.Tiledesk('open')
302
- }
303
- }, 3000);
299
+ // setTimeout(() => {
300
+ // if(event_data && event_data.detail && event_data.detail.global && !event_data.detail.global.isOpen){
301
+ // window.Tiledesk('open')
302
+ // }
303
+ // }, 3000);
304
304
  });
305
305
 
306
306
  window.Tiledesk('onAuthStateChanged', function(event_data) {
@@ -20,6 +20,6 @@ export class ConversationModel {
20
20
  public color: string,
21
21
  public avatar: string,
22
22
  public archived: boolean,
23
- public type: string,
23
+ public type: string
24
24
  ) { }
25
- }
25
+ }
@@ -5,6 +5,7 @@ export class UploadModel {
5
5
  url: string;
6
6
  progress: number;
7
7
  createdAt: Date = new Date();
8
+
8
9
  constructor(file: File) {
9
10
  this.file = file;
10
11
  }
@@ -31,5 +31,6 @@ export abstract class PresenceService {
31
31
  abstract userIsOnline(userid: string): Observable<any>
32
32
  abstract lastOnlineForUser(userid: string): void;
33
33
  abstract setPresence(userid: string): void;
34
+ abstract imHere():void;
34
35
  abstract removePresence(): void;
35
36
  }
@@ -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 } from '../../utils/utils-message';
31
+ import { messageType, checkIfIsMemberJoinedGroup, hideInfoMessage, isJustRecived, isSender } from '../../utils/utils-message';
32
32
 
33
33
  // @Injectable({ providedIn: 'root' })
34
34
  @Injectable()
@@ -187,7 +187,6 @@ export class FirebaseConversationHandler extends ConversationHandlerService {
187
187
  type: typeMsg,
188
188
  attributes: attributes,
189
189
  channel_type: channelType
190
- // isSender: true
191
190
  });
192
191
 
193
192
  // const message = new MessageModel(
@@ -310,7 +309,7 @@ export class FirebaseConversationHandler extends ConversationHandlerService {
310
309
  // }
311
310
 
312
311
  // verifico che il sender è il logged user
313
- msg.isSender = this.isSender(msg.sender, this.loggedUser.uid);
312
+ msg.isSender = isSender(msg.sender, this.loggedUser.uid);
314
313
  //check if message contains only an emojii
315
314
  // msg.emoticon = isEmojii(msg.text)
316
315
 
@@ -335,7 +334,7 @@ export class FirebaseConversationHandler extends ConversationHandlerService {
335
334
  // }
336
335
 
337
336
  // verifico che il sender è il logged user
338
- msg.isSender = this.isSender(msg.sender, this.loggedUser.uid);
337
+ msg.isSender = isSender(msg.sender, this.loggedUser.uid);
339
338
  //check if message contains only an emojii
340
339
  // msg.emoticon = isEmojii(msg.text)
341
340
 
@@ -453,118 +452,92 @@ export class FirebaseConversationHandler extends ConversationHandlerService {
453
452
  }
454
453
  }
455
454
 
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;
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;
466
463
  }
467
- } else {
468
- return false;
469
- }
464
+ });
470
465
  }
471
466
 
472
467
 
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])
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
+ }
526
493
  }
527
- else {
528
- that.logger.debug('[FIREBASEConversationHandlerSERVICE] addCommandMessage --> last command executed (wait), exit')
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})
529
508
  }
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})
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)
536
518
  }
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)
546
519
  }
520
+ execute(commands[0]) //START render first message
547
521
  }
548
- execute(commands[0]) //START render first message
549
- }
550
522
 
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
- }
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
+ command_message.attributes = {...message.attributes, ...command_message.attributes}
538
+ this.addedNew(command_message)
539
+ callback();
540
+ }
568
541
 
569
542
 
570
543
  private isValidMessage(msgToCkeck:MessageModel): boolean{
@@ -180,4 +180,8 @@ export class FirebasePresenceService extends PresenceService {
180
180
  return connectionsRef;
181
181
  }
182
182
 
183
+ public imHere(){
184
+ //NOT IMPLEMENTED FOR FIREBASE ENGINE
185
+ }
186
+
183
187
  }
@@ -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 } from '../../utils/utils-message';
27
+ import { messageType, checkIfIsMemberJoinedGroup, hideInfoMessage, isJustRecived, isSender } from '../../utils/utils-message';
28
28
 
29
29
 
30
30
  // @Injectable({ providedIn: 'root' })
@@ -113,7 +113,7 @@ export class MQTTConversationHandler extends ConversationHandlerService {
113
113
  }
114
114
 
115
115
  if (msg.attributes && msg.attributes.commands ) {
116
- this.logger.debug('[MQTTConversationHandlerSERVICE] splitted message::::', this.messages)
116
+ this.logger.debug('[MQTTConversationHandlerSERVICE] splitted message::::', this.messages, msg)
117
117
  this.addCommandMessage(msg)
118
118
  } else {
119
119
  // this.logger.debug('[MQTTConversationHandlerSERVICE] NOT splitted message::::', msg)
@@ -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 = this.isSender(msg.sender, this.loggedUser.uid);
311
+ msg.isSender = 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,33 +420,6 @@ 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
-
450
423
 
451
424
  unsubscribe(key: string) {
452
425
  this.logger.log('[MQTTConversationHandlerSERVICE] unsubscribe: ', key);
@@ -485,7 +458,7 @@ export class MQTTConversationHandler extends ConversationHandlerService {
485
458
  commands[i+1]? commands[i+1].time = 0 : null
486
459
  }
487
460
  }
488
- that.generateMessageObject(msg, command.message, function () {
461
+ that.generateMessageObject(msg, command.message, i, function () {
489
462
  i += 1
490
463
  if (i < commands.length) {
491
464
  execute(commands[i])
@@ -515,9 +488,10 @@ export class MQTTConversationHandler extends ConversationHandlerService {
515
488
  execute(commands[0]) //START render first message
516
489
  }
517
490
 
518
- private generateMessageObject(message, command_message, callback) {
491
+ private generateMessageObject(message, command_message, index, callback) {
519
492
  let parentUid = message.uid
520
- command_message.uid = uuidv4();
493
+ // command_message.uid = uuidv4();
494
+ command_message.uid = message.uid + '_' + index
521
495
  if(command_message.text) command_message.text = command_message.text.trim()//remove black msg with only spaces
522
496
  command_message.language = message.language;
523
497
  command_message.recipient = message.recipient;
@@ -529,6 +503,7 @@ export class MQTTConversationHandler extends ConversationHandlerService {
529
503
  command_message.isSender = message.isSender;
530
504
  command_message.attributes? command_message.attributes.commands = true : command_message.attributes = {commands : true}
531
505
  command_message.attributes.parentUid = parentUid //added to manage message STATUS UPDATES
506
+ command_message.attributes = {...message.attributes, ...command_message.attributes}
532
507
  this.addedMessage(command_message)
533
508
  callback();
534
509
  }