@chat21/chat21-web-widget 5.0.53-rc.3 → 5.0.53-rc.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/CHANGELOG.md +15 -2
- package/package.json +1 -1
- package/src/app/app.component.ts +18 -8
- package/src/app/app.module.ts +10 -8
- package/src/app/component/conversation-detail/conversation/conversation.component.ts +15 -1
- package/src/app/component/conversation-detail/conversation-content/conversation-content.component.spec.ts +2 -2
- package/src/app/component/last-message/last-message.component.html +83 -72
- package/src/app/component/last-message/last-message.component.scss +98 -42
- package/src/app/component/last-message/last-message.component.spec.ts +2 -2
- package/src/app/component/last-message/last-message.component.ts +49 -25
- package/src/app/component/list-all-conversations/list-all-conversations.component.ts +1 -1
- package/src/app/component/message/bubble-message/bubble-message.component.html +0 -5
- package/src/app/component/message/html/html.component.spec.ts +1 -1
- package/src/app/component/message/info-message/info-message.component.spec.ts +1 -1
- package/src/app/component/message/text/text.component.scss +4 -0
- package/src/app/component/message/text/text.component.spec.ts +2 -2
- package/src/app/component/message-attachment/message-attachment.component.html +1 -1
- package/src/app/component/message-attachment/message-attachment.component.ts +2 -0
- package/src/app/{directives → pipe}/html-entites-encode.pipe.spec.ts +0 -0
- package/src/app/{directives → pipe}/html-entities-encode.pipe.ts +0 -0
- package/src/app/{directives → pipe}/marked.pipe.spec.ts +0 -0
- package/src/app/{directives → pipe}/marked.pipe.ts +0 -0
- package/src/app/{directives → pipe}/safe-html.pipe.spec.ts +0 -0
- package/src/app/{directives → pipe}/safe-html.pipe.ts +0 -0
- package/src/app/providers/events.service.spec.ts +16 -0
- package/src/app/providers/events.service.ts +76 -0
- package/src/app/providers/global-settings.service.ts +11 -12
- package/src/app/utils/globals.ts +4 -1
- package/src/app/utils/rules.ts +88 -5
- package/src/assets/js/chat21client.js +27 -4
- package/src/assets/twp/chatbot-panel.html +0 -5
- package/src/chat21-core/models/conversation.ts +2 -2
- package/src/chat21-core/models/upload.ts +1 -0
- package/src/chat21-core/providers/abstract/presence.service.ts +1 -0
- package/src/chat21-core/providers/firebase/firebase-conversation-handler.ts +78 -106
- package/src/chat21-core/providers/firebase/firebase-presence.service.ts +4 -0
- package/src/chat21-core/providers/mqtt/mqtt-conversation-handler.ts +2 -29
- package/src/chat21-core/providers/mqtt/mqtt-presence.service.ts +13 -156
- package/src/chat21-core/providers/tiledesk/tiledesk-requests.service.ts +21 -4
- package/src/chat21-core/utils/utils-message.ts +36 -0
- package/src/iframe-style.css +2 -2
- package/src/models/project.ts +4 -1
- package/src/models/rule.ts +18 -0
|
@@ -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 =
|
|
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 =
|
|
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,91 @@ export class FirebaseConversationHandler extends ConversationHandlerService {
|
|
|
453
452
|
}
|
|
454
453
|
}
|
|
455
454
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
return
|
|
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
|
-
}
|
|
468
|
-
return false;
|
|
469
|
-
}
|
|
464
|
+
});
|
|
470
465
|
}
|
|
471
466
|
|
|
472
467
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
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
|
-
|
|
528
|
-
|
|
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
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
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
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
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
|
+
this.addedNew(command_message)
|
|
538
|
+
callback();
|
|
539
|
+
}
|
|
568
540
|
|
|
569
541
|
|
|
570
542
|
private isValidMessage(msgToCkeck:MessageModel): boolean{
|
|
@@ -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' })
|
|
@@ -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 =
|
|
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);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Chat21Service } from 'src/chat21-core/providers/mqtt/chat-service';
|
|
1
2
|
import { Injectable } from '@angular/core';
|
|
2
3
|
import { BehaviorSubject, Observable } from 'rxjs';
|
|
3
4
|
|
|
@@ -19,6 +20,7 @@ import { LoggerInstance } from '../logger/loggerInstance';
|
|
|
19
20
|
// @Injectable({ providedIn: 'root' })
|
|
20
21
|
@Injectable()
|
|
21
22
|
export class MQTTPresenceService extends PresenceService {
|
|
23
|
+
|
|
22
24
|
|
|
23
25
|
// BehaviorSubject
|
|
24
26
|
BSIsOnline: BehaviorSubject<any> = new BehaviorSubject<any>(null);
|
|
@@ -30,7 +32,7 @@ export class MQTTPresenceService extends PresenceService {
|
|
|
30
32
|
private logger: LoggerService = LoggerInstance.getInstance();
|
|
31
33
|
|
|
32
34
|
constructor(
|
|
33
|
-
|
|
35
|
+
public chat21Service: Chat21Service
|
|
34
36
|
) {
|
|
35
37
|
super();
|
|
36
38
|
}
|
|
@@ -47,40 +49,11 @@ export class MQTTPresenceService extends PresenceService {
|
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
lastOnlineForUser(userid: string) {
|
|
50
|
-
|
|
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
|
-
// });
|
|
52
|
+
|
|
62
53
|
}
|
|
63
54
|
|
|
64
55
|
public setPresence(userid: string): void {
|
|
65
|
-
|
|
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
|
-
// });
|
|
56
|
+
|
|
84
57
|
}
|
|
85
58
|
|
|
86
59
|
/**
|
|
@@ -88,130 +61,14 @@ export class MQTTPresenceService extends PresenceService {
|
|
|
88
61
|
* richiamato prima del logout
|
|
89
62
|
*/
|
|
90
63
|
public removePresence(): void {
|
|
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
|
-
// }
|
|
99
|
-
}
|
|
100
|
-
|
|
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
64
|
|
|
65
|
+
}
|
|
127
66
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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
|
-
// }
|
|
67
|
+
public imHere(): void {
|
|
68
|
+
this.logger.debug('[MQTT-PRESENCE] imHere', this.tenant);
|
|
69
|
+
setTimeout(() => {
|
|
70
|
+
this.chat21Service.chatClient.ImHere()
|
|
71
|
+
}, 2000);
|
|
72
|
+
}
|
|
189
73
|
|
|
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
|
-
// }
|
|
74
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
|
2
2
|
import { Injectable } from '@angular/core';
|
|
3
|
+
import { map } from 'rxjs/operators';
|
|
3
4
|
import { AppStorageService } from '../abstract/app-storage.service';
|
|
4
5
|
import { LoggerService } from '../abstract/logger.service';
|
|
5
6
|
import { LoggerInstance } from '../logger/loggerInstance';
|
|
@@ -11,7 +12,7 @@ export class TiledeskRequestsService {
|
|
|
11
12
|
public SERVER_BASE_URL: string;
|
|
12
13
|
|
|
13
14
|
// private
|
|
14
|
-
private
|
|
15
|
+
private URL_TILEDESK_REQUEST: string;
|
|
15
16
|
private tiledeskToken: string;
|
|
16
17
|
|
|
17
18
|
private logger: LoggerService = LoggerInstance.getInstance()
|
|
@@ -24,7 +25,7 @@ export class TiledeskRequestsService {
|
|
|
24
25
|
initialize(serverBaseUrl: string, projectId: string,) {
|
|
25
26
|
this.logger.debug('[TILEDESK-REQUEST-SERV] - initialize', projectId);
|
|
26
27
|
this.SERVER_BASE_URL = serverBaseUrl;
|
|
27
|
-
this.
|
|
28
|
+
this.URL_TILEDESK_REQUEST = this.SERVER_BASE_URL + projectId +'/requests/';
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
|
|
@@ -37,8 +38,8 @@ export class TiledeskRequestsService {
|
|
|
37
38
|
Authorization: this.tiledeskToken,
|
|
38
39
|
});
|
|
39
40
|
const requestOptions = { headers: headers };
|
|
40
|
-
|
|
41
|
-
const url = this.
|
|
41
|
+
|
|
42
|
+
const url = this.URL_TILEDESK_REQUEST + supportgroupid + '/closeg'
|
|
42
43
|
return new Promise((resolve, reject) => {
|
|
43
44
|
this.logger.debug('[TILEDESK-REQUEST-SERV] - closeSupportGroup URLLLL', url, requestOptions);
|
|
44
45
|
this.http.put(url, null, requestOptions).subscribe((data) => {
|
|
@@ -49,4 +50,20 @@ export class TiledeskRequestsService {
|
|
|
49
50
|
});
|
|
50
51
|
});
|
|
51
52
|
}
|
|
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
|
+
}
|
|
52
69
|
}
|
|
@@ -1,3 +1,7 @@
|
|
|
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';
|
|
1
5
|
import {
|
|
2
6
|
MESSAGE_TYPE_INFO,
|
|
3
7
|
MESSAGE_TYPE_MINE,
|
|
@@ -69,6 +73,18 @@ export function isMine(message: any) {
|
|
|
69
73
|
return false;
|
|
70
74
|
}
|
|
71
75
|
|
|
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
|
+
|
|
72
88
|
/** */
|
|
73
89
|
export function messageType(msgType: string, message: any) {
|
|
74
90
|
|
|
@@ -177,3 +193,23 @@ export function hideInfoMessage(msg, infoMessageKeyEnabled): boolean{
|
|
|
177
193
|
}
|
|
178
194
|
return true
|
|
179
195
|
}
|
|
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
|
+
}
|
package/src/iframe-style.css
CHANGED
package/src/models/project.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { IRules } from './rule';
|
|
2
|
+
|
|
1
3
|
export class ProjectModel {
|
|
2
4
|
constructor(
|
|
3
5
|
public id?: string,
|
|
@@ -22,6 +24,7 @@ export class ProjectModel {
|
|
|
22
24
|
public color?: string,
|
|
23
25
|
public welcomeTitle?: string,
|
|
24
26
|
public welcomeMsg?: string,
|
|
27
|
+
public attributes?: IRules
|
|
25
28
|
) { }
|
|
26
29
|
|
|
27
30
|
initialize (
|
|
@@ -40,7 +43,7 @@ export class ProjectModel {
|
|
|
40
43
|
trialDaysLeft?: number,
|
|
41
44
|
trialExpired?: boolean,
|
|
42
45
|
updatedAt?: string,
|
|
43
|
-
versions?: string
|
|
46
|
+
versions?: string,
|
|
44
47
|
) {
|
|
45
48
|
this.id = id;
|
|
46
49
|
this.activeOperatingHours = activeOperatingHours;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface IRules {
|
|
2
|
+
[id: string]:Rule[]
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export interface Rule {
|
|
6
|
+
uid: string,
|
|
7
|
+
name: string,
|
|
8
|
+
description?: string,
|
|
9
|
+
when: {
|
|
10
|
+
regexOption: string,
|
|
11
|
+
text: string,
|
|
12
|
+
urlMatches: string,
|
|
13
|
+
triggerEvery: number},
|
|
14
|
+
do: [
|
|
15
|
+
{wait: number},
|
|
16
|
+
{message: any}
|
|
17
|
+
]
|
|
18
|
+
}
|