@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.
- package/CHANGELOG.md +35 -2
- package/deploy_amazon_prod.sh +11 -2
- package/package.json +1 -1
- package/src/app/app.component.html +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/form/inputs/form-text/form-text.component.scss +3 -1
- package/src/app/component/form/inputs/form-textarea/form-textarea.component.scss +1 -1
- package/src/app/component/home-conversations/home-conversations.component.html +5 -3
- package/src/app/component/last-message/last-message.component.html +83 -72
- package/src/app/component/last-message/last-message.component.scss +119 -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 +3 -0
- package/src/app/utils/rules.ts +84 -5
- package/src/assets/js/chat21client.js +27 -4
- package/src/assets/twp/index.html +5 -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 +79 -106
- package/src/chat21-core/providers/firebase/firebase-presence.service.ts +4 -0
- package/src/chat21-core/providers/mqtt/mqtt-conversation-handler.ts +8 -33
- package/src/chat21-core/providers/mqtt/mqtt-presence.service.ts +13 -156
- package/src/chat21-core/providers/tiledesk/tiledesk-auth.service.ts +5 -0
- 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 +19 -0
|
@@ -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,19 @@
|
|
|
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
|
+
},
|
|
15
|
+
do: [
|
|
16
|
+
// {wait: number},
|
|
17
|
+
{message: any}
|
|
18
|
+
]
|
|
19
|
+
}
|