@chat21/chat21-web-widget 5.0.47 → 5.0.48-rc.2
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 +11 -0
- package/angular.json +2 -1
- package/dist/assets/images/{website mockup.jpg → website_mockup.jpg} +0 -0
- package/dist/assets/twp/chatbot-panel.html +2 -2
- package/dist/environments/real_data/widget-config-native-prod.json +27 -0
- package/dist/main.js +1 -1
- package/package.json +1 -1
- package/src/app/app.module.ts +1 -1
- package/src/app/component/home/home.component.ts +1 -1
- package/src/app/providers/global-settings.service.ts +8 -4
- package/src/app/utils/utils.ts +1 -0
- package/src/assets/images/{website mockup.jpg → website_mockup.jpg} +0 -0
- package/src/assets/twp/chatbot-panel.html +2 -2
- package/src/chat21-core/models/message.ts +0 -1
- package/src/chat21-core/providers/firebase/firebase-conversation-handler.ts +3 -3
- package/src/chat21-core/providers/mqtt/mqtt-conversation-handler.ts +128 -54
- package/src/chat21-core/utils/constants.ts +0 -1
- package/src/chat21-core/utils/utils-message.ts +1 -7
- package/src/chat21-core/utils/utils.ts +3 -0
- package/src/environments/real_data/widget-config-native-prod.json +27 -0
- package/src/models/message.ts +0 -2
package/package.json
CHANGED
package/src/app/app.module.ts
CHANGED
|
@@ -228,7 +228,7 @@ export function uploadFactory(http: HttpClient, appConfig: AppConfigService, app
|
|
|
228
228
|
const config = appConfig.getConfig()
|
|
229
229
|
if (config.uploadEngine === UPLOAD_ENGINE_NATIVE) {
|
|
230
230
|
const nativeUploadService = new NativeUploadService(http, appStorage)
|
|
231
|
-
nativeUploadService.setBaseUrl(config.
|
|
231
|
+
nativeUploadService.setBaseUrl(config.baseImageUrl)
|
|
232
232
|
return nativeUploadService
|
|
233
233
|
} else {
|
|
234
234
|
return new FirebaseUploadService();
|
|
@@ -105,7 +105,7 @@ export class HomeComponent implements OnInit, AfterViewInit {
|
|
|
105
105
|
|
|
106
106
|
openConversationOnPlatform(platform: "telegram" | "whatsapp" | "messanger" ){
|
|
107
107
|
if(platform === 'telegram'){
|
|
108
|
-
window.open('https://telegram.me'+this.g.telegramUsername, '_blank')
|
|
108
|
+
window.open('https://telegram.me/'+this.g.telegramUsername, '_blank')
|
|
109
109
|
}else if(platform === 'whatsapp'){
|
|
110
110
|
window.open('https://wa.me/'+this.g.whatsappNumber, '_blank')
|
|
111
111
|
}else if(platform=== 'messanger'){
|
|
@@ -1789,20 +1789,22 @@ export class GlobalSettingsService {
|
|
|
1789
1789
|
// }
|
|
1790
1790
|
// console.log('this.globals.offline_msg ::::', department['offline_msg']);
|
|
1791
1791
|
// console.log('this.globals.online_msg ::::', department['online_msg']);
|
|
1792
|
-
departments.splice(i, 1);
|
|
1792
|
+
// departments.splice(i, 1);
|
|
1793
|
+
this.globals.setParameter('departmentDefault', departments[i]);
|
|
1794
|
+
this.setDepartment(departments[i]);
|
|
1793
1795
|
return;
|
|
1794
1796
|
}
|
|
1795
1797
|
i++;
|
|
1796
1798
|
});
|
|
1797
|
-
this.globals.setParameter('departmentDefault', departments[0]);
|
|
1798
|
-
this.setDepartment(departments[0]);
|
|
1799
|
+
// this.globals.setParameter('departmentDefault', departments[0]);
|
|
1800
|
+
// this.setDepartment(departments[0]);
|
|
1799
1801
|
} else {
|
|
1800
1802
|
// DEPARTMENT DEFAULT NON RESTITUISCE RISULTATI !!!!
|
|
1801
1803
|
this.logger.error('[GLOBAL-SET] initDepartments > DEPARTMENT DEFAULT NON RESTITUISCE RISULTATI ::::');
|
|
1802
1804
|
// return;
|
|
1803
1805
|
}
|
|
1804
1806
|
|
|
1805
|
-
this.setDepartmentFromExternal(); // chiamata ridondante viene fatta nel setParameters come ultima operazione
|
|
1807
|
+
// this.setDepartmentFromExternal(); // chiamata ridondante viene fatta nel setParameters come ultima operazione
|
|
1806
1808
|
}
|
|
1807
1809
|
|
|
1808
1810
|
|
|
@@ -1828,6 +1830,8 @@ export class GlobalSettingsService {
|
|
|
1828
1830
|
}
|
|
1829
1831
|
this.logger.debug('[GLOBAL-SET] setDepartmentFromExternal > END departmentID ::::' + this.globals.departmentID + isValidID);
|
|
1830
1832
|
}
|
|
1833
|
+
//remove default department from list
|
|
1834
|
+
this.globals.departments = this.globals.departments.filter(obj => obj['default'] !== true)
|
|
1831
1835
|
}
|
|
1832
1836
|
|
|
1833
1837
|
/**
|
package/src/app/utils/utils.ts
CHANGED
|
File without changes
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
|
|
102
102
|
.mockup{
|
|
103
103
|
background-repeat: no-repeat;
|
|
104
|
-
background-image: url(../images/
|
|
104
|
+
background-image: url(../images/website_mockup.jpg);
|
|
105
105
|
background-size: calc(100% - 122px);
|
|
106
106
|
background-position-x: 50px;
|
|
107
107
|
background-position-y: 100px;
|
|
@@ -405,7 +405,7 @@
|
|
|
405
405
|
|
|
406
406
|
window.onload = function() {
|
|
407
407
|
document.getElementById("project_id").innerHTML = '"' + tiledesk_projectid + '"';
|
|
408
|
-
document.getElementById("project_name").innerHTML = project_name;
|
|
408
|
+
// document.getElementById("project_name").innerHTML = project_name;
|
|
409
409
|
|
|
410
410
|
if(role !== 'agent'){
|
|
411
411
|
document.getElementById("testPageButton").style.display = 'block'
|
|
@@ -251,7 +251,7 @@ export class FirebaseConversationHandler extends ConversationHandlerService {
|
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
253
|
|
|
254
|
-
|
|
254
|
+
|
|
255
255
|
|
|
256
256
|
this.addRepalceMessageInArray(msg.uid, msg);
|
|
257
257
|
this.messageAdded.next(msg);
|
|
@@ -411,7 +411,7 @@ export class FirebaseConversationHandler extends ConversationHandlerService {
|
|
|
411
411
|
message.text = INFO_A_NEW_SUPPORT_REQUEST_HAS_BEEN_ASSIGNED_TO_YOU + ': ' + textAfterColon;
|
|
412
412
|
}
|
|
413
413
|
} else if ((message.attributes.messagelabel && message.attributes.messagelabel.key === LEAD_UPDATED)) {
|
|
414
|
-
|
|
414
|
+
message.text = INFO_SUPPORT_LEAD_UPDATED;
|
|
415
415
|
} else if ((message.attributes.messagelabel && message.attributes.messagelabel.key === MEMBER_LEFT_GROUP)) {
|
|
416
416
|
let subject: string;
|
|
417
417
|
if (message.attributes.messagelabel.parameters.fullname) {
|
|
@@ -557,7 +557,7 @@ private generateMessageObject(message, command_message, callback) {
|
|
|
557
557
|
command_message.attributes.parentUid = parentUid //added to manage message STATUS UPDATES
|
|
558
558
|
this.addedNew(command_message)
|
|
559
559
|
callback();
|
|
560
|
-
|
|
560
|
+
}
|
|
561
561
|
|
|
562
562
|
|
|
563
563
|
private isValidMessage(msgToCkeck:MessageModel): boolean{
|
|
@@ -21,10 +21,10 @@ import {
|
|
|
21
21
|
htmlEntities,
|
|
22
22
|
compareValues,
|
|
23
23
|
searchIndexInArrayForUid,
|
|
24
|
-
setHeaderDate,
|
|
25
24
|
conversationMessagesRef
|
|
26
25
|
} from '../../utils/utils';
|
|
27
|
-
import {
|
|
26
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
27
|
+
import { messageType, checkIfIsMemberJoinedGroup, hideInfoMessage, isJustRecived } from '../../utils/utils-message';
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
// @Injectable({ providedIn: 'root' })
|
|
@@ -47,7 +47,6 @@ export class MQTTConversationHandler extends ConversationHandlerService {
|
|
|
47
47
|
// private variables
|
|
48
48
|
private translationMap: Map<string, string>; // LABEL_TODAY, LABEL_TOMORROW
|
|
49
49
|
private showInfoMessage: string[];
|
|
50
|
-
// private urlNodeFirebase: string;
|
|
51
50
|
private recipientId: string;
|
|
52
51
|
private recipientFullname: string;
|
|
53
52
|
private tenant: string;
|
|
@@ -55,8 +54,7 @@ export class MQTTConversationHandler extends ConversationHandlerService {
|
|
|
55
54
|
private senderId: string;
|
|
56
55
|
private listSubsriptions: any[];
|
|
57
56
|
private CLIENT_BROWSER: string;
|
|
58
|
-
private
|
|
59
|
-
|
|
57
|
+
private startTime: Date = new Date();
|
|
60
58
|
private logger: LoggerService = LoggerInstance.getInstance()
|
|
61
59
|
|
|
62
60
|
constructor(
|
|
@@ -71,7 +69,7 @@ export class MQTTConversationHandler extends ConversationHandlerService {
|
|
|
71
69
|
*/
|
|
72
70
|
initialize(recipientId: string, recipientFullName: string,loggedUser: UserModel,
|
|
73
71
|
tenant: string,translationMap: Map<string, string>, showInfoMessage: string[]) {
|
|
74
|
-
this.logger.log('[
|
|
72
|
+
this.logger.log('[MQTTConversationHandlerSERVICE] initWithRecipient:', tenant);
|
|
75
73
|
this.recipientId = recipientId;
|
|
76
74
|
this.recipientFullname = recipientFullName;
|
|
77
75
|
this.loggedUser = loggedUser;
|
|
@@ -96,37 +94,49 @@ export class MQTTConversationHandler extends ConversationHandlerService {
|
|
|
96
94
|
* mi sottoscrivo a change, removed, added
|
|
97
95
|
*/
|
|
98
96
|
connect() {
|
|
99
|
-
this.logger.log('[
|
|
97
|
+
this.logger.log('[MQTTConversationHandlerSERVICE] connecting conversation handler...');
|
|
100
98
|
if (this.conversationWith == null) {
|
|
101
|
-
this.logger.error('[
|
|
99
|
+
this.logger.error('[MQTTConversationHandlerSERVICE] cant connect invalid this.conversationWith', this.conversationWith);
|
|
102
100
|
return;
|
|
103
101
|
}
|
|
104
102
|
this.chat21Service.chatClient.lastMessages(this.conversationWith, (err, messages) => {
|
|
105
103
|
if (!err) {
|
|
106
|
-
messages.forEach(
|
|
107
|
-
this.addedMessage(msg);
|
|
104
|
+
messages.forEach(message => {
|
|
105
|
+
// this.addedMessage(msg);
|
|
106
|
+
const msg: MessageModel = message;
|
|
107
|
+
msg.uid = message.message_id;
|
|
108
|
+
if (msg.attributes && msg.attributes.commands) {
|
|
109
|
+
// this.logger.debug('[MQTTConversationHandlerSERVICE] splitted message::::', msg)
|
|
110
|
+
this.addCommandMessage(msg)
|
|
111
|
+
} else {
|
|
112
|
+
// this.logger.debug('[MQTTConversationHandlerSERVICE] NOT splitted message::::', msg)
|
|
113
|
+
this.addedMessage(msg)
|
|
114
|
+
}
|
|
108
115
|
});
|
|
109
116
|
}
|
|
110
117
|
});
|
|
111
118
|
const handler_message_added = this.chat21Service.chatClient.onMessageAddedInConversation(
|
|
112
119
|
this.conversationWith, (message, topic) => {
|
|
113
|
-
this.logger.log('[
|
|
114
|
-
this.addedMessage(
|
|
120
|
+
this.logger.log('[MQTTConversationHandlerSERVICE] message added:', message, 'on topic:', topic);
|
|
121
|
+
// this.addedMessage(msg);
|
|
122
|
+
const msg: MessageModel = message;
|
|
123
|
+
msg.uid = message.message_id;
|
|
124
|
+
|
|
125
|
+
if (msg.attributes && msg.attributes.commands) {
|
|
126
|
+
this.logger.debug('[MQTTConversationHandlerSERVICE] splitted message::::', msg)
|
|
127
|
+
this.addCommandMessage(msg)
|
|
128
|
+
} else {
|
|
129
|
+
this.logger.debug('[MQTTConversationHandlerSERVICE] NOT splitted message::::', msg)
|
|
130
|
+
this.addedMessage(msg)
|
|
131
|
+
}
|
|
115
132
|
});
|
|
116
133
|
const handler_message_updated = this.chat21Service.chatClient.onMessageUpdatedInConversation(
|
|
117
134
|
this.conversationWith, (message, topic) => {
|
|
118
|
-
this.logger.log('[
|
|
135
|
+
this.logger.log('[MQTTConversationHandlerSERVICE] message updated:', message, 'on topic:', topic);
|
|
119
136
|
this.updatedMessageStatus(message);
|
|
120
137
|
});
|
|
121
138
|
}
|
|
122
139
|
|
|
123
|
-
isGroup(groupId) {
|
|
124
|
-
if (groupId.indexOf('group-') >= 0) {
|
|
125
|
-
return true;
|
|
126
|
-
}
|
|
127
|
-
return false;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
140
|
/**
|
|
131
141
|
* bonifico url in testo messaggio
|
|
132
142
|
* recupero time attuale
|
|
@@ -163,7 +173,7 @@ export class MQTTConversationHandler extends ConversationHandlerService {
|
|
|
163
173
|
channelType = TYPE_DIRECT;
|
|
164
174
|
}
|
|
165
175
|
|
|
166
|
-
this.logger.log('[
|
|
176
|
+
this.logger.log('[MQTTConversationHandlerSERVICE] Senderfullname', senderFullname);
|
|
167
177
|
const language = document.documentElement.lang;
|
|
168
178
|
const recipientFullname = conversationWithFullname;
|
|
169
179
|
const recipientId = conversationWith;
|
|
@@ -181,7 +191,7 @@ export class MQTTConversationHandler extends ConversationHandlerService {
|
|
|
181
191
|
(err, message) => {
|
|
182
192
|
if (err) {
|
|
183
193
|
message.status = '-100';
|
|
184
|
-
this.logger.log('[
|
|
194
|
+
this.logger.log('[MQTTConversationHandlerSERVICE] ERROR', err);
|
|
185
195
|
} else {
|
|
186
196
|
message.status = '150';
|
|
187
197
|
}
|
|
@@ -213,9 +223,9 @@ export class MQTTConversationHandler extends ConversationHandlerService {
|
|
|
213
223
|
}
|
|
214
224
|
|
|
215
225
|
/** */
|
|
216
|
-
private addedMessage(messageSnapshot:
|
|
226
|
+
private addedMessage(messageSnapshot: MessageModel) {
|
|
217
227
|
const msg = this.messageGenerate(messageSnapshot);
|
|
218
|
-
|
|
228
|
+
|
|
219
229
|
let isInfoMessage = messageType(MESSAGE_TYPE_INFO, msg)
|
|
220
230
|
if(isInfoMessage){
|
|
221
231
|
this.messageInfo.next(msg)
|
|
@@ -232,16 +242,7 @@ export class MQTTConversationHandler extends ConversationHandlerService {
|
|
|
232
242
|
}
|
|
233
243
|
}
|
|
234
244
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
// imposto il giorno del messaggio per visualizzare o nascondere l'header data
|
|
238
|
-
msg.headerDate = null;
|
|
239
|
-
const headerDate = setHeaderDate(this.translationMap, msg.timestamp);
|
|
240
|
-
if (headerDate !== this.lastDate) {
|
|
241
|
-
this.lastDate = headerDate;
|
|
242
|
-
msg.headerDate = headerDate;
|
|
243
|
-
}
|
|
244
|
-
this.logger.log('[MQTTConversationHandler] adding message:' + JSON.stringify(msg));
|
|
245
|
+
this.logger.log('[MQTTConversationHandlerSERVICE] adding message:' + JSON.stringify(msg));
|
|
245
246
|
// this.logger.log('childSnapshot.message_id:' + msg.message_id);
|
|
246
247
|
// this.logger.log('childSnapshot.key:' + msg.key);
|
|
247
248
|
// this.logger.log('childSnapshot.uid:' + msg.uid);
|
|
@@ -250,18 +251,19 @@ export class MQTTConversationHandler extends ConversationHandlerService {
|
|
|
250
251
|
this.messageAdded.next(msg);
|
|
251
252
|
}
|
|
252
253
|
|
|
254
|
+
|
|
253
255
|
/** */
|
|
254
256
|
private updatedMessageStatus(patch: any) {
|
|
255
257
|
if(messageType(MESSAGE_TYPE_INFO, patch) ){
|
|
256
258
|
return;
|
|
257
259
|
}
|
|
258
|
-
this.logger.log('[
|
|
260
|
+
this.logger.log('[MQTTConversationHandlerSERVICE] updating message with patch', patch);
|
|
259
261
|
const index = searchIndexInArrayForUid(this.messages, patch.message_id);
|
|
260
262
|
if (index > -1) {
|
|
261
263
|
const message = this.messages[index];
|
|
262
264
|
if (message) {
|
|
263
265
|
message.status = patch.status;
|
|
264
|
-
this.logger.log('[
|
|
266
|
+
this.logger.log('[MQTTConversationHandlerSERVICE] message found and patched (replacing)', message);
|
|
265
267
|
this.addReplaceMessageInArray(message.uid, message);
|
|
266
268
|
this.messageChanged.next(message);
|
|
267
269
|
}
|
|
@@ -281,9 +283,9 @@ export class MQTTConversationHandler extends ConversationHandlerService {
|
|
|
281
283
|
/** */
|
|
282
284
|
private messageGenerate(childSnapshot: any) {
|
|
283
285
|
// const msg: MessageModel = childSnapshot.val();
|
|
284
|
-
this.logger.log("[
|
|
286
|
+
this.logger.log("[MQTTConversationHandlerSERVICE] childSnapshot >" + JSON.stringify(childSnapshot));
|
|
285
287
|
const msg = childSnapshot;
|
|
286
|
-
msg.uid = childSnapshot.key;
|
|
288
|
+
// msg.uid = childSnapshot.key;
|
|
287
289
|
msg.text = msg.text.trim() //remove black msg with only spaces
|
|
288
290
|
// controllo fatto per i gruppi da rifattorizzare
|
|
289
291
|
if (!msg.sender_fullname || msg.sender_fullname === 'undefined') {
|
|
@@ -294,7 +296,7 @@ export class MQTTConversationHandler extends ConversationHandlerService {
|
|
|
294
296
|
// msg.text = htmlEntities(msg.text);
|
|
295
297
|
// }
|
|
296
298
|
// verifico che il sender è il logged user
|
|
297
|
-
this.logger.log("[
|
|
299
|
+
this.logger.log("[MQTTConversationHandlerSERVICE] ****>msg.sender:" + msg.sender);
|
|
298
300
|
msg.isSender = this.isSender(msg.sender, this.loggedUser.uid);
|
|
299
301
|
// traduco messaggi se sono del server
|
|
300
302
|
if (messageType(MESSAGE_TYPE_INFO, msg)) {
|
|
@@ -307,8 +309,6 @@ export class MQTTConversationHandler extends ConversationHandlerService {
|
|
|
307
309
|
private addReplaceMessageInArray(uid: string, msg: MessageModel) {
|
|
308
310
|
const index = searchIndexInArrayForUid(this.messages, uid);
|
|
309
311
|
if (index > -1) {
|
|
310
|
-
// const headerDate = this.messages[index].headerDate;
|
|
311
|
-
// msg.headerDate = headerDate;
|
|
312
312
|
this.messages.splice(index, 1, msg);
|
|
313
313
|
} else {
|
|
314
314
|
this.messages.splice(0, 0, msg);
|
|
@@ -387,11 +387,11 @@ export class MQTTConversationHandler extends ConversationHandlerService {
|
|
|
387
387
|
* @param conversationWith
|
|
388
388
|
*/
|
|
389
389
|
private updateMessageStatusReceived(msg) {
|
|
390
|
-
this.logger.log('[
|
|
390
|
+
this.logger.log('[MQTTConversationHandlerSERVICE] updateMessageStatusReceived', msg);
|
|
391
391
|
if (msg['status'] < MSG_STATUS_RECEIVED) {
|
|
392
|
-
this.logger.log('[
|
|
392
|
+
this.logger.log('[MQTTConversationHandlerSERVICE] status ', msg['status'], ' < (RECEIVED:200)', MSG_STATUS_RECEIVED);
|
|
393
393
|
if (msg.sender !== this.loggedUser.uid && msg.status < MSG_STATUS_RECEIVED) {
|
|
394
|
-
this.logger.log('[
|
|
394
|
+
this.logger.log('[MQTTConversationHandlerSERVICE] updating message with status received');
|
|
395
395
|
this.chat21Service.chatClient.updateMessageStatus(msg.message_id, this.conversationWith, MSG_STATUS_RECEIVED, null);
|
|
396
396
|
}
|
|
397
397
|
}
|
|
@@ -432,15 +432,89 @@ export class MQTTConversationHandler extends ConversationHandlerService {
|
|
|
432
432
|
// }
|
|
433
433
|
|
|
434
434
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
435
|
+
unsubscribe(key: string) {
|
|
436
|
+
this.logger.log('[MQTTConversationHandlerSERVICE] unsubscribe: ', key);
|
|
437
|
+
this.listSubsriptions.forEach(sub => {
|
|
438
|
+
this.logger.log('[MQTTConversationHandlerSERVICE] unsubscribe: ', sub.uid, key);
|
|
439
|
+
if (sub.uid === key) {
|
|
440
|
+
sub.unsubscribe(key, null);
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
private addCommandMessage(msg: MessageModel){
|
|
447
|
+
const that = this;
|
|
448
|
+
const commands = msg.attributes.commands;
|
|
449
|
+
let i=0;
|
|
450
|
+
function execute(command){
|
|
451
|
+
if(command.type === "message"){
|
|
452
|
+
that.logger.debug('[MQTTConversationHandlerSERVICE] addCommandMessage --> type="message"', command, i)
|
|
453
|
+
if (i >= 2) {
|
|
454
|
+
|
|
455
|
+
//check if previus wait message type has time value, otherwize set to 1000ms
|
|
456
|
+
!commands[i-1].time? commands[i-1].time= 1000 : commands[i-1].time
|
|
457
|
+
command.message.timestamp = commands[i-2].message.timestamp + commands[i-1].time;
|
|
458
|
+
|
|
459
|
+
/** CHECK IF MESSAGE IS JUST RECEIVED: IF false, set next message time (if object exist) to 0 -> this allow to show it immediately */
|
|
460
|
+
if(!isJustRecived(that.startTime.getTime(), msg.timestamp)){
|
|
461
|
+
let previewsTimeMsg = msg.timestamp;
|
|
462
|
+
commands[i-2]? previewsTimeMsg = commands[i-2].message.timestamp : null;
|
|
463
|
+
command.message.timestamp = previewsTimeMsg + 100
|
|
464
|
+
commands[i+1]? commands[i+1].time = 0 : null
|
|
465
|
+
}
|
|
466
|
+
} else { /**MANAGE FIRST MESSAGE */
|
|
467
|
+
command.message.timestamp = msg.timestamp;
|
|
468
|
+
if(!isJustRecived(that.startTime.getTime(), msg.timestamp)){
|
|
469
|
+
commands[i+1]? commands[i+1].time = 0 : null
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
that.generateMessageObject(msg, command.message, function () {
|
|
473
|
+
i += 1
|
|
474
|
+
if (i < commands.length) {
|
|
475
|
+
execute(commands[i])
|
|
476
|
+
}
|
|
477
|
+
else {
|
|
478
|
+
that.logger.debug('[MQTTConversationHandlerSERVICE] addCommandMessage --> last command executed (wait), exit')
|
|
479
|
+
}
|
|
480
|
+
})
|
|
481
|
+
}else if(command.type === "wait"){
|
|
482
|
+
that.logger.debug('[MQTTConversationHandlerSERVICE] addCommandMessage --> type="wait"', command, i, commands.length)
|
|
483
|
+
//publish waiting event to simulate user typing
|
|
484
|
+
if(isJustRecived(that.startTime.getTime(), msg.timestamp)){
|
|
485
|
+
// console.log('message just received::', command, i, commands)
|
|
486
|
+
that.messageWait.next({uid: that.conversationWith, uidUserTypingNow: msg.sender, nameUserTypingNow: msg.sender_fullname, waitTime: command.time, command: command})
|
|
487
|
+
}
|
|
488
|
+
setTimeout(function() {
|
|
489
|
+
i += 1
|
|
490
|
+
if (i < commands.length) {
|
|
491
|
+
execute(commands[i])
|
|
492
|
+
}
|
|
493
|
+
else {
|
|
494
|
+
that.logger.debug('[MQTTConversationHandlerSERVICE] addCommandMessage --> last command executed (send message), exit')
|
|
495
|
+
}
|
|
496
|
+
},command.time)
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
execute(commands[0]) //START render first message
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
private generateMessageObject(message, command_message, callback) {
|
|
503
|
+
let parentUid = message.uid
|
|
504
|
+
command_message.uid = uuidv4();
|
|
505
|
+
if(command_message.text) command_message.text = command_message.text.trim()//remove black msg with only spaces
|
|
506
|
+
command_message.language = message.language;
|
|
507
|
+
command_message.recipient = message.recipient;
|
|
508
|
+
command_message.recipient_fullname = message.recipient_fullname;
|
|
509
|
+
command_message.sender = message.sender;
|
|
510
|
+
command_message.sender_fullname = message.sender_fullname;
|
|
511
|
+
command_message.channel_type = message.channel_type;
|
|
512
|
+
command_message.status = message.status;
|
|
513
|
+
command_message.isSender = message.isSender;
|
|
514
|
+
command_message.attributes? command_message.attributes.commands = true : command_message.attributes = {commands : true}
|
|
515
|
+
command_message.attributes.parentUid = parentUid //added to manage message STATUS UPDATES
|
|
516
|
+
this.addedMessage(command_message)
|
|
517
|
+
callback();
|
|
518
|
+
}
|
|
445
519
|
|
|
446
520
|
}
|
|
@@ -58,7 +58,6 @@ export const TYPE_POPUP_DETAIL_MESSAGE = 'DETAIL_MESSAGE';
|
|
|
58
58
|
export const MESSAGE_TYPE_INFO = 'INFO';
|
|
59
59
|
export const MESSAGE_TYPE_MINE = 'MINE';
|
|
60
60
|
export const MESSAGE_TYPE_OTHERS = 'OTHERS';
|
|
61
|
-
export const MESSAGE_TYPE_DATE = 'DATE';
|
|
62
61
|
|
|
63
62
|
export const CHAT_REOPENED = 'CHAT_REOPENED';
|
|
64
63
|
export const CHAT_CLOSED = 'CHAT_CLOSED';
|
|
@@ -2,7 +2,6 @@ import {
|
|
|
2
2
|
MESSAGE_TYPE_INFO,
|
|
3
3
|
MESSAGE_TYPE_MINE,
|
|
4
4
|
MESSAGE_TYPE_OTHERS,
|
|
5
|
-
MESSAGE_TYPE_DATE,
|
|
6
5
|
MAX_WIDTH_IMAGES,
|
|
7
6
|
CHANNEL_TYPE_GROUP,
|
|
8
7
|
TYPE_SUPPORT_GROUP
|
|
@@ -72,12 +71,7 @@ export function isMine(message: any) {
|
|
|
72
71
|
|
|
73
72
|
/** */
|
|
74
73
|
export function messageType(msgType: string, message: any) {
|
|
75
|
-
|
|
76
|
-
if (message.headerDate && message.headerDate !== '') {
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
74
|
+
|
|
81
75
|
if (msgType === MESSAGE_TYPE_INFO) {
|
|
82
76
|
return isInfo(message);
|
|
83
77
|
}
|
|
@@ -100,6 +100,9 @@ export function contactsRef(tenant) {
|
|
|
100
100
|
// return labelDays;
|
|
101
101
|
// }
|
|
102
102
|
|
|
103
|
+
/**
|
|
104
|
+
* @deprecated
|
|
105
|
+
*/
|
|
103
106
|
export function setHeaderDate(translate, timestamp): string {
|
|
104
107
|
// const LABEL_TODAY = translate.get('LABEL_TODAY');
|
|
105
108
|
// const LABEL_TOMORROW = translate.get('LABEL_TOMORROW');
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"chatEngine": "mqtt",
|
|
3
|
+
"uploadEngine": "native",
|
|
4
|
+
"pushEngine":"mqtt",
|
|
5
|
+
"fileUploadAccept":"*/*",
|
|
6
|
+
"logLevel": "debug",
|
|
7
|
+
"remoteTranslationsUrl": "https://api.tiledesk.com/v3/",
|
|
8
|
+
"firebaseConfig": {
|
|
9
|
+
"apiKey": "AIzaSyDKfdKrlD7AYcbQ-U-xxgV-b3FUQ4xt7NM",
|
|
10
|
+
"authDomain": "tiledesk-prod-v2.firebaseapp.com",
|
|
11
|
+
"databaseURL": "https://tiledesk-prod-v2.firebaseio.com",
|
|
12
|
+
"projectId": "tiledesk-prod-v2",
|
|
13
|
+
"storageBucket": "tiledesk-prod-v2.appspot.com",
|
|
14
|
+
"messagingSenderId": "92907897826",
|
|
15
|
+
"appId": "1:92907897826:web:f255664014a7cc14ee2fbb",
|
|
16
|
+
"tenant": "tilechat"
|
|
17
|
+
},
|
|
18
|
+
"chat21Config": {
|
|
19
|
+
"appId": "tilechat",
|
|
20
|
+
"MQTTendpoint": "wss://eu.rtmv3.tiledesk.com/mqws/ws",
|
|
21
|
+
"APIendpoint": "https://eu.rtmv3.tiledesk.com/chatapi/api",
|
|
22
|
+
"_log": true
|
|
23
|
+
},
|
|
24
|
+
"apiUrl": "https://api.tiledesk.com/v3/",
|
|
25
|
+
"baseImageUrl": "https://eu.rtmv3.tiledesk.com/api/",
|
|
26
|
+
"authPersistence": "LOCAL"
|
|
27
|
+
}
|
package/src/models/message.ts
CHANGED
|
@@ -15,7 +15,6 @@ export class MessageModel {
|
|
|
15
15
|
public metadata: any,
|
|
16
16
|
public text: any,
|
|
17
17
|
public timestamp: any,
|
|
18
|
-
public headerDate: string,
|
|
19
18
|
public type: string,
|
|
20
19
|
public attributes: any,
|
|
21
20
|
public channel_type: string,
|
|
@@ -34,7 +33,6 @@ export class MessageModel {
|
|
|
34
33
|
// metadata: this.metadata,
|
|
35
34
|
// text: this.text,
|
|
36
35
|
// timestamp: firebase.database.ServerValue.TIMESTAMP,
|
|
37
|
-
// // headerDate: this.headerDate,
|
|
38
36
|
// type: this.type,
|
|
39
37
|
// attributes: this.attributes,
|
|
40
38
|
// channel_type: this.channel_type
|