@chat21/chat21-ionic 3.0.67 → 3.0.68
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 +14 -0
- package/deploy_amazon_prod.sh +4 -0
- package/package.json +1 -1
- package/src/app/app.component.ts +35 -17
- package/src/app/app.module.ts +4 -4
- package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.scss +8 -0
- package/src/app/chatlib/conversation-detail/message/info-message/info-message.component.ts +0 -2
- package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.ts +1 -3
- package/src/app/components/conversation-info/info-content/info-content.component.ts +22 -25
- package/src/app/components/project-item/project-item.component.ts +28 -50
- package/src/app/pages/conversation-detail/conversation-detail.page.ts +47 -78
- package/src/app/pages/conversations-list/conversations-list.page.ts +23 -30
- package/src/app/pages/create-canned-response/create-canned-response.page.ts +22 -29
- package/src/app/services/websocket/websocket.service.ts +1 -1
- package/src/assets/i18n/ar.json +1 -1
- package/src/assets/i18n/az.json +266 -0
- package/src/assets/i18n/de.json +1 -1
- package/src/assets/i18n/en.json +1 -1
- package/src/assets/i18n/es.json +1 -1
- package/src/assets/i18n/fr.json +1 -1
- package/src/assets/i18n/it.json +1 -1
- package/src/assets/i18n/kk.json +266 -0
- package/src/assets/i18n/pt.json +1 -1
- package/src/assets/i18n/ru.json +1 -1
- package/src/assets/i18n/sr.json +1 -1
- package/src/assets/i18n/sv.json +266 -0
- package/src/assets/i18n/tr.json +1 -1
- package/src/assets/i18n/uk.json +1 -1
- package/src/assets/i18n/uz.json +267 -0
- package/src/assets/images/language_flag/az.png +0 -0
- package/src/assets/images/language_flag/kk.png +0 -0
- package/src/assets/images/language_flag/{sv-SE.png → sv.png} +0 -0
- package/src/assets/images/language_flag/uz.png +0 -0
- package/src/chat-config-mqtt-localhost.json +10 -3
- package/src/chat-config-pre.json +2 -1
- package/src/chat21-core/providers/abstract/conversations-handler.service.ts +2 -0
- package/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts +0 -2
- package/src/chat21-core/providers/firebase/firebase-auth-service.ts +0 -5
- package/src/chat21-core/providers/firebase/firebase-conversations-handler.ts +45 -5
- package/src/chat21-core/providers/firebase/firebase-image-repo.ts +2 -1
- package/src/chat21-core/providers/mqtt/mqtt-archivedconversations-handler.ts +71 -268
- package/src/chat21-core/providers/mqtt/mqtt-auth-service.ts +23 -26
- package/src/chat21-core/providers/mqtt/mqtt-conversation-handler.ts +3 -24
- package/src/chat21-core/providers/mqtt/mqtt-conversations-handler.ts +14 -47
- package/src/chat21-core/providers/mqtt/mqtt-groups-handler.ts +6 -10
- package/src/chat21-core/providers/mqtt/mqtt-notifications.ts +88 -93
- package/src/chat21-core/providers/native/native-image-repo.ts +9 -2
- package/src/chat21-core/providers/native/native-upload-service.ts +1 -2
- package/src/chat21-core/providers/tiledesk/tiledesk-auth.service.ts +0 -1
- package/src/chat21-core/utils/constants.ts +1 -1
- package/src/chat21-core/utils/utils-message.ts +1 -1
- package/deploy_pre.sh +0 -44
|
@@ -15,9 +15,10 @@ import { TYPE_GROUP } from '../../utils/constants';
|
|
|
15
15
|
import { getImageUrlThumbFromFirebasestorage, avatarPlaceholder, getColorBck } from '../../utils/utils-user';
|
|
16
16
|
import { compareValues, getFromNow, conversationsPathForUserId, searchIndexInArrayForUid } from '../../utils/utils';
|
|
17
17
|
import { ArchivedConversationsHandlerService } from '../abstract/archivedconversations-handler.service';
|
|
18
|
+
import { LoggerService } from '../abstract/logger.service';
|
|
19
|
+
import { LoggerInstance } from '../logger/loggerInstance';
|
|
18
20
|
|
|
19
21
|
@Injectable({ providedIn: 'root' })
|
|
20
|
-
|
|
21
22
|
export class MQTTArchivedConversationsHandler extends ArchivedConversationsHandlerService {
|
|
22
23
|
|
|
23
24
|
// BehaviorSubject
|
|
@@ -31,20 +32,14 @@ export class MQTTArchivedConversationsHandler extends ArchivedConversationsHandl
|
|
|
31
32
|
archivedConversations: Array<ConversationModel> = [];
|
|
32
33
|
uidConvSelected: string;
|
|
33
34
|
tenant: string;
|
|
34
|
-
// FIREBASESTORAGE_BASE_URL_IMAGE: string;
|
|
35
|
-
// urlStorageBucket: string;
|
|
36
35
|
|
|
37
36
|
// private variables
|
|
38
37
|
private loggedUserId: string;
|
|
39
38
|
private translationMap: Map<string, string>;
|
|
40
39
|
private isConversationClosingMap: Map<string, boolean>;
|
|
41
|
-
|
|
42
|
-
private audio: any;
|
|
43
|
-
private setTimeoutSound: any;
|
|
40
|
+
private logger: LoggerService = LoggerInstance.getInstance()
|
|
44
41
|
|
|
45
42
|
constructor(
|
|
46
|
-
// private tiledeskConversationsProvider: TiledeskConversationProvider,
|
|
47
|
-
// public databaseProvider: DatabaseProvider,
|
|
48
43
|
public chat21Service: Chat21Service
|
|
49
44
|
) {
|
|
50
45
|
super();
|
|
@@ -53,18 +48,12 @@ export class MQTTArchivedConversationsHandler extends ArchivedConversationsHandl
|
|
|
53
48
|
/**
|
|
54
49
|
* inizializzo conversations handler
|
|
55
50
|
*/
|
|
56
|
-
initialize(
|
|
57
|
-
|
|
58
|
-
userId: string,
|
|
59
|
-
translationMap: Map<string, string>
|
|
60
|
-
) {
|
|
61
|
-
console.log('initialize MQTTConversationsHandler');
|
|
51
|
+
initialize(tenant: string, userId: string,translationMap: Map<string, string>) {
|
|
52
|
+
this.logger.debug('[MQTTArchivedConversationsHandler] initialize');
|
|
62
53
|
this.loggedUserId = userId;
|
|
63
54
|
this.translationMap = translationMap;
|
|
64
55
|
this.archivedConversations = [];
|
|
65
|
-
// this.databaseProvider.initialize(userId, this.tenant);
|
|
66
56
|
this.isConversationClosingMap = new Map();
|
|
67
|
-
// this.getConversationsFromStorage();
|
|
68
57
|
}
|
|
69
58
|
|
|
70
59
|
public getConversationDetail(conversationWith: string, callback) {
|
|
@@ -73,13 +62,14 @@ export class MQTTArchivedConversationsHandler extends ArchivedConversationsHandl
|
|
|
73
62
|
// callback
|
|
74
63
|
|
|
75
64
|
const conversation = this.archivedConversations.find(conv => conv.conversation_with === conversationWith);
|
|
76
|
-
|
|
65
|
+
this.logger.log('[MQTTArchivedConversationsHandler] getConversationDetail found locally? *****: ', conversation);
|
|
77
66
|
if (conversation) {
|
|
78
67
|
console.log('found!');
|
|
79
68
|
callback(conversation);
|
|
80
69
|
} else {
|
|
81
|
-
|
|
70
|
+
this.logger.log('[MQTTArchivedConversationsHandler] getConversationDetail Not found locally, remote.getConversationDetail *****: ', conversation);
|
|
82
71
|
this.chat21Service.chatClient.archivedConversationDetail(conversationWith, (err, conversation) => {
|
|
72
|
+
this.logger.log('[MQTTArchivedConversationsHandler] getConversationDetail --REMOTE CONV IS OBJ:', conversation);
|
|
83
73
|
if (conversation) {
|
|
84
74
|
if (callback) {
|
|
85
75
|
callback(this.completeConversation(conversation));
|
|
@@ -152,45 +142,28 @@ export class MQTTArchivedConversationsHandler extends ArchivedConversationsHandl
|
|
|
152
142
|
// New connect - renamed subscribeToConversation
|
|
153
143
|
//----------------------------------------------------------------------------------
|
|
154
144
|
subscribeToConversations(loaded) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
// });
|
|
164
|
-
const handlerConversationDeleted = this.chat21Service.chatClient.onArchivedConversationDeleted( (conv) => {
|
|
165
|
-
console.log('conversation deleted:', conv.text);
|
|
166
|
-
this.removed(conv);
|
|
167
|
-
});
|
|
168
|
-
this.chat21Service.chatClient.lastConversations( true, (err, conversations) => {
|
|
169
|
-
console.log('Last conversations', conversations, 'err', err);
|
|
170
|
-
if (!err) {
|
|
171
|
-
conversations.forEach(conv => {
|
|
172
|
-
this.added(conv);
|
|
173
|
-
});
|
|
174
|
-
loaded();
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
// SET AUDIO
|
|
178
|
-
// this.audio = new Audio();
|
|
179
|
-
// this.audio.src = URL_SOUND;
|
|
180
|
-
// this.audio.load();
|
|
181
|
-
// const that = this;
|
|
182
|
-
// const urlNodeFirebase = conversationsPathForUserId(this.tenant, this.loggedUserId);
|
|
183
|
-
// console.log('connect -------> conversations', urlNodeFirebase);
|
|
184
|
-
// this.ref = firebase.database().ref(urlNodeFirebase).orderByChild('timestamp').limitToLast(200);
|
|
185
|
-
// this.ref.on('child_changed', (childSnapshot) => {
|
|
186
|
-
// that.changed(childSnapshot);
|
|
187
|
-
// });
|
|
188
|
-
// this.ref.on('child_removed', (childSnapshot) => {
|
|
189
|
-
// that.removed(childSnapshot);
|
|
190
|
-
// });
|
|
191
|
-
// this.ref.on('child_added', (childSnapshot) => {
|
|
192
|
-
// that.added(childSnapshot);
|
|
145
|
+
this.logger.debug('[MQTTArchivedConversationsHandler] connecting MQTT conversations handler');
|
|
146
|
+
const handlerConversationAdded = this.chat21Service.chatClient.onArchivedConversationAdded( (conv) => {
|
|
147
|
+
this.logger.log('[MQTTArchivedConversationsHandler] Added conv ->', conv.text)
|
|
148
|
+
this.added(conv);
|
|
149
|
+
});
|
|
150
|
+
// const handlerConversationUpdated = this.chat21Service.chatClient.onConversationUpdated( (conv) => {
|
|
151
|
+
// console.log('conversation updated:', conv.text);
|
|
152
|
+
// this.changed(conv);
|
|
193
153
|
// });
|
|
154
|
+
const handlerConversationDeleted = this.chat21Service.chatClient.onArchivedConversationDeleted( (conv) => {
|
|
155
|
+
this.logger.debug('[MQTTArchivedConversationsHandler] conversation deleted:', conv);
|
|
156
|
+
this.removed(conv);
|
|
157
|
+
});
|
|
158
|
+
this.chat21Service.chatClient.lastConversations( true, (err, conversations) => {
|
|
159
|
+
this.logger.debug('[MQTTArchivedConversationsHandler] Last conversations', conversations, 'err', err);
|
|
160
|
+
if (!err) {
|
|
161
|
+
conversations.forEach(conv => {
|
|
162
|
+
this.added(conv);
|
|
163
|
+
});
|
|
164
|
+
loaded();
|
|
165
|
+
}
|
|
166
|
+
});
|
|
194
167
|
}
|
|
195
168
|
|
|
196
169
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice
|
|
@@ -205,61 +178,32 @@ export class MQTTArchivedConversationsHandler extends ArchivedConversationsHandl
|
|
|
205
178
|
* 7 - pubblico conversations:update
|
|
206
179
|
*/
|
|
207
180
|
private added(childSnapshot: any) {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
// childData.uid = childSnapshot.key;
|
|
211
|
-
// const conversation = this.completeConversation(childData);
|
|
212
|
-
// if (this.isValidConversation(childSnapshot.key, conversation)) {
|
|
213
|
-
// this.setClosingConversation(childSnapshot.key, false);
|
|
214
|
-
// // da verificare l'utilità e spostare in questa classe
|
|
215
|
-
// // this.tiledeskConversationsProvider.setClosingConversation(childSnapshot.key, false);
|
|
216
|
-
// const index = searchIndexInArrayForUid(this.conversations, conversation.uid);
|
|
217
|
-
// if (index > -1) {
|
|
218
|
-
// this.conversations.splice(index, 1, conversation);
|
|
219
|
-
// } else {
|
|
220
|
-
// this.conversations.splice(0, 0, conversation);
|
|
221
|
-
// // this.databaseProvider.setConversation(conversation);
|
|
222
|
-
// }
|
|
223
|
-
// this.conversations.sort(compareValues('timestamp', 'desc'));
|
|
224
|
-
// console.log("ALL CONVS:", this.conversations)
|
|
225
|
-
// this.conversationChanged.next(conversation);
|
|
226
|
-
// this.conversationAdded.next(conversation);
|
|
227
|
-
// // this.events.publish('conversationsChanged', this.conversations);
|
|
228
|
-
// } else {
|
|
229
|
-
// console.error('ChatConversationsHandler::added::conversations with conversationId: ', childSnapshot.key, 'is not valid');
|
|
230
|
-
// }
|
|
231
|
-
// let childData: ConversationModel = childSnapshot;
|
|
181
|
+
this.logger.debug('[MQTTArchivedConversationsHandler] NEW CONV childSnapshot', childSnapshot)
|
|
182
|
+
|
|
232
183
|
let conversation = this.completeConversation(childSnapshot);
|
|
233
184
|
conversation.uid = conversation.conversation_with;
|
|
234
185
|
// console.log("NUOVA CONVER;" + conversation.uid)
|
|
235
|
-
console.log("NUOVA CONVER;.uid" + conversation.uid)
|
|
236
186
|
if (this.isValidConversation(conversation)) {
|
|
237
187
|
this.setClosingConversation(conversation.conversation_with, false);
|
|
238
|
-
|
|
239
|
-
console.log("conversations:", this.archivedConversations)
|
|
240
|
-
console.log("cerco: ", conversation.uid)
|
|
188
|
+
this.logger.debug('[MQTTArchivedConversationsHandler] conversations:', conversation.uid, this.archivedConversations);
|
|
241
189
|
const index = this.searchIndexInArrayForConversationWith(this.archivedConversations, conversation.conversation_with);
|
|
242
|
-
console.log("found index:", index)
|
|
243
190
|
console.log("NUOVA CONVER;.uid2" + conversation.uid)
|
|
244
191
|
if (index > -1) {
|
|
245
|
-
|
|
192
|
+
this.logger.debug('[MQTTArchivedConversationsHandler] TROVATO')
|
|
246
193
|
this.archivedConversations.splice(index, 1, conversation);
|
|
247
194
|
} else {
|
|
248
|
-
|
|
195
|
+
this.logger.debug('[MQTTArchivedConversationsHandler] NON TROVATO')
|
|
249
196
|
this.archivedConversations.splice(0, 0, conversation);
|
|
250
197
|
// this.databaseProvider.setConversation(conversation);
|
|
251
198
|
}
|
|
252
|
-
|
|
199
|
+
this.logger.debug('[MQTTArchivedConversationsHandler] NUOVA CONVER;.uid3' + conversation.uid)
|
|
253
200
|
this.archivedConversations.sort(compareValues('timestamp', 'desc'));
|
|
254
|
-
|
|
255
|
-
console.log("TUTTE:", this.archivedConversations)
|
|
201
|
+
this.logger.debug('[MQTTArchivedConversationsHandler] TUTTE:', this.archivedConversations)
|
|
256
202
|
this.archivedConversationChanged.next(conversation);
|
|
257
|
-
console.log("NUOVA CONVER;.uid5" + conversation.uid)
|
|
258
203
|
this.archivedConversationAdded.next(conversation);
|
|
259
|
-
console.log("NUOVA CONVER;.uid6" + conversation.uid)
|
|
260
204
|
// this.events.publish('conversationsChanged', this.conversations);
|
|
261
205
|
} else {
|
|
262
|
-
|
|
206
|
+
this.logger.error('[MQTTArchivedConversationsHandler] ChatConversationsHandler::added::conversations with conversationId: ', conversation.conversation_with, 'is not valid');
|
|
263
207
|
}
|
|
264
208
|
}
|
|
265
209
|
|
|
@@ -318,19 +262,6 @@ export class MQTTArchivedConversationsHandler extends ArchivedConversationsHandl
|
|
|
318
262
|
}
|
|
319
263
|
// remove the conversation from the isConversationClosingMap
|
|
320
264
|
this.deleteClosingConversation(childSnapshot.key);
|
|
321
|
-
|
|
322
|
-
// const index = searchIndexInArrayForUid(this.conversations, childSnapshot.key);
|
|
323
|
-
// if (index > -1) {
|
|
324
|
-
// // 2
|
|
325
|
-
// this.conversations.splice(index, 1);
|
|
326
|
-
// // this.conversations.sort(compareValues('timestamp', 'desc'));
|
|
327
|
-
// // 3
|
|
328
|
-
// this.databaseProvider.removeConversation(childSnapshot.key);
|
|
329
|
-
// // 4
|
|
330
|
-
// // this.conversationsChanged.next(this.conversations);
|
|
331
|
-
// this.conversationsRemoved.next(this.conversations);
|
|
332
|
-
// // this.events.publish('conversationsChanged', this.conversations);
|
|
333
|
-
// }
|
|
334
265
|
}
|
|
335
266
|
|
|
336
267
|
/**
|
|
@@ -374,86 +305,8 @@ export class MQTTArchivedConversationsHandler extends ArchivedConversationsHandl
|
|
|
374
305
|
* 5 - imposto avatar, colore e immagine
|
|
375
306
|
* @param conv
|
|
376
307
|
*/
|
|
377
|
-
// public completeConversation(conv: any): ConversationModel {
|
|
378
|
-
// const conversation: ConversationModel = conv;
|
|
379
|
-
// // console.log('completeConversation', conv);
|
|
380
|
-
// if (!conv.sender_fullname || conv.sender_fullname === 'undefined' || conv.sender_fullname.trim() === '') {
|
|
381
|
-
// conversation.sender_fullname = conv.sender;
|
|
382
|
-
// } else {
|
|
383
|
-
// conversation.sender_fullname = conv.sender_fullname;
|
|
384
|
-
// }
|
|
385
|
-
// if (!conv.recipient_fullname || conv.recipient_fullname === 'undefined' || conv.recipient_fullname.trim() === ''){
|
|
386
|
-
// conversation.recipient_fullname = conv.recipient;
|
|
387
|
-
// } else {
|
|
388
|
-
// conversation.recipient_fullname = conv.recipient_fullname;
|
|
389
|
-
// }
|
|
390
|
-
// let LABEL_TU: string;
|
|
391
|
-
// this.translate.get('LABEL_TU').subscribe((res: string) => {
|
|
392
|
-
// LABEL_TU = res;
|
|
393
|
-
// });
|
|
394
|
-
// let conversationWithFullname = conv.sender_fullname;
|
|
395
|
-
// let conversationWith = conv.sender;
|
|
396
|
-
// conversation.last_message_text = conv.last_message_text;
|
|
397
|
-
// if (conv.sender === this.loggedUser.uid) {
|
|
398
|
-
// conversationWith = conv.recipient;
|
|
399
|
-
// conversationWithFullname = conv.recipient_fullname;
|
|
400
|
-
// conversation.last_message_text = LABEL_TU + conv.last_message_text;
|
|
401
|
-
// } else if (conv.channel_type === TYPE_GROUP) {
|
|
402
|
-
// conversationWith = conv.recipient;
|
|
403
|
-
// conversationWithFullname = conv.recipient_fullname;
|
|
404
|
-
// conversation.last_message_text = conv.last_message_text;
|
|
405
|
-
// }
|
|
406
|
-
// conversation.conversation_with_fullname = conversationWithFullname;
|
|
407
|
-
|
|
408
|
-
// conversation.selected = false;
|
|
409
|
-
// console.log('conv.uid', conv.uid);
|
|
410
|
-
// conversation.status = this.setStatusConversation(conv.sender, conv.uid);
|
|
411
|
-
|
|
412
|
-
// conversation.time_last_message = this.getTimeLastMessage(conv.timestamp);
|
|
413
|
-
|
|
414
|
-
// conversation.avatar = avatarPlaceholder(conversationWithFullname);
|
|
415
|
-
// conversation.color = getColorBck(conversationWithFullname);
|
|
416
|
-
// conversation.image = this.getImageUrlThumbFromFirebasestorage(conv.uid);
|
|
417
|
-
// // try {
|
|
418
|
-
// // const FIREBASESTORAGE_BASE_URL_IMAGE = this.appConfig.getConfig().FIREBASESTORAGE_BASE_URL_IMAGE;
|
|
419
|
-
// // conversation.image = getImageUrlThumb(FIREBASESTORAGE_BASE_URL_IMAGE, conversationWith);
|
|
420
|
-
// // } catch (err) {
|
|
421
|
-
// // console.log(err);
|
|
422
|
-
// // }
|
|
423
|
-
// // console.log('completeConversation fine', conversation);
|
|
424
|
-
// return conversation;
|
|
425
|
-
// }
|
|
426
|
-
|
|
427
308
|
private completeConversation(conv): ConversationModel {
|
|
428
|
-
// console.log('completeConversation', conv);
|
|
429
|
-
// const LABEL_TU = this.translationMap.get('LABEL_TU');
|
|
430
309
|
// conv.selected = false;
|
|
431
|
-
// if (!conv.sender_fullname || conv.sender_fullname === 'undefined' || conv.sender_fullname.trim() === '') {
|
|
432
|
-
// conv.sender_fullname = conv.sender;
|
|
433
|
-
// }
|
|
434
|
-
// if (!conv.recipient_fullname || conv.recipient_fullname === 'undefined' || conv.recipient_fullname.trim() === '') {
|
|
435
|
-
// conv.recipient_fullname = conv.recipient;
|
|
436
|
-
// }
|
|
437
|
-
// let conversation_with_fullname = conv.sender_fullname;
|
|
438
|
-
// let conversation_with = conv.sender;
|
|
439
|
-
// if (conv.sender === this.loggedUserId) {
|
|
440
|
-
// conversation_with = conv.recipient;
|
|
441
|
-
// conversation_with_fullname = conv.recipient_fullname;
|
|
442
|
-
// conv.last_message_text = LABEL_TU + conv.last_message_text;
|
|
443
|
-
// } else if (conv.channel_type === TYPE_GROUP) {
|
|
444
|
-
// conversation_with = conv.recipient;
|
|
445
|
-
// conversation_with_fullname = conv.recipient_fullname;
|
|
446
|
-
// conv.last_message_text = conv.last_message_text;
|
|
447
|
-
// }
|
|
448
|
-
// conv.conversation_with_fullname = conversation_with_fullname;
|
|
449
|
-
|
|
450
|
-
// conv.status = this.setStatusConversation(conv.sender, conv.uid);
|
|
451
|
-
// conv.time_last_message = this.getTimeLastMessage(conv.timestamp);
|
|
452
|
-
// conv.avatar = avatarPlaceholder(conversation_with_fullname);
|
|
453
|
-
// conv.color = getColorBck(conversation_with_fullname);
|
|
454
|
-
// return conv;
|
|
455
|
-
console.log('completeConversation', conv);
|
|
456
|
-
conv.selected = false;
|
|
457
310
|
if (!conv.sender_fullname || conv.sender_fullname === 'undefined' || conv.sender_fullname.trim() === '') {
|
|
458
311
|
conv.sender_fullname = conv.sender;
|
|
459
312
|
}
|
|
@@ -474,7 +327,6 @@ export class MQTTArchivedConversationsHandler extends ArchivedConversationsHandl
|
|
|
474
327
|
conv.conversation_with_fullname = conversation_with_fullname;
|
|
475
328
|
conv.conversation_with = conversation_with;
|
|
476
329
|
conv.status = this.setStatusConversation(conv.sender, conv.uid);
|
|
477
|
-
conv.time_last_message = this.getTimeLastMessage(conv.timestamp);
|
|
478
330
|
conv.avatar = avatarPlaceholder(conversation_with_fullname);
|
|
479
331
|
conv.color = getColorBck(conversation_with_fullname);
|
|
480
332
|
if (!conv.last_message_text) {
|
|
@@ -571,124 +423,75 @@ export class MQTTArchivedConversationsHandler extends ArchivedConversationsHandl
|
|
|
571
423
|
/**
|
|
572
424
|
* attivo sound se è un msg nuovo
|
|
573
425
|
*/
|
|
574
|
-
private soundMessage() {
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
// /**
|
|
596
|
-
// * check if the conversations is valid or not
|
|
597
|
-
// */
|
|
598
|
-
// private isValidConversation(convToCheckId, convToCheck: ConversationModel) : boolean {
|
|
599
|
-
// //console.log("[BEGIN] ChatConversationsHandler:: convToCheck with uid: ", convToCheckId);
|
|
600
|
-
// if (!this.isValidField(convToCheck.uid)) {
|
|
601
|
-
// console.error("ChatConversationsHandler::isValidConversation:: 'uid is not valid' ");
|
|
602
|
-
// return false;
|
|
603
|
-
// }
|
|
604
|
-
// if (!this.isValidField(convToCheck.is_new)) {
|
|
605
|
-
// console.error("ChatConversationsHandler::isValidConversation:: 'is_new is not valid' ");
|
|
606
|
-
// return false;
|
|
607
|
-
// }
|
|
608
|
-
// if (!this.isValidField(convToCheck.last_message_text)) {
|
|
609
|
-
// console.error("ChatConversationsHandler::isValidConversation:: 'last_message_text is not valid' ");
|
|
610
|
-
// return false;
|
|
611
|
-
// }
|
|
612
|
-
// if (!this.isValidField(convToCheck.recipient)) {
|
|
613
|
-
// console.error("ChatConversationsHandler::isValidConversation:: 'recipient is not valid' ");
|
|
614
|
-
// return false;
|
|
615
|
-
// }
|
|
616
|
-
// if (!this.isValidField(convToCheck.recipient_fullname)) {
|
|
617
|
-
// console.error("ChatConversationsHandler::isValidConversation:: 'recipient_fullname is not valid' ");
|
|
618
|
-
// return false;
|
|
619
|
-
// }
|
|
620
|
-
// if (!this.isValidField(convToCheck.sender)) {
|
|
621
|
-
// console.error("ChatConversationsHandler::isValidConversation:: 'sender is not valid' ");
|
|
622
|
-
// return false;
|
|
623
|
-
// }
|
|
624
|
-
// if (!this.isValidField(convToCheck.sender_fullname)) {
|
|
625
|
-
// console.error("ChatConversationsHandler::isValidConversation:: 'sender_fullname is not valid' ");
|
|
626
|
-
// return false;
|
|
627
|
-
// }
|
|
628
|
-
// if (!this.isValidField(convToCheck.status)) {
|
|
629
|
-
// console.error("ChatConversationsHandler::isValidConversation:: 'status is not valid' ");
|
|
630
|
-
// return false;
|
|
631
|
-
// }
|
|
632
|
-
// if (!this.isValidField(convToCheck.timestamp)) {
|
|
633
|
-
// console.error("ChatConversationsHandler::isValidConversation:: 'timestamp is not valid' ");
|
|
634
|
-
// return false;
|
|
635
|
-
// }
|
|
636
|
-
// if (!this.isValidField(convToCheck.channel_type)) {
|
|
637
|
-
// console.error("ChatConversationsHandler::isValidConversation:: 'channel_type is not valid' ");
|
|
638
|
-
// return false;
|
|
639
|
-
// }
|
|
640
|
-
// //console.log("[END] ChatConversationsHandler:: convToCheck with uid: ", convToCheckId);
|
|
641
|
-
// // any other case
|
|
642
|
-
// return true;
|
|
426
|
+
// private soundMessage() {
|
|
427
|
+
// console.log('****** soundMessage *****', this.audio);
|
|
428
|
+
// const that = this;
|
|
429
|
+
// // this.audio = new Audio();
|
|
430
|
+
// // this.audio.src = 'assets/pling.mp3';
|
|
431
|
+
// // this.audio.load();
|
|
432
|
+
// this.audio.pause();
|
|
433
|
+
// this.audio.currentTime = 0;
|
|
434
|
+
// clearTimeout(this.setTimeoutSound);
|
|
435
|
+
// this.setTimeoutSound = setTimeout(function () {
|
|
436
|
+
// //setTimeout(function() {
|
|
437
|
+
// that.audio.play()
|
|
438
|
+
// .then(function() {
|
|
439
|
+
// // console.log('****** then *****');
|
|
440
|
+
// })
|
|
441
|
+
// .catch(function() {
|
|
442
|
+
// // console.log('***//tiledesk-dashboard/chat*');
|
|
443
|
+
// });
|
|
444
|
+
// }, 1000);
|
|
643
445
|
// }
|
|
644
446
|
|
|
447
|
+
|
|
645
448
|
/**
|
|
646
449
|
* check if the conversations is valid or not
|
|
647
450
|
*/
|
|
648
451
|
private isValidConversation(convToCheck: ConversationModel) : boolean {
|
|
649
452
|
//console.log("[BEGIN] ChatConversationsHandler:: convToCheck with uid: ", convToCheckId);
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
453
|
+
this.logger.debug('[MQTTArchivedConversationsHandler] checking uid of', convToCheck)
|
|
454
|
+
this.logger.debug('[MQTTArchivedConversationsHandler] conversation.uid', convToCheck.uid)
|
|
455
|
+
this.logger.debug('[MQTTArchivedConversationsHandler] channel_type is:', convToCheck.channel_type)
|
|
653
456
|
|
|
654
457
|
if (!this.isValidField(convToCheck.uid)) {
|
|
655
|
-
|
|
458
|
+
this.logger.error('[MQTTArchivedConversationsHandler] ChatConversationsHandler::isValidConversation:: "uid is not valid" ');
|
|
656
459
|
return false;
|
|
657
460
|
}
|
|
658
461
|
// if (!this.isValidField(convToCheck.is_new)) {
|
|
659
|
-
//
|
|
462
|
+
// this.logger.error("ChatConversationsHandler::isValidConversation:: 'is_new is not valid' ");
|
|
660
463
|
// return false;
|
|
661
464
|
// }
|
|
662
465
|
if (!this.isValidField(convToCheck.last_message_text)) {
|
|
663
|
-
|
|
466
|
+
this.logger.error('[MQTTArchivedConversationsHandler] ChatConversationsHandler::isValidConversation:: "last_message_text is not valid" ');
|
|
664
467
|
return false;
|
|
665
468
|
}
|
|
666
469
|
if (!this.isValidField(convToCheck.recipient)) {
|
|
667
|
-
|
|
470
|
+
this.logger.error('[MQTTArchivedConversationsHandler] ChatConversationsHandler::isValidConversation:: "recipient is not valid" ');
|
|
668
471
|
return false;
|
|
669
472
|
}
|
|
670
473
|
if (!this.isValidField(convToCheck.recipient_fullname)) {
|
|
671
|
-
|
|
474
|
+
this.logger.error('[MQTTArchivedConversationsHandler] ChatConversationsHandler::isValidConversation:: "recipient_fullname is not valid" ');
|
|
672
475
|
return false;
|
|
673
476
|
}
|
|
674
477
|
if (!this.isValidField(convToCheck.sender)) {
|
|
675
|
-
|
|
478
|
+
this.logger.error('[MQTTArchivedConversationsHandler] ChatConversationsHandler::isValidConversation:: "sender is not valid" ');
|
|
676
479
|
return false;
|
|
677
480
|
}
|
|
678
481
|
if (!this.isValidField(convToCheck.sender_fullname)) {
|
|
679
|
-
|
|
482
|
+
this.logger.error('[MQTTArchivedConversationsHandler] ChatConversationsHandler::isValidConversation:: "sender_fullname is not valid" ');
|
|
680
483
|
return false;
|
|
681
484
|
}
|
|
682
485
|
if (!this.isValidField(convToCheck.status)) {
|
|
683
|
-
|
|
486
|
+
this.logger.error('[MQTTArchivedConversationsHandler] ChatConversationsHandler::isValidConversation:: "status is not valid" ');
|
|
684
487
|
return false;
|
|
685
488
|
}
|
|
686
489
|
if (!this.isValidField(convToCheck.timestamp)) {
|
|
687
|
-
|
|
490
|
+
this.logger.error('[MQTTArchivedConversationsHandler] ChatConversationsHandler::isValidConversation:: "timestamp is not valid" ');
|
|
688
491
|
return false;
|
|
689
492
|
}
|
|
690
493
|
if (!this.isValidField(convToCheck.channel_type)) {
|
|
691
|
-
|
|
494
|
+
this.logger.error('[MQTTArchivedConversationsHandler] ChatConversationsHandler::isValidConversation:: "channel_type is not valid" ');
|
|
692
495
|
return false;
|
|
693
496
|
}
|
|
694
497
|
//console.log("[END] ChatConversationsHandler:: convToCheck with uid: ", convToCheckId);
|
|
@@ -701,4 +504,4 @@ export class MQTTArchivedConversationsHandler extends ArchivedConversationsHandl
|
|
|
701
504
|
return (field === null || field === undefined) ? false : true;
|
|
702
505
|
}
|
|
703
506
|
|
|
704
|
-
}
|
|
507
|
+
}
|
|
@@ -38,10 +38,8 @@ export class MQTTAuthService extends MessagingAuthService {
|
|
|
38
38
|
public user: any;
|
|
39
39
|
private currentUser: any;
|
|
40
40
|
|
|
41
|
-
// private
|
|
41
|
+
// private
|
|
42
42
|
private URL_TILEDESK_CREATE_CUSTOM_TOKEN: string;
|
|
43
|
-
// private URL_TILEDESK_SIGNIN_ANONYMOUSLY: string;
|
|
44
|
-
// private URL_TILEDESK_SIGNIN_WITH_CUSTOM_TOKEN: string;
|
|
45
43
|
|
|
46
44
|
private logger: LoggerService = LoggerInstance.getInstance()
|
|
47
45
|
|
|
@@ -51,7 +49,6 @@ export class MQTTAuthService extends MessagingAuthService {
|
|
|
51
49
|
public appStorage: AppStorageService
|
|
52
50
|
) {
|
|
53
51
|
super();
|
|
54
|
-
this.logger.log("chat21Service:", chat21Service)
|
|
55
52
|
}
|
|
56
53
|
|
|
57
54
|
/**
|
|
@@ -59,30 +56,30 @@ export class MQTTAuthService extends MessagingAuthService {
|
|
|
59
56
|
*/
|
|
60
57
|
initialize() {
|
|
61
58
|
this.SERVER_BASE_URL = this.getBaseUrl();
|
|
62
|
-
// this.URL_TILEDESK_SIGNIN = this.SERVER_BASE_URL + 'auth/signin';
|
|
63
|
-
// this.URL_TILEDESK_SIGNIN_ANONYMOUSLY = this.SERVER_BASE_URL + 'auth/signinAnonymously';
|
|
64
59
|
this.URL_TILEDESK_CREATE_CUSTOM_TOKEN = this.SERVER_BASE_URL + 'chat21/native/auth/createCustomToken';
|
|
65
|
-
|
|
66
|
-
this.logger.log(' ---------------- login con token url ---------------- ');
|
|
60
|
+
this.logger.log('[MQTTAuthService] initialize ');
|
|
67
61
|
// this.checkIsAuth();
|
|
68
62
|
// this.onAuthStateChanged();
|
|
69
63
|
}
|
|
70
64
|
|
|
71
65
|
// logout(callback) {
|
|
72
|
-
logout() {
|
|
73
|
-
this.logger.log("closing mqtt connection...");
|
|
74
|
-
|
|
75
|
-
this.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
66
|
+
logout(): Promise<boolean> {
|
|
67
|
+
this.logger.log("[MQTTAuthService] logout: closing mqtt connection...");
|
|
68
|
+
return new Promise((resolve, reject) => {
|
|
69
|
+
this.chat21Service.chatClient.close(() => {
|
|
70
|
+
console.log("[MQTTAuthService] logout: mqtt connection closed. OK");
|
|
71
|
+
// remove
|
|
72
|
+
// this.appStorage.removeItem('tiledeskToken');
|
|
73
|
+
// this.appStorage.removeItem('currentUser');
|
|
74
|
+
this.currentUser = null;
|
|
75
|
+
console.log("[MQTTAuthService] logout: user removed");
|
|
76
|
+
this.BSSignOut.next(true);
|
|
77
|
+
this.BSAuthStateChanged.next('offline');
|
|
78
|
+
resolve(true)
|
|
79
|
+
// if (callback) {
|
|
80
|
+
// callback();
|
|
81
|
+
// }
|
|
82
|
+
});
|
|
86
83
|
});
|
|
87
84
|
}
|
|
88
85
|
|
|
@@ -97,7 +94,7 @@ z
|
|
|
97
94
|
|
|
98
95
|
/** */
|
|
99
96
|
getToken(): string {
|
|
100
|
-
this.logger.log('
|
|
97
|
+
this.logger.log('[MQTTAuthService]::getToken');
|
|
101
98
|
return this.token;
|
|
102
99
|
}
|
|
103
100
|
|
|
@@ -258,7 +255,7 @@ z
|
|
|
258
255
|
// const that = this;
|
|
259
256
|
this.http.post(this.URL_TILEDESK_CREATE_CUSTOM_TOKEN, postData, { headers, responseType})
|
|
260
257
|
.subscribe(data => {
|
|
261
|
-
this.logger.log("**** data", data)
|
|
258
|
+
this.logger.log("[MQTTAuthService] connectWithCustomToken: **** data", data)
|
|
262
259
|
const result = JSON.parse(data);
|
|
263
260
|
this.connectMQTT(result);
|
|
264
261
|
}, error => {
|
|
@@ -267,10 +264,10 @@ z
|
|
|
267
264
|
}
|
|
268
265
|
|
|
269
266
|
connectMQTT(credentials: any): any {
|
|
270
|
-
this.logger.log('**** credentials:', credentials);
|
|
267
|
+
this.logger.log('[MQTTAuthService] connectMQTT: **** credentials:', credentials);
|
|
271
268
|
const userid = credentials.userid;
|
|
272
269
|
this.chat21Service.chatClient.connect(userid, credentials.token, () => {
|
|
273
|
-
this.logger.log('Chat connected.');
|
|
270
|
+
this.logger.log('[MQTTAuthService] connectMQTT: Chat connected.');
|
|
274
271
|
this.BSAuthStateChanged.next('online');
|
|
275
272
|
});
|
|
276
273
|
}
|