@chat21/chat21-ionic 3.0.58 → 3.0.59-rc15
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 +69 -0
- package/README.md +9 -0
- package/config.xml +11 -2
- package/env.sample +2 -0
- package/package.json +1 -1
- package/resources/Android/splash/drawable-land-hdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-land-ldpi-screen.png +0 -0
- package/resources/Android/splash/drawable-land-mdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-land-xhdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-land-xxhdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-land-xxxhdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-port-hdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-port-ldpi-screen.png +0 -0
- package/resources/Android/splash/drawable-port-mdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-port-xhdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-port-xxhdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-port-xxxhdpi-screen.png +0 -0
- package/resources/Android/splash.png +0 -0
- package/src/app/app-routing.module.ts +21 -17
- package/src/app/app.component.html +6 -3
- package/src/app/app.component.ts +259 -55
- package/src/app/app.module.ts +16 -8
- package/src/app/chatlib/conversation-detail/conversation-content/conversation-content.component.html +1 -1
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.html +4 -4
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.scss +8 -2
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.ts +6 -1
- package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.html +7 -2
- package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.ts +47 -2
- package/src/app/chatlib/conversation-detail/message/image/image.component.html +7 -6
- package/src/app/chatlib/conversation-detail/message/image/image.component.ts +20 -1
- package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.html +39 -9
- package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.scss +8 -144
- package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.ts +14 -17
- package/src/app/chatlib/list-conversations-component/list-conversations/list-conversations.component.html +1 -1
- package/src/app/components/authentication/login/login.component.html +10 -10
- package/src/app/components/authentication/login/login.component.ts +2 -1
- package/src/app/components/conversation-detail/bubble-my-message/bubble-my-message.component.ts +1 -1
- package/src/app/components/conversation-detail/bubble-others-message/bubble-others-message.component.ts +1 -1
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.html +17 -12
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.scss +12 -0
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.ts +21 -5
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.html +3 -2
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.scss +22 -17
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.ts +46 -5
- package/src/app/components/ddp-header/ddp-header.component.html +1 -1
- package/src/app/components/ddp-header/ddp-header.component.ts +4 -2
- package/src/app/components/image-viewer/image-viewer.component.html +23 -0
- package/src/app/components/image-viewer/image-viewer.component.scss +107 -0
- package/src/app/components/image-viewer/image-viewer.component.spec.ts +24 -0
- package/src/app/components/image-viewer/image-viewer.component.ts +38 -0
- package/src/app/components/project-item/project-item.component.html +147 -0
- package/src/app/components/project-item/project-item.component.scss +669 -0
- package/src/app/components/project-item/project-item.component.spec.ts +24 -0
- package/src/app/components/project-item/project-item.component.ts +317 -0
- package/src/app/components/utils/avatar-profile/avatar-profile.component.html +7 -0
- package/src/app/components/utils/avatar-profile/avatar-profile.component.ts +22 -5
- package/src/app/pages/authentication/login/login.page.html +1 -2
- package/src/app/pages/authentication/login/login.page.ts +1 -1
- package/src/app/pages/conversation-detail/conversation-detail.page.html +5 -3
- package/src/app/pages/conversation-detail/conversation-detail.page.ts +122 -30
- package/src/app/pages/conversations-list/conversations-list.page.html +44 -23
- package/src/app/pages/conversations-list/conversations-list.page.scss +290 -127
- package/src/app/pages/conversations-list/conversations-list.page.ts +172 -12
- package/src/app/pages/unassigned-conversations/unassigned-conversations-routing.module.ts +17 -0
- package/src/app/pages/unassigned-conversations/unassigned-conversations.module.ts +22 -0
- package/src/app/pages/unassigned-conversations/unassigned-conversations.page.html +22 -0
- package/src/app/pages/unassigned-conversations/unassigned-conversations.page.scss +79 -0
- package/src/app/pages/unassigned-conversations/unassigned-conversations.page.spec.ts +24 -0
- package/src/app/pages/unassigned-conversations/unassigned-conversations.page.ts +108 -0
- package/src/app/services/nav-proxy.service.ts +1 -1
- package/src/app/services/tiledesk/tiledesk.service.ts +22 -1
- package/src/app/services/websocket/websocket-js.ts +557 -0
- package/src/app/services/websocket/websocket.service.spec.ts +12 -0
- package/src/app/services/websocket/websocket.service.ts +274 -0
- package/src/app/shared/shared.module.ts +7 -1
- package/src/assets/i18n/en.json +9 -1
- package/src/assets/i18n/it.json +9 -1
- package/src/assets/js/chat21client.js +141 -67
- package/src/assets/transparent.png +0 -0
- package/src/chat-config-pre-test.json +3 -1
- package/src/chat-config-template.json +3 -1
- package/src/chat-config.json +3 -1
- package/src/chat21-core/providers/chat-manager.ts +3 -3
- package/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts +1 -1
- package/src/chat21-core/providers/firebase/firebase-auth-service.ts +6 -6
- package/src/chat21-core/providers/firebase/firebase-conversation-handler.ts +1 -1
- package/src/chat21-core/providers/firebase/firebase-notifications.ts +1 -1
- package/src/chat21-core/providers/firebase/firebase-presence.service.ts +2 -2
- package/src/chat21-core/providers/firebase/firebase-typing.service.ts +1 -1
- package/src/chat21-core/providers/firebase/firebase-upload.service.ts +1 -1
- package/src/chat21-core/providers/mqtt/mqtt-auth-service.ts +27 -27
- package/src/chat21-core/providers/mqtt/mqtt-conversations-handler.ts +13 -5
- package/src/chat21-core/providers/mqtt/mqtt-notifications.ts +101 -11
- package/src/chat21-core/providers/tiledesk/tiledesk-auth.service.ts +13 -4
- package/src/chat21-core/utils/utils.ts +1 -1
- package/src/firebase-messaging-sw-template.js +1 -1
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
/*
|
|
2
2
|
Chat21Client
|
|
3
|
-
v. 0.1.5
|
|
4
|
-
- added groupSetMembers()
|
|
5
|
-
- renamed createGroup() in groupCreate()
|
|
6
|
-
- renamed leaveGroup() in groupLeave()
|
|
7
|
-
- renamed joinGroup() in groupJoin()
|
|
8
|
-
- renamed getGroup() in groupData()
|
|
9
3
|
|
|
4
|
+
v0.1.8
|
|
10
5
|
|
|
11
|
-
|
|
12
|
-
- added basicMessageBuilder()
|
|
13
|
-
- added sendMessageRaw()
|
|
14
|
-
- added leaveGroup()
|
|
15
|
-
|
|
6
|
+
@Author Andrea Sponziello
|
|
16
7
|
(c) Tiledesk 2020
|
|
17
8
|
*/
|
|
18
9
|
|
|
@@ -33,8 +24,9 @@ class Chat21Client {
|
|
|
33
24
|
this.client_id = this.uuidv4();
|
|
34
25
|
if (options && options.MQTTendpoint) {
|
|
35
26
|
if (options.MQTTendpoint.startsWith('/')) {
|
|
36
|
-
|
|
37
|
-
|
|
27
|
+
if (this.log) {
|
|
28
|
+
console.log("MQTTendpoint relative url");
|
|
29
|
+
}
|
|
38
30
|
var loc = window.location, new_uri;
|
|
39
31
|
if (loc.protocol === "https:") {
|
|
40
32
|
// new_uri = "wss:";
|
|
@@ -59,7 +51,9 @@ class Chat21Client {
|
|
|
59
51
|
this.log = options.log ? true : false;
|
|
60
52
|
this.APIendpoint = options.APIendpoint;
|
|
61
53
|
this.appid = options.appId;
|
|
62
|
-
|
|
54
|
+
if (this.log) {
|
|
55
|
+
console.log("final endpoint:", this.endpoint);
|
|
56
|
+
}
|
|
63
57
|
this.user_id = null;
|
|
64
58
|
this.jwt = null;
|
|
65
59
|
this.last_handler = 0;
|
|
@@ -86,10 +80,14 @@ class Chat21Client {
|
|
|
86
80
|
// MQTT: https://www.hivemq.com/blog/mqtt-essentials-part-5-mqtt-topics-best-practices/
|
|
87
81
|
// RABBITMQ: https://www.cloudamqp.com/blog/2015-09-03-part4-rabbitmq-for-beginners-exchanges-routing-keys-bindings.html#topic-exchange
|
|
88
82
|
this.topic_inbox = 'apps/tilechat/users/' + this.user_id + "/#"
|
|
89
|
-
|
|
83
|
+
if (this.log) {
|
|
84
|
+
console.log("subscribing to:", this.user_id, "topic", this.topic_inbox);
|
|
85
|
+
}
|
|
90
86
|
this.client.subscribe(this.topic_inbox, (err) => {
|
|
91
|
-
|
|
92
|
-
|
|
87
|
+
if (this.log) {
|
|
88
|
+
console.log("subscribed to:", this.topic_inbox, " with err", err)
|
|
89
|
+
}
|
|
90
|
+
});
|
|
93
91
|
}
|
|
94
92
|
|
|
95
93
|
// subscribeToMyMessages() {
|
|
@@ -159,16 +157,22 @@ class Chat21Client {
|
|
|
159
157
|
}
|
|
160
158
|
|
|
161
159
|
updateMessageStatus(messageId, conversWith, status, callback) {
|
|
162
|
-
// callback - function (err)
|
|
163
|
-
|
|
160
|
+
// callback - function (err)
|
|
161
|
+
if (this.log) {
|
|
162
|
+
console.log("updating recipient_id:", messageId, "on conversWith", conversWith, "status", status)
|
|
163
|
+
}
|
|
164
164
|
// 'apps/tilechat/users/USER_ID/messages/CONVERS_WITH/MESSAGE_ID/update'
|
|
165
165
|
let dest_topic = `apps/${this.appid}/users/${this.user_id}/messages/${conversWith}/${messageId}/update`
|
|
166
|
-
|
|
166
|
+
if (this.log) {
|
|
167
|
+
console.log("update dest_topic:", dest_topic);
|
|
168
|
+
}
|
|
167
169
|
let message_patch = {
|
|
168
170
|
status: status
|
|
169
171
|
}
|
|
170
172
|
const payload = JSON.stringify(message_patch)
|
|
171
|
-
|
|
173
|
+
if (this.log) {
|
|
174
|
+
console.log("payload:", payload)
|
|
175
|
+
}
|
|
172
176
|
this.client.publish(dest_topic, payload, null, (err) => {
|
|
173
177
|
if (callback) {
|
|
174
178
|
callback(err, message_patch)
|
|
@@ -177,16 +181,22 @@ class Chat21Client {
|
|
|
177
181
|
}
|
|
178
182
|
|
|
179
183
|
updateConversationIsNew(conversWith, is_new, callback) {
|
|
180
|
-
// callback - function (err)
|
|
181
|
-
|
|
184
|
+
// callback - function (err)
|
|
185
|
+
if (this.log) {
|
|
186
|
+
console.log("updating conversation with:", conversWith, "is_new", is_new);
|
|
187
|
+
}
|
|
182
188
|
// 'apps/tilechat/users/USER_ID/conversations/CONVERS_WITH/update'
|
|
183
189
|
let dest_topic = `apps/${this.appid}/users/${this.user_id}/conversations/${conversWith}/update` //'apps/tilechat/users/' + this.user_id + '/conversations/' + conversWith + '/update'
|
|
184
|
-
|
|
190
|
+
if (this.log) {
|
|
191
|
+
console.log("update dest_topic:", dest_topic);
|
|
192
|
+
}
|
|
185
193
|
let patch = {
|
|
186
194
|
is_new: is_new
|
|
187
195
|
}
|
|
188
196
|
const payload = JSON.stringify(patch)
|
|
189
|
-
|
|
197
|
+
if (this.log) {
|
|
198
|
+
console.log("payload:", payload);
|
|
199
|
+
}
|
|
190
200
|
this.client.publish(dest_topic, payload, null, (err) => {
|
|
191
201
|
if (callback) {
|
|
192
202
|
callback(err)
|
|
@@ -207,7 +217,9 @@ class Chat21Client {
|
|
|
207
217
|
// }
|
|
208
218
|
|
|
209
219
|
// callback - function (err)
|
|
210
|
-
|
|
220
|
+
if (this.log) {
|
|
221
|
+
console.log("creating group:", name, "id", group_id, "members", members)
|
|
222
|
+
}
|
|
211
223
|
// who creates the group is also group-owner
|
|
212
224
|
// ex.: http://localhost:8004/api/tilechat/04-ANDREASPONZIELLO/groups
|
|
213
225
|
// let data = {
|
|
@@ -221,7 +233,9 @@ class Chat21Client {
|
|
|
221
233
|
// }
|
|
222
234
|
|
|
223
235
|
const URL = `${this.APIendpoint}/${this.appid}/groups`
|
|
224
|
-
|
|
236
|
+
if (this.log) {
|
|
237
|
+
console.log("creating group...", URL)
|
|
238
|
+
}
|
|
225
239
|
let options = {
|
|
226
240
|
url: URL,
|
|
227
241
|
headers: {
|
|
@@ -306,9 +320,13 @@ class Chat21Client {
|
|
|
306
320
|
}
|
|
307
321
|
|
|
308
322
|
groupLeave(group_id, member_id, callback) {
|
|
309
|
-
|
|
323
|
+
if (this.log) {
|
|
324
|
+
console.log("leaving group:", group_id);
|
|
325
|
+
}
|
|
310
326
|
const URL = `${this.APIendpoint}/${this.appid}/groups/${group_id}/members/${member_id}`
|
|
311
|
-
|
|
327
|
+
if (this.log) {
|
|
328
|
+
console.log("leaving group:", URL)
|
|
329
|
+
}
|
|
312
330
|
let options = {
|
|
313
331
|
url: URL,
|
|
314
332
|
headers: {
|
|
@@ -328,9 +346,13 @@ class Chat21Client {
|
|
|
328
346
|
}
|
|
329
347
|
|
|
330
348
|
groupJoin(group_id, member_id, callback) {
|
|
331
|
-
|
|
349
|
+
if (this.log) {
|
|
350
|
+
console.log("leaving group:", group_id);
|
|
351
|
+
}
|
|
332
352
|
const URL = `${this.APIendpoint}/${this.appid}/groups/${group_id}/members`
|
|
333
|
-
|
|
353
|
+
if (this.log) {
|
|
354
|
+
console.log("joining group:", URL)
|
|
355
|
+
}
|
|
334
356
|
let options = {
|
|
335
357
|
url: URL,
|
|
336
358
|
headers: {
|
|
@@ -361,9 +383,13 @@ class Chat21Client {
|
|
|
361
383
|
// "6067513cb64a9b1ba259839c":1
|
|
362
384
|
// }
|
|
363
385
|
// }
|
|
364
|
-
|
|
386
|
+
if (this.log) {
|
|
387
|
+
console.log("setting group members of", group_id, "members", members)
|
|
388
|
+
}
|
|
365
389
|
const URL = `${this.APIendpoint}/${this.appid}/groups/${group_id}/members`
|
|
366
|
-
|
|
390
|
+
if (this.log) {
|
|
391
|
+
console.log("setting group members...", URL)
|
|
392
|
+
}
|
|
367
393
|
let options = {
|
|
368
394
|
url: URL,
|
|
369
395
|
headers: {
|
|
@@ -385,12 +411,45 @@ class Chat21Client {
|
|
|
385
411
|
}, this.log);
|
|
386
412
|
}
|
|
387
413
|
|
|
414
|
+
saveInstance(instance_id, data, callback) {
|
|
415
|
+
if (this.log) {
|
|
416
|
+
console.log("saving instance_id:", instance_id, "data", data);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
// /:app_id/:user_id/instances/:instance_id
|
|
420
|
+
const URL = `${this.APIendpoint}/${this.appid}/${this.user_id}/instances/${instance_id}`
|
|
421
|
+
if (this.log) {
|
|
422
|
+
console.log("saving instance...");
|
|
423
|
+
}
|
|
424
|
+
let options = {
|
|
425
|
+
url: URL,
|
|
426
|
+
headers: {
|
|
427
|
+
"Authorization": this.jwt,
|
|
428
|
+
"Content-Type": "application/json;charset=UTF-8"
|
|
429
|
+
},
|
|
430
|
+
data: data,
|
|
431
|
+
method: 'POST'
|
|
432
|
+
}
|
|
433
|
+
Chat21Client.myrequest(options, (err, response, json) => {
|
|
434
|
+
if (err) {
|
|
435
|
+
callback(err, null);
|
|
436
|
+
}
|
|
437
|
+
else if (json && callback) {
|
|
438
|
+
callback(null, json);
|
|
439
|
+
}
|
|
440
|
+
}, this.log);
|
|
441
|
+
}
|
|
442
|
+
|
|
388
443
|
archiveConversation(conversWith, callback) {
|
|
389
444
|
// callback - function (err)
|
|
390
|
-
|
|
445
|
+
if (this.log) {
|
|
446
|
+
console.log("archiving conversation with:", conversWith)
|
|
447
|
+
}
|
|
391
448
|
// 'apps/tilechat/users/USER_ID/conversations/CONVERS_WITH/archive'
|
|
392
449
|
let dest_topic = 'apps/tilechat/users/' + this.user_id + '/conversations/' + conversWith + '/archive'
|
|
393
|
-
|
|
450
|
+
if (this.log) {
|
|
451
|
+
console.log("archive dest_topic:", dest_topic)
|
|
452
|
+
}
|
|
394
453
|
// let patch = {
|
|
395
454
|
// action: 'archive'
|
|
396
455
|
// }
|
|
@@ -440,7 +499,6 @@ class Chat21Client {
|
|
|
440
499
|
}
|
|
441
500
|
|
|
442
501
|
onMessageAdded(callback) {
|
|
443
|
-
console.log("onMessageAdded(callback)")
|
|
444
502
|
this.last_handler++
|
|
445
503
|
this.onMessageAddedCallbacks.set(this.last_handler, callback)
|
|
446
504
|
return this.last_handler;
|
|
@@ -485,20 +543,24 @@ class Chat21Client {
|
|
|
485
543
|
}
|
|
486
544
|
|
|
487
545
|
onMessageUpdated(callback) {
|
|
488
|
-
this.last_handler
|
|
546
|
+
this.last_handler += 1
|
|
489
547
|
this.onMessageUpdatedCallbacks.set(this.last_handler, callback)
|
|
490
548
|
return this.last_handler;
|
|
491
549
|
}
|
|
492
550
|
|
|
493
551
|
onGroupUpdated(callback) {
|
|
494
|
-
this.last_handler
|
|
552
|
+
this.last_handler += 1
|
|
495
553
|
this.onGroupUpdatedCallbacks.set(this.last_handler, callback)
|
|
496
554
|
return this.last_handler;
|
|
497
555
|
}
|
|
498
556
|
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
557
|
+
removeOnMessageAddedHandler(handler) {
|
|
558
|
+
this.onMessageAddedCallbacks.delete(handler);
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
removeOnGroupUpdatedHandler(handler) {
|
|
562
|
+
this.onGroupUpdatedCallbacks.delete(handler);
|
|
563
|
+
}
|
|
502
564
|
|
|
503
565
|
start() {
|
|
504
566
|
if (this.on_message_handler) {
|
|
@@ -511,7 +573,9 @@ class Chat21Client {
|
|
|
511
573
|
// console.log("topic:" + topic + "\nmessage payload:" + message)
|
|
512
574
|
const _topic = this.parseTopic(topic)
|
|
513
575
|
if (!_topic) {
|
|
514
|
-
|
|
576
|
+
if (this.log) {
|
|
577
|
+
console.log("Invalid message topic:", topic);
|
|
578
|
+
}
|
|
515
579
|
return;
|
|
516
580
|
}
|
|
517
581
|
const conversWith = _topic.conversWith
|
|
@@ -533,7 +597,9 @@ class Chat21Client {
|
|
|
533
597
|
if (this.onConversationUpdatedCallbacks) {
|
|
534
598
|
// example topic: apps.tilechat.users.ME.conversations.CONVERS-WITH.clientdeleted
|
|
535
599
|
if (topic.includes("/conversations/") && topic.endsWith(_CLIENTUPDATED)) {
|
|
536
|
-
|
|
600
|
+
if (this.log) {
|
|
601
|
+
console.log("conversation updated! /conversations/, topic:", topic)
|
|
602
|
+
}
|
|
537
603
|
// map.forEach((value, key, map) =>)
|
|
538
604
|
this.onConversationUpdatedCallbacks.forEach((callback, handler, map) => {
|
|
539
605
|
callback(JSON.parse(message.toString()), topic)
|
|
@@ -544,7 +610,9 @@ class Chat21Client {
|
|
|
544
610
|
if (this.onConversationDeletedCallbacks) {
|
|
545
611
|
if (topic.includes("/conversations/") && topic.endsWith(_CLIENTDELETED)) {
|
|
546
612
|
// map.forEach((value, key, map) =>)
|
|
547
|
-
|
|
613
|
+
if (this.log) {
|
|
614
|
+
console.log("conversation deleted! /conversations/, topic:", topic, message.toString() );
|
|
615
|
+
}
|
|
548
616
|
this.onConversationDeletedCallbacks.forEach((callback, handler, map) => {
|
|
549
617
|
callback(JSON.parse(message.toString()), topic)
|
|
550
618
|
});
|
|
@@ -627,16 +695,16 @@ class Chat21Client {
|
|
|
627
695
|
// }
|
|
628
696
|
const type = callback_obj.type
|
|
629
697
|
if (topic.includes("/messages/") && topic.endsWith(_CLIENTADDED)) {
|
|
630
|
-
console.log("/messages/_CLIENTADDED")
|
|
698
|
+
if (this.log) { console.log("/messages/_CLIENTADDED") }
|
|
631
699
|
if (type === CALLBACK_TYPE_ON_MESSAGE_ADDED_FOR_CONVERSATION) {
|
|
632
700
|
if (conversWith === callback_obj.conversWith) {
|
|
633
|
-
console.log("/messages/_CLIENTADDED on: ", conversWith)
|
|
701
|
+
if (this.log) { console.log("/messages/_CLIENTADDED on: ", conversWith)}
|
|
634
702
|
callback_obj.callback(JSON.parse(message.toString()), _topic)
|
|
635
703
|
}
|
|
636
704
|
}
|
|
637
705
|
}
|
|
638
706
|
if (topic.includes("/messages/") && topic.endsWith(_CLIENTUPDATED)) {
|
|
639
|
-
console.log("/messages/_CLIENTUPDATED")
|
|
707
|
+
if (this.log) {console.log("/messages/_CLIENTUPDATED")}
|
|
640
708
|
if (type === CALLBACK_TYPE_ON_MESSAGE_UPDATED_FOR_CONVERSATION) {
|
|
641
709
|
if (conversWith === callback_obj.conversWith) {
|
|
642
710
|
console.log("/messages/_CLIENTUPDATED on: ", conversWith)
|
|
@@ -657,7 +725,7 @@ class Chat21Client {
|
|
|
657
725
|
|
|
658
726
|
}
|
|
659
727
|
catch (err) {
|
|
660
|
-
console.
|
|
728
|
+
console.error("ERROR:", err)
|
|
661
729
|
}
|
|
662
730
|
})
|
|
663
731
|
// console.log("HANDLER_:", this.on_message_handler)
|
|
@@ -683,7 +751,7 @@ class Chat21Client {
|
|
|
683
751
|
lastArchivedConversations(callback) {
|
|
684
752
|
// ex.: http://localhost:8004/tilechat/04-ANDREASPONZIELLO/archived_conversations
|
|
685
753
|
const URL = `${this.APIendpoint}/${this.appid}/${this.user_id}/archived_conversations`
|
|
686
|
-
console.log("getting last archived conversations...", URL)
|
|
754
|
+
if (this.log) {console.log("getting last archived conversations...", URL)}
|
|
687
755
|
var xmlhttp = new XMLHttpRequest();
|
|
688
756
|
xmlhttp.open("GET", URL, true);
|
|
689
757
|
xmlhttp.setRequestHeader("authorization", this.jwt);
|
|
@@ -695,7 +763,7 @@ class Chat21Client {
|
|
|
695
763
|
callback(null, json.result)
|
|
696
764
|
}
|
|
697
765
|
catch (err) {
|
|
698
|
-
console.
|
|
766
|
+
console.error("parsing json ERROR", err)
|
|
699
767
|
callback(err, null)
|
|
700
768
|
}
|
|
701
769
|
}
|
|
@@ -707,7 +775,7 @@ class Chat21Client {
|
|
|
707
775
|
// ex.: http://localhost:8004/tilechat/04-ANDREASPONZIELLO/conversations
|
|
708
776
|
const archived_url_part = archived ? '/archived' : '';
|
|
709
777
|
const URL = `${this.APIendpoint}/${this.appid}/${this.user_id}/conversations` + archived_url_part;
|
|
710
|
-
console.log("getting last convs...", URL);
|
|
778
|
+
if (this.log) {console.log("getting last convs...", URL);}
|
|
711
779
|
var xmlhttp = new XMLHttpRequest();
|
|
712
780
|
xmlhttp.open("GET", URL, true);
|
|
713
781
|
xmlhttp.setRequestHeader("authorization", this.jwt);
|
|
@@ -719,7 +787,7 @@ class Chat21Client {
|
|
|
719
787
|
callback(null, json.result)
|
|
720
788
|
}
|
|
721
789
|
catch (err) {
|
|
722
|
-
console.
|
|
790
|
+
console.error("parsing json ERROR", err)
|
|
723
791
|
callback(err, null)
|
|
724
792
|
}
|
|
725
793
|
}
|
|
@@ -731,15 +799,20 @@ class Chat21Client {
|
|
|
731
799
|
// ex.: http://localhost:8004/tilechat/04-ANDREASPONZIELLO/conversations/CONVERS_WITH
|
|
732
800
|
const URL = `${this.APIendpoint}/${this.appid}/${this.user_id}/conversations/${conversWith}`
|
|
733
801
|
console.log("getting conversation detail:", URL)
|
|
802
|
+
console.log("conversWith:", conversWith)
|
|
734
803
|
var xmlhttp = new XMLHttpRequest();
|
|
735
804
|
xmlhttp.open("GET", URL, true);
|
|
736
805
|
xmlhttp.setRequestHeader("authorization", this.jwt);
|
|
737
806
|
xmlhttp.onreadystatechange = function() {
|
|
738
|
-
console.log("onreadystatechange!")
|
|
739
807
|
if (callback && xmlhttp.readyState == 4 && xmlhttp.status == 200 && xmlhttp.responseText) {
|
|
740
808
|
try {
|
|
741
809
|
const json = JSON.parse(xmlhttp.responseText);
|
|
742
|
-
|
|
810
|
+
if (json && json.result && Array.isArray(json.result) && json.result.length ==1) {
|
|
811
|
+
callback(null, json.result[0]);
|
|
812
|
+
}
|
|
813
|
+
else {
|
|
814
|
+
callback({"message": "Incorrect conversation result."}, null);
|
|
815
|
+
}
|
|
743
816
|
}
|
|
744
817
|
catch (err) {
|
|
745
818
|
console.error("parsing json ERROR", err);
|
|
@@ -821,12 +894,11 @@ class Chat21Client {
|
|
|
821
894
|
.then(function (response) {
|
|
822
895
|
if (log) {console.log("response.status:", response.status);}
|
|
823
896
|
if (callback) {
|
|
824
|
-
if (log) { console.log("callback1()"); }
|
|
825
897
|
callback(null, response.headers, response.data);
|
|
826
898
|
}
|
|
827
899
|
})
|
|
828
900
|
.catch(function (error) {
|
|
829
|
-
|
|
901
|
+
console.error("Axios call error:", error);
|
|
830
902
|
if (callback) {
|
|
831
903
|
callback(error, null, null);
|
|
832
904
|
}
|
|
@@ -860,8 +932,10 @@ class Chat21Client {
|
|
|
860
932
|
this.user_id = user_id;
|
|
861
933
|
// console.log("userid:", this.user_id)
|
|
862
934
|
this.jwt = jwt
|
|
863
|
-
|
|
864
|
-
|
|
935
|
+
if (this.log) {
|
|
936
|
+
console.log("connecting user_id:", user_id)
|
|
937
|
+
console.log("using jwt token:", jwt)
|
|
938
|
+
}
|
|
865
939
|
|
|
866
940
|
if (this.client) {
|
|
867
941
|
this.client.end()
|
|
@@ -883,17 +957,17 @@ class Chat21Client {
|
|
|
883
957
|
clientId: this.client_id,
|
|
884
958
|
username: 'JWT',
|
|
885
959
|
password: jwt,
|
|
886
|
-
rejectUnauthorized:
|
|
960
|
+
rejectUnauthorized: true
|
|
887
961
|
}
|
|
888
|
-
console.log("starting mqtt connection with LWT on:", presence_topic, this.endpoint)
|
|
962
|
+
if (this.log) {console.log("starting mqtt connection with LWT on:", presence_topic, this.endpoint)}
|
|
889
963
|
// client = mqtt.connect('mqtt://127.0.0.1:15675/ws',options)
|
|
890
964
|
this.client = mqtt.connect(this.endpoint,options)
|
|
891
965
|
|
|
892
|
-
this.client.on('connect',
|
|
966
|
+
this.client.on('connect', // TODO if token is wrong it must reply with an error!
|
|
893
967
|
() => {
|
|
894
|
-
console.log("chat client connected...")
|
|
968
|
+
if (this.log) {console.log("chat client connected...")}
|
|
895
969
|
if (!this.connected) {
|
|
896
|
-
console.log("Chat client first connection.")
|
|
970
|
+
if (this.log) {console.log("Chat client first connection.")}
|
|
897
971
|
this.connected = true
|
|
898
972
|
this.start()
|
|
899
973
|
callback()
|
|
@@ -902,17 +976,17 @@ class Chat21Client {
|
|
|
902
976
|
);
|
|
903
977
|
this.client.on('reconnect',
|
|
904
978
|
() => {
|
|
905
|
-
console.log("Chat client reconnect event");
|
|
979
|
+
if (this.log) {console.log("Chat client reconnect event");}
|
|
906
980
|
}
|
|
907
981
|
);
|
|
908
982
|
this.client.on('close',
|
|
909
983
|
() => {
|
|
910
|
-
console.log("Chat client close event");
|
|
984
|
+
if (this.log) {console.log("Chat client close event");}
|
|
911
985
|
}
|
|
912
986
|
);
|
|
913
987
|
this.client.on('offline',
|
|
914
988
|
() => {
|
|
915
|
-
console.log("Chat client offline event");
|
|
989
|
+
if (this.log) {console.log("Chat client offline event");}
|
|
916
990
|
}
|
|
917
991
|
);
|
|
918
992
|
this.client.on('error',
|
|
@@ -925,7 +999,7 @@ class Chat21Client {
|
|
|
925
999
|
close(callback) {
|
|
926
1000
|
if (this.topic_inbox) {
|
|
927
1001
|
this.client.unsubscribe(this.topic_inbox, (err) => {
|
|
928
|
-
console.
|
|
1002
|
+
if (this.log) {console.log("unsubscribed from", this.topic_inbox);}
|
|
929
1003
|
this.client.end(() => {
|
|
930
1004
|
this.connected = false
|
|
931
1005
|
// reset all subscriptions
|
|
Binary file
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
"logLevel": "info",
|
|
6
6
|
"fileUploadAccept":"*/*",
|
|
7
7
|
"authPersistence": "LOCAL",
|
|
8
|
+
"supportMode": true,
|
|
8
9
|
"firebaseConfig": {
|
|
9
10
|
"tenant": "tilechat",
|
|
10
11
|
"apiKey": "AIzaSyCoWXHNvP1-qOllCpTshhC6VjPXeRTK0T4",
|
|
@@ -25,6 +26,7 @@
|
|
|
25
26
|
},
|
|
26
27
|
"apiUrl": "https://tiledesk-server-pre.herokuapp.com/",
|
|
27
28
|
"baseImageUrl": "https://firebasestorage.googleapis.com/v0/b/",
|
|
28
|
-
"dashboardUrl": "https://support-pre.tiledesk.com/dashboard/"
|
|
29
|
+
"dashboardUrl": "https://support-pre.tiledesk.com/dashboard/",
|
|
30
|
+
"wsUrl": "wss://tiledesk-server-pre.herokuapp.com/"
|
|
29
31
|
}
|
|
30
32
|
|
package/src/chat-config.json
CHANGED
|
@@ -23,5 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"apiUrl": "http://localhost:3000/",
|
|
25
25
|
"baseImageUrl": "https://firebasestorage.googleapis.com/v0/b/",
|
|
26
|
-
"dashboardUrl": "
|
|
26
|
+
"dashboardUrl": "https://support-pre.tiledesk.com/dashboard/",
|
|
27
|
+
"wsUrl": "ws://localhost:3000/",
|
|
28
|
+
"supportMode": false
|
|
27
29
|
}
|
|
@@ -46,7 +46,7 @@ export class ChatManager {
|
|
|
46
46
|
initialize() {
|
|
47
47
|
const appconfig = this.appConfigProvider.getConfig();
|
|
48
48
|
this.tenant = appconfig.firebaseConfig.tenant;
|
|
49
|
-
this.logger.
|
|
49
|
+
this.logger.log('[CHAT MANAGER] - initialize -> firebaseConfig tenant ', this.tenant);
|
|
50
50
|
this.handlers = [];
|
|
51
51
|
this.openInfoConversation = true;
|
|
52
52
|
this.currentUser = null;
|
|
@@ -57,7 +57,7 @@ export class ChatManager {
|
|
|
57
57
|
* setTiledeskToken
|
|
58
58
|
*/
|
|
59
59
|
public setTiledeskToken(tiledeskToken: string) {
|
|
60
|
-
this.logger.
|
|
60
|
+
this.logger.log('initialize FROM [APP-COMP] - [CHAT MANAGER] - initialize -> firebaseConfig tenant ', this.tenant);
|
|
61
61
|
this.tiledeskToken = tiledeskToken;
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -72,7 +72,7 @@ export class ChatManager {
|
|
|
72
72
|
* setCurrentUser
|
|
73
73
|
*/
|
|
74
74
|
public setCurrentUser(currentUser: UserModel) {
|
|
75
|
-
this.logger.
|
|
75
|
+
this.logger.log('initialize FROM [APP-COMP] - [CHAT MANAGER] setCurrentUser currentUser ', currentUser)
|
|
76
76
|
this.currentUser = currentUser;
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -64,7 +64,7 @@ export class FirebaseArchivedConversationsHandler extends ArchivedConversationsH
|
|
|
64
64
|
* inizializzo conversations handler
|
|
65
65
|
*/
|
|
66
66
|
initialize(tenant: string, userId: string, translationMap: Map<string, string>) {
|
|
67
|
-
this.logger.
|
|
67
|
+
this.logger.log('initialize FROM [APP-COMP] - FIREBASEArchivedConversationsHandlerSERVICE] tenant ', tenant, ' - userId: ', userId, ' - translationMap: ', translationMap)
|
|
68
68
|
this.tenant = tenant;
|
|
69
69
|
this.loggedUserId = userId;
|
|
70
70
|
this.translationMap = translationMap;
|
|
@@ -75,10 +75,10 @@ export class FirebaseAuthService extends MessagingAuthService {
|
|
|
75
75
|
*
|
|
76
76
|
*/
|
|
77
77
|
initialize() {
|
|
78
|
-
|
|
78
|
+
this.logger.log('initialize FROM [APP-COMP] [FIREBASEAuthSERVICE]')
|
|
79
79
|
this.SERVER_BASE_URL = this.getBaseUrl();
|
|
80
80
|
this.URL_TILEDESK_CREATE_CUSTOM_TOKEN = this.SERVER_BASE_URL + 'chat21/firebase/auth/createCustomToken';
|
|
81
|
-
this.logger.
|
|
81
|
+
this.logger.log('[FIREBASEAuthSERVICE] - initialize URL_TILEDESK_CREATE_CUSTOM_TOKEN ', this.URL_TILEDESK_CREATE_CUSTOM_TOKEN)
|
|
82
82
|
|
|
83
83
|
|
|
84
84
|
let firebasePersistence;
|
|
@@ -102,7 +102,7 @@ export class FirebaseAuthService extends MessagingAuthService {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
firebase.auth().setPersistence(firebasePersistence).then(async () => {
|
|
105
|
-
|
|
105
|
+
this.logger.log('[FIREBASEAuthSERVICE] firebasePersistence ', firebasePersistence)
|
|
106
106
|
// this.onAuthStateChanged(); // commented for new-login
|
|
107
107
|
})
|
|
108
108
|
.catch((error) => {
|
|
@@ -203,12 +203,12 @@ export class FirebaseAuthService extends MessagingAuthService {
|
|
|
203
203
|
// Only one subscriber x application allowed
|
|
204
204
|
// ---------------------------------------------------------------------------------------------------
|
|
205
205
|
if (this.unsubscribe) {
|
|
206
|
-
|
|
206
|
+
this.logger.log('initialize FROM [APP-COMP] - [FIREBASEAuthSERVICE] onAuthStateChanged ALREADY SUBSCRIBED')
|
|
207
207
|
return
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
this.unsubscribe = firebase.auth().onAuthStateChanged(user => {
|
|
211
|
-
|
|
211
|
+
this.logger.log('initialize FROM [APP-COMP] - [FIREBASEAuthSERVICE] onAuthStateChanged', user)
|
|
212
212
|
|
|
213
213
|
|
|
214
214
|
if (!user) {
|
|
@@ -351,7 +351,7 @@ export class FirebaseAuthService extends MessagingAuthService {
|
|
|
351
351
|
// }
|
|
352
352
|
// return firebase.auth().setPersistence(firebasePersistence).then(async () => {
|
|
353
353
|
return firebase.auth().signInWithCustomToken(token).then(async (user) => {
|
|
354
|
-
|
|
354
|
+
this.logger.log('[FIREBASEAuthSERVICE] signInWithCustomToken user: ', user);
|
|
355
355
|
if (user) {
|
|
356
356
|
this.BSAuthStateChanged.next('online');
|
|
357
357
|
}
|
|
@@ -65,7 +65,7 @@ export class FirebaseConversationHandler extends ConversationHandlerService {
|
|
|
65
65
|
* inizializzo conversation handler
|
|
66
66
|
*/
|
|
67
67
|
initialize(recipientId: string,recipientFullName: string,loggedUser: UserModel,tenant: string,translationMap: Map<string, string>) {
|
|
68
|
-
this.logger.
|
|
68
|
+
this.logger.log('[FIREBASEConversationHandlerSERVICE] initWithRecipient',recipientId, recipientFullName, loggedUser, tenant, translationMap)
|
|
69
69
|
this.recipientId = recipientId;
|
|
70
70
|
this.recipientFullname = recipientFullName;
|
|
71
71
|
this.loggedUser = loggedUser;
|
|
@@ -26,7 +26,7 @@ export class FirebaseNotifications extends NotificationsService {
|
|
|
26
26
|
initialize(tenant: string, vapId: string): void {
|
|
27
27
|
this.tenant = tenant
|
|
28
28
|
this.vapidkey = vapId
|
|
29
|
-
this.logger.
|
|
29
|
+
this.logger.log('[FIREBASE-NOTIFICATIONS] initialize - tenant ', this.tenant)
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
if (!('serviceWorker' in navigator)) {
|
|
@@ -49,7 +49,7 @@ export class FirebasePresenceService extends PresenceService {
|
|
|
49
49
|
public initialize(tenant: string) {
|
|
50
50
|
// this.tenant = this.getTenant();
|
|
51
51
|
this.tenant = tenant;
|
|
52
|
-
this.logger.
|
|
52
|
+
this.logger.log('[FIREBASEPresenceSERVICE] initialize this.tenant', this.tenant);
|
|
53
53
|
this.urlNodePresence = '/apps/' + this.tenant + '/presence/';
|
|
54
54
|
}
|
|
55
55
|
|
|
@@ -129,7 +129,7 @@ export class FirebasePresenceService extends PresenceService {
|
|
|
129
129
|
* @param userid
|
|
130
130
|
*/
|
|
131
131
|
public setPresence(userid: string): void {
|
|
132
|
-
this.logger.
|
|
132
|
+
this.logger.log('initialize FROM [APP-COMP] - [FIREBASEPresenceSERVICE] - SET PRESENCE userid ', userid)
|
|
133
133
|
this.onlineConnectionsRef = this.referenceOnlineForUser(userid);
|
|
134
134
|
this.lastOnlineConnectionsRef = this.referenceLastOnlineForUser(userid);
|
|
135
135
|
const connectedRefURL = '/.info/connected';
|
|
@@ -52,7 +52,7 @@ export class FirebaseTypingService extends TypingService {
|
|
|
52
52
|
public initialize(tenant: string) {
|
|
53
53
|
// this.tenant = this.getTenant();
|
|
54
54
|
this.tenant = tenant;
|
|
55
|
-
this.logger.
|
|
55
|
+
this.logger.log('[FIREBASETypingSERVICE] initialize - tenant ', this.tenant)
|
|
56
56
|
this.urlNodeTypings = '/apps/' + this.tenant + '/typings/';
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -43,7 +43,7 @@ export class FirebaseUploadService extends UploadService {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
public initialize() {
|
|
46
|
-
this.logger.
|
|
46
|
+
this.logger.log('[FIREBASEUploadSERVICE] initialize');
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
public upload(userId: string, upload: UploadModel): Promise<any> {
|