@chat21/chat21-ionic 3.0.59-rc4 → 3.0.59

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.
Files changed (63) hide show
  1. package/CHANGELOG.md +77 -0
  2. package/README.md +5 -0
  3. package/config.xml +2 -2
  4. package/env.sample +3 -1
  5. package/package.json +1 -1
  6. package/resources/Android/splash/drawable-land-hdpi-screen.png +0 -0
  7. package/resources/Android/splash/drawable-land-ldpi-screen.png +0 -0
  8. package/resources/Android/splash/drawable-land-mdpi-screen.png +0 -0
  9. package/resources/Android/splash/drawable-land-xhdpi-screen.png +0 -0
  10. package/resources/Android/splash/drawable-land-xxhdpi-screen.png +0 -0
  11. package/resources/Android/splash/drawable-land-xxxhdpi-screen.png +0 -0
  12. package/resources/Android/splash/drawable-port-hdpi-screen.png +0 -0
  13. package/resources/Android/splash/drawable-port-ldpi-screen.png +0 -0
  14. package/resources/Android/splash/drawable-port-mdpi-screen.png +0 -0
  15. package/resources/Android/splash/drawable-port-xhdpi-screen.png +0 -0
  16. package/resources/Android/splash/drawable-port-xxhdpi-screen.png +0 -0
  17. package/resources/Android/splash/drawable-port-xxxhdpi-screen.png +0 -0
  18. package/resources/Android/splash.png +0 -0
  19. package/src/app/app.component.scss +10 -5
  20. package/src/app/app.component.ts +393 -234
  21. package/src/app/app.module.ts +12 -7
  22. package/src/app/chatlib/conversation-detail/conversation-content/conversation-content.component.html +1 -1
  23. package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.html +7 -6
  24. package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.ts +2 -1
  25. package/src/app/chatlib/list-conversations-component/list-conversations/list-conversations.component.html +1 -1
  26. package/src/app/components/authentication/login/login.component.html +8 -8
  27. package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.html +2 -4
  28. package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.ts +7 -2
  29. package/src/app/components/ddp-header/ddp-header.component.html +1 -1
  30. package/src/app/components/ddp-header/ddp-header.component.ts +4 -2
  31. package/src/app/components/project-item/project-item.component.html +61 -16
  32. package/src/app/components/project-item/project-item.component.scss +165 -38
  33. package/src/app/components/project-item/project-item.component.ts +58 -36
  34. package/src/app/pages/authentication/login/login.page.html +1 -2
  35. package/src/app/pages/conversation-detail/conversation-detail.page.ts +2 -0
  36. package/src/app/pages/conversations-list/conversations-list.page.html +12 -7
  37. package/src/app/pages/conversations-list/conversations-list.page.scss +279 -261
  38. package/src/app/pages/conversations-list/conversations-list.page.ts +149 -17
  39. package/src/app/pages/unassigned-conversations/unassigned-conversations.page.html +10 -2
  40. package/src/app/pages/unassigned-conversations/unassigned-conversations.page.scss +79 -0
  41. package/src/app/pages/unassigned-conversations/unassigned-conversations.page.ts +47 -36
  42. package/src/app/services/app-config.ts +77 -5
  43. package/src/app/services/websocket/websocket-js.ts +12 -14
  44. package/src/app/services/websocket/websocket.service.ts +26 -8
  45. package/src/assets/i18n/en.json +2 -1
  46. package/src/assets/i18n/it.json +2 -1
  47. package/src/assets/js/chat21client.js +144 -82
  48. package/src/assets/logo.png +0 -0
  49. package/src/assets/transparent.png +0 -0
  50. package/src/chat-config-pre-test.json +3 -1
  51. package/src/chat-config-template.json +4 -1
  52. package/src/chat-config.json +4 -1
  53. package/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts +1 -1
  54. package/src/chat21-core/providers/firebase/firebase-conversations-handler.ts +1 -1
  55. package/src/chat21-core/providers/firebase/firebase-notifications.ts +31 -23
  56. package/src/chat21-core/providers/mqtt/mqtt-auth-service.ts +27 -27
  57. package/src/chat21-core/providers/mqtt/mqtt-conversation-handler.ts +3 -5
  58. package/src/chat21-core/providers/mqtt/mqtt-conversations-handler.ts +13 -5
  59. package/src/chat21-core/providers/mqtt/mqtt-notifications.ts +101 -11
  60. package/src/chat21-core/providers/tiledesk/tiledesk-auth.service.ts +12 -3
  61. package/src/chat21-core/utils/utils-message.ts +2 -2
  62. package/src/firebase-messaging-sw-template.js +1 -1
  63. package/src/assets/images/tiledesk_logo_50x50.png +0 -0
@@ -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.9
10
5
 
11
- v. 0.1.4
12
- - added basicMessageBuilder()
13
- - added sendMessageRaw()
14
- - added leaveGroup()
15
-
6
+ @Author Andrea Sponziello
16
7
  (c) Tiledesk 2020
17
8
  */
18
9
 
@@ -31,10 +22,12 @@ class Chat21Client {
31
22
  this.client = null;
32
23
  this.reconnections = 0 // just to check how many reconnections
33
24
  this.client_id = this.uuidv4();
25
+ this.log = options._log ? true : false;
34
26
  if (options && options.MQTTendpoint) {
35
27
  if (options.MQTTendpoint.startsWith('/')) {
36
- console.log("MQTTendpoint relative url");
37
-
28
+ if (this.log) {
29
+ console.log("MQTTendpoint relative url");
30
+ }
38
31
  var loc = window.location, new_uri;
39
32
  if (loc.protocol === "https:") {
40
33
  // new_uri = "wss:";
@@ -56,10 +49,11 @@ class Chat21Client {
56
49
  else {
57
50
  this.endpoint = "ws://34.253.207.0:15675/ws"
58
51
  }
59
- this.log = options.log ? true : false;
60
52
  this.APIendpoint = options.APIendpoint;
61
53
  this.appid = options.appId;
62
- console.log("final endpoint:", this.endpoint)
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,27 +80,19 @@ 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
- console.log("subscribing to:", this.user_id, "topic", this.topic_inbox)
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
- console.log("subscribed to:", this.topic_inbox, " with err", err)
92
- })
87
+ if (this.log) {
88
+ console.log("subscribed to:", this.topic_inbox, " with err", err)
89
+ }
90
+ });
93
91
  }
94
92
 
95
- // subscribeToMyMessages() {
96
- // // this subscription because in /conversations I receive my messages
97
- // // 'apps/tilechat/users/ME/messages/TO/outgoing'
98
- // // 'apps/tilechat/users/ME/messages/FROM/incoming'
99
- // let messages_inbox = 'apps/tilechat/users/' + this.user_id + '/messages/+'
100
- // console.log("subscribing to inbox of:", this.user_id, "topic", messages_inbox)
101
- // this.client.subscribe(messages_inbox, (err) => {
102
- // console.log("subscribed to:", messages_inbox, " with err", err)
103
- // })
104
- // }
105
-
106
93
  sendMessage(text, type, recipient_id, recipient_fullname, sender_fullname, attributes, metadata, channel_type, callback) {
107
- // callback - function (err)
108
- // console.log("recipient_id:", recipient_id)
109
- let dest_topic = `apps/${this.appid}/users/${this.user_id}/messages/${recipient_id}/outgoing`
94
+ // console.log("sendMessage:",text, recipient_id)
95
+ let dest_topic = `apps/${this.appid}/outgoing/users/${this.user_id}/messages/${recipient_id}/outgoing`
110
96
  // console.log("dest_topic:", dest_topic)
111
97
  let outgoing_message = {
112
98
  text: text,
@@ -140,7 +126,7 @@ class Chat21Client {
140
126
  sendMessageRaw(outgoing_message, recipient_id, callback) {
141
127
  // callback - function (err)
142
128
  // console.log("recipient_id:", recipient_id)
143
- let dest_topic = `apps/${this.appid}/users/${this.user_id}/messages/${recipient_id}/outgoing`
129
+ let dest_topic = `apps/${this.appid}/outgoing/users/${this.user_id}/messages/${recipient_id}/outgoing`
144
130
  // console.log("dest_topic:", dest_topic)
145
131
  // let outgoing_message = {
146
132
  // text: text,
@@ -159,16 +145,22 @@ class Chat21Client {
159
145
  }
160
146
 
161
147
  updateMessageStatus(messageId, conversWith, status, callback) {
162
- // callback - function (err)
163
- console.log("updating recipient_id:", messageId, "on conversWith", conversWith, "status", status)
148
+ // callback - function (err)
149
+ if (this.log) {
150
+ console.log("updating recipient_id:", messageId, "on conversWith", conversWith, "status", status)
151
+ }
164
152
  // 'apps/tilechat/users/USER_ID/messages/CONVERS_WITH/MESSAGE_ID/update'
165
153
  let dest_topic = `apps/${this.appid}/users/${this.user_id}/messages/${conversWith}/${messageId}/update`
166
- console.log("update dest_topic:", dest_topic)
154
+ if (this.log) {
155
+ console.log("update dest_topic:", dest_topic);
156
+ }
167
157
  let message_patch = {
168
158
  status: status
169
159
  }
170
160
  const payload = JSON.stringify(message_patch)
171
- console.log("payload:", payload)
161
+ if (this.log) {
162
+ console.log("payload:", payload)
163
+ }
172
164
  this.client.publish(dest_topic, payload, null, (err) => {
173
165
  if (callback) {
174
166
  callback(err, message_patch)
@@ -177,16 +169,22 @@ class Chat21Client {
177
169
  }
178
170
 
179
171
  updateConversationIsNew(conversWith, is_new, callback) {
180
- // callback - function (err)
181
- console.log("updating conversation with:", conversWith, "is_new", is_new)
172
+ // callback - function (err)
173
+ if (this.log) {
174
+ console.log("updating conversation with:", conversWith, "is_new", is_new);
175
+ }
182
176
  // 'apps/tilechat/users/USER_ID/conversations/CONVERS_WITH/update'
183
177
  let dest_topic = `apps/${this.appid}/users/${this.user_id}/conversations/${conversWith}/update` //'apps/tilechat/users/' + this.user_id + '/conversations/' + conversWith + '/update'
184
- console.log("update dest_topic:", dest_topic)
178
+ if (this.log) {
179
+ console.log("update dest_topic:", dest_topic);
180
+ }
185
181
  let patch = {
186
182
  is_new: is_new
187
183
  }
188
184
  const payload = JSON.stringify(patch)
189
- console.log("payload:", payload)
185
+ if (this.log) {
186
+ console.log("payload:", payload);
187
+ }
190
188
  this.client.publish(dest_topic, payload, null, (err) => {
191
189
  if (callback) {
192
190
  callback(err)
@@ -207,7 +205,9 @@ class Chat21Client {
207
205
  // }
208
206
 
209
207
  // callback - function (err)
210
- console.log("creating group:", name, "id", group_id, "members", members)
208
+ if (this.log) {
209
+ console.log("creating group:", name, "id", group_id, "members", members)
210
+ }
211
211
  // who creates the group is also group-owner
212
212
  // ex.: http://localhost:8004/api/tilechat/04-ANDREASPONZIELLO/groups
213
213
  // let data = {
@@ -221,7 +221,9 @@ class Chat21Client {
221
221
  // }
222
222
 
223
223
  const URL = `${this.APIendpoint}/${this.appid}/groups`
224
- console.log("creating group...", URL)
224
+ if (this.log) {
225
+ console.log("creating group...", URL)
226
+ }
225
227
  let options = {
226
228
  url: URL,
227
229
  headers: {
@@ -306,9 +308,13 @@ class Chat21Client {
306
308
  }
307
309
 
308
310
  groupLeave(group_id, member_id, callback) {
309
- console.log("leaving group:", group_id);
311
+ if (this.log) {
312
+ console.log("leaving group:", group_id);
313
+ }
310
314
  const URL = `${this.APIendpoint}/${this.appid}/groups/${group_id}/members/${member_id}`
311
- console.log("leaving group:", URL)
315
+ if (this.log) {
316
+ console.log("leaving group:", URL)
317
+ }
312
318
  let options = {
313
319
  url: URL,
314
320
  headers: {
@@ -328,9 +334,13 @@ class Chat21Client {
328
334
  }
329
335
 
330
336
  groupJoin(group_id, member_id, callback) {
331
- console.log("leaving group:", group_id);
337
+ if (this.log) {
338
+ console.log("leaving group:", group_id);
339
+ }
332
340
  const URL = `${this.APIendpoint}/${this.appid}/groups/${group_id}/members`
333
- console.log("joining group:", URL)
341
+ if (this.log) {
342
+ console.log("joining group:", URL)
343
+ }
334
344
  let options = {
335
345
  url: URL,
336
346
  headers: {
@@ -361,9 +371,13 @@ class Chat21Client {
361
371
  // "6067513cb64a9b1ba259839c":1
362
372
  // }
363
373
  // }
364
- console.log("setting group members of", group_id, "members", members)
374
+ if (this.log) {
375
+ console.log("setting group members of", group_id, "members", members)
376
+ }
365
377
  const URL = `${this.APIendpoint}/${this.appid}/groups/${group_id}/members`
366
- console.log("setting group members...", URL)
378
+ if (this.log) {
379
+ console.log("setting group members...", URL)
380
+ }
367
381
  let options = {
368
382
  url: URL,
369
383
  headers: {
@@ -385,12 +399,45 @@ class Chat21Client {
385
399
  }, this.log);
386
400
  }
387
401
 
402
+ saveInstance(instance_id, data, callback) {
403
+ if (this.log) {
404
+ console.log("saving instance_id:", instance_id, "data", data);
405
+ }
406
+
407
+ // /:app_id/:user_id/instances/:instance_id
408
+ const URL = `${this.APIendpoint}/${this.appid}/${this.user_id}/instances/${instance_id}`
409
+ if (this.log) {
410
+ console.log("saving instance...");
411
+ }
412
+ let options = {
413
+ url: URL,
414
+ headers: {
415
+ "Authorization": this.jwt,
416
+ "Content-Type": "application/json;charset=UTF-8"
417
+ },
418
+ data: data,
419
+ method: 'POST'
420
+ }
421
+ Chat21Client.myrequest(options, (err, response, json) => {
422
+ if (err) {
423
+ callback(err, null);
424
+ }
425
+ else if (json && callback) {
426
+ callback(null, json);
427
+ }
428
+ }, this.log);
429
+ }
430
+
388
431
  archiveConversation(conversWith, callback) {
389
432
  // callback - function (err)
390
- console.log("archiving conversation with:", conversWith)
433
+ if (this.log) {
434
+ console.log("archiving conversation with:", conversWith)
435
+ }
391
436
  // 'apps/tilechat/users/USER_ID/conversations/CONVERS_WITH/archive'
392
437
  let dest_topic = 'apps/tilechat/users/' + this.user_id + '/conversations/' + conversWith + '/archive'
393
- console.log("archive dest_topic:", dest_topic)
438
+ if (this.log) {
439
+ console.log("archive dest_topic:", dest_topic)
440
+ }
394
441
  // let patch = {
395
442
  // action: 'archive'
396
443
  // }
@@ -440,7 +487,6 @@ class Chat21Client {
440
487
  }
441
488
 
442
489
  onMessageAdded(callback) {
443
- console.log("onMessageAdded(callback)")
444
490
  this.last_handler++
445
491
  this.onMessageAddedCallbacks.set(this.last_handler, callback)
446
492
  return this.last_handler;
@@ -485,20 +531,24 @@ class Chat21Client {
485
531
  }
486
532
 
487
533
  onMessageUpdated(callback) {
488
- this.last_handler++
534
+ this.last_handler += 1
489
535
  this.onMessageUpdatedCallbacks.set(this.last_handler, callback)
490
536
  return this.last_handler;
491
537
  }
492
538
 
493
539
  onGroupUpdated(callback) {
494
- this.last_handler++
540
+ this.last_handler += 1
495
541
  this.onGroupUpdatedCallbacks.set(this.last_handler, callback)
496
542
  return this.last_handler;
497
543
  }
498
544
 
499
- // removeMessageHandler(handler) {
500
- // this.onMessageCallbacks.delete(handler)
501
- // }
545
+ removeOnMessageAddedHandler(handler) {
546
+ this.onMessageAddedCallbacks.delete(handler);
547
+ }
548
+
549
+ removeOnGroupUpdatedHandler(handler) {
550
+ this.onGroupUpdatedCallbacks.delete(handler);
551
+ }
502
552
 
503
553
  start() {
504
554
  if (this.on_message_handler) {
@@ -511,7 +561,9 @@ class Chat21Client {
511
561
  // console.log("topic:" + topic + "\nmessage payload:" + message)
512
562
  const _topic = this.parseTopic(topic)
513
563
  if (!_topic) {
514
- console.log("Invalid message topic:", topic);
564
+ if (this.log) {
565
+ console.log("Invalid message topic:", topic);
566
+ }
515
567
  return;
516
568
  }
517
569
  const conversWith = _topic.conversWith
@@ -533,7 +585,9 @@ class Chat21Client {
533
585
  if (this.onConversationUpdatedCallbacks) {
534
586
  // example topic: apps.tilechat.users.ME.conversations.CONVERS-WITH.clientdeleted
535
587
  if (topic.includes("/conversations/") && topic.endsWith(_CLIENTUPDATED)) {
536
- console.log("conversation updated! /conversations/, topic:", topic)
588
+ if (this.log) {
589
+ console.log("conversation updated! /conversations/, topic:", topic)
590
+ }
537
591
  // map.forEach((value, key, map) =>)
538
592
  this.onConversationUpdatedCallbacks.forEach((callback, handler, map) => {
539
593
  callback(JSON.parse(message.toString()), topic)
@@ -544,7 +598,9 @@ class Chat21Client {
544
598
  if (this.onConversationDeletedCallbacks) {
545
599
  if (topic.includes("/conversations/") && topic.endsWith(_CLIENTDELETED)) {
546
600
  // map.forEach((value, key, map) =>)
547
- console.log("conversation deleted! /conversations/, topic:", topic, message.toString() );
601
+ if (this.log) {
602
+ console.log("conversation deleted! /conversations/, topic:", topic, message.toString() );
603
+ }
548
604
  this.onConversationDeletedCallbacks.forEach((callback, handler, map) => {
549
605
  callback(JSON.parse(message.toString()), topic)
550
606
  });
@@ -627,16 +683,16 @@ class Chat21Client {
627
683
  // }
628
684
  const type = callback_obj.type
629
685
  if (topic.includes("/messages/") && topic.endsWith(_CLIENTADDED)) {
630
- console.log("/messages/_CLIENTADDED")
686
+ if (this.log) { console.log("/messages/_CLIENTADDED") }
631
687
  if (type === CALLBACK_TYPE_ON_MESSAGE_ADDED_FOR_CONVERSATION) {
632
688
  if (conversWith === callback_obj.conversWith) {
633
- console.log("/messages/_CLIENTADDED on: ", conversWith)
689
+ if (this.log) { console.log("/messages/_CLIENTADDED on: ", conversWith)}
634
690
  callback_obj.callback(JSON.parse(message.toString()), _topic)
635
691
  }
636
692
  }
637
693
  }
638
694
  if (topic.includes("/messages/") && topic.endsWith(_CLIENTUPDATED)) {
639
- console.log("/messages/_CLIENTUPDATED")
695
+ if (this.log) {console.log("/messages/_CLIENTUPDATED")}
640
696
  if (type === CALLBACK_TYPE_ON_MESSAGE_UPDATED_FOR_CONVERSATION) {
641
697
  if (conversWith === callback_obj.conversWith) {
642
698
  console.log("/messages/_CLIENTUPDATED on: ", conversWith)
@@ -657,7 +713,7 @@ class Chat21Client {
657
713
 
658
714
  }
659
715
  catch (err) {
660
- console.log("ERROR:", err)
716
+ console.error("ERROR:", err)
661
717
  }
662
718
  })
663
719
  // console.log("HANDLER_:", this.on_message_handler)
@@ -683,7 +739,7 @@ class Chat21Client {
683
739
  lastArchivedConversations(callback) {
684
740
  // ex.: http://localhost:8004/tilechat/04-ANDREASPONZIELLO/archived_conversations
685
741
  const URL = `${this.APIendpoint}/${this.appid}/${this.user_id}/archived_conversations`
686
- console.log("getting last archived conversations...", URL)
742
+ if (this.log) {console.log("getting last archived conversations...", URL)}
687
743
  var xmlhttp = new XMLHttpRequest();
688
744
  xmlhttp.open("GET", URL, true);
689
745
  xmlhttp.setRequestHeader("authorization", this.jwt);
@@ -695,7 +751,7 @@ class Chat21Client {
695
751
  callback(null, json.result)
696
752
  }
697
753
  catch (err) {
698
- console.log("parsing json ERROR", err)
754
+ console.error("parsing json ERROR", err)
699
755
  callback(err, null)
700
756
  }
701
757
  }
@@ -707,7 +763,7 @@ class Chat21Client {
707
763
  // ex.: http://localhost:8004/tilechat/04-ANDREASPONZIELLO/conversations
708
764
  const archived_url_part = archived ? '/archived' : '';
709
765
  const URL = `${this.APIendpoint}/${this.appid}/${this.user_id}/conversations` + archived_url_part;
710
- console.log("getting last convs...", URL);
766
+ if (this.log) {console.log("getting last convs...", URL);}
711
767
  var xmlhttp = new XMLHttpRequest();
712
768
  xmlhttp.open("GET", URL, true);
713
769
  xmlhttp.setRequestHeader("authorization", this.jwt);
@@ -719,7 +775,7 @@ class Chat21Client {
719
775
  callback(null, json.result)
720
776
  }
721
777
  catch (err) {
722
- console.log("parsing json ERROR", err)
778
+ console.error("parsing json ERROR", err)
723
779
  callback(err, null)
724
780
  }
725
781
  }
@@ -731,15 +787,20 @@ class Chat21Client {
731
787
  // ex.: http://localhost:8004/tilechat/04-ANDREASPONZIELLO/conversations/CONVERS_WITH
732
788
  const URL = `${this.APIendpoint}/${this.appid}/${this.user_id}/conversations/${conversWith}`
733
789
  console.log("getting conversation detail:", URL)
790
+ console.log("conversWith:", conversWith)
734
791
  var xmlhttp = new XMLHttpRequest();
735
792
  xmlhttp.open("GET", URL, true);
736
793
  xmlhttp.setRequestHeader("authorization", this.jwt);
737
794
  xmlhttp.onreadystatechange = function() {
738
- console.log("onreadystatechange!")
739
795
  if (callback && xmlhttp.readyState == 4 && xmlhttp.status == 200 && xmlhttp.responseText) {
740
796
  try {
741
797
  const json = JSON.parse(xmlhttp.responseText);
742
- callback(null, json.result);
798
+ if (json && json.result && Array.isArray(json.result) && json.result.length ==1) {
799
+ callback(null, json.result[0]);
800
+ }
801
+ else {
802
+ callback({"message": "Incorrect conversation result."}, null);
803
+ }
743
804
  }
744
805
  catch (err) {
745
806
  console.error("parsing json ERROR", err);
@@ -821,12 +882,11 @@ class Chat21Client {
821
882
  .then(function (response) {
822
883
  if (log) {console.log("response.status:", response.status);}
823
884
  if (callback) {
824
- if (log) { console.log("callback1()"); }
825
885
  callback(null, response.headers, response.data);
826
886
  }
827
887
  })
828
888
  .catch(function (error) {
829
- if (log) { console.log("Axios call error:", error); }
889
+ console.error("Axios call error:", error);
830
890
  if (callback) {
831
891
  callback(error, null, null);
832
892
  }
@@ -860,8 +920,10 @@ class Chat21Client {
860
920
  this.user_id = user_id;
861
921
  // console.log("userid:", this.user_id)
862
922
  this.jwt = jwt
863
- console.log("connecting user_id:", user_id)
864
- console.log("using jwt token:", jwt)
923
+ if (this.log) {
924
+ console.log("connecting user_id:", user_id)
925
+ console.log("using jwt token:", jwt)
926
+ }
865
927
 
866
928
  if (this.client) {
867
929
  this.client.end()
@@ -885,15 +947,15 @@ class Chat21Client {
885
947
  password: jwt,
886
948
  rejectUnauthorized: false
887
949
  }
888
- console.log("starting mqtt connection with LWT on:", presence_topic, this.endpoint)
950
+ if (this.log) {console.log("starting mqtt connection with LWT on:", presence_topic, this.endpoint)}
889
951
  // client = mqtt.connect('mqtt://127.0.0.1:15675/ws',options)
890
952
  this.client = mqtt.connect(this.endpoint,options)
891
953
 
892
- this.client.on('connect',
954
+ this.client.on('connect', // TODO if token is wrong it must reply with an error!
893
955
  () => {
894
- console.log("chat client connected...")
956
+ if (this.log) {console.log("chat client connected...")}
895
957
  if (!this.connected) {
896
- console.log("Chat client first connection.")
958
+ if (this.log) {console.log("Chat client first connection.")}
897
959
  this.connected = true
898
960
  this.start()
899
961
  callback()
@@ -902,17 +964,17 @@ class Chat21Client {
902
964
  );
903
965
  this.client.on('reconnect',
904
966
  () => {
905
- console.log("Chat client reconnect event");
967
+ if (this.log) {console.log("Chat client reconnect event");}
906
968
  }
907
969
  );
908
970
  this.client.on('close',
909
971
  () => {
910
- console.log("Chat client close event");
972
+ if (this.log) {console.log("Chat client close event");}
911
973
  }
912
974
  );
913
975
  this.client.on('offline',
914
976
  () => {
915
- console.log("Chat client offline event");
977
+ if (this.log) {console.log("Chat client offline event");}
916
978
  }
917
979
  );
918
980
  this.client.on('error',
@@ -925,7 +987,7 @@ class Chat21Client {
925
987
  close(callback) {
926
988
  if (this.topic_inbox) {
927
989
  this.client.unsubscribe(this.topic_inbox, (err) => {
928
- console.error("unsubscribed from", this.topic_inbox);
990
+ if (this.log) {console.log("unsubscribed from", this.topic_inbox);}
929
991
  this.client.end(() => {
930
992
  this.connected = false
931
993
  // reset all subscriptions
Binary file
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
 
@@ -23,5 +23,8 @@
23
23
  },
24
24
  "apiUrl": "${API_URL}",
25
25
  "baseImageUrl": "${API_BASEIMAGE_URL}",
26
- "dashboardUrl": "${DASHBOARD_URL}"
26
+ "dashboardUrl": "${DASHBOARD_URL}",
27
+ "wsUrl": "${WS_URL}",
28
+ "wsUrlRel": "${WS_URL_RELATIVE}",
29
+ "supportMode": "${SUPPORT_MODE}"
27
30
  }
@@ -23,5 +23,8 @@
23
23
  },
24
24
  "apiUrl": "http://localhost:3000/",
25
25
  "baseImageUrl": "https://firebasestorage.googleapis.com/v0/b/",
26
- "dashboardUrl": "http://localhost:4500/"
26
+ "dashboardUrl": "https://support-pre.tiledesk.com/dashboard/",
27
+ "wsUrl": "ws://localhost:3000/",
28
+ "wsUrlRel": "${WS_URL_RELATIVE}",
29
+ "supportMode": false
27
30
  }
@@ -306,7 +306,7 @@ export class FirebaseArchivedConversationsHandler extends ArchivedConversationsH
306
306
  this.archivedConversationAdded.next(conversationAdded);
307
307
  }
308
308
  } else {
309
- this.logger.error('[FIREBASEArchivedConversationsHandlerSERVICE] ADDED::conversations with conversationId: ', childSnapshot.key, 'is not valid')
309
+ // this.logger.error('[FIREBASEArchivedConversationsHandlerSERVICE] ADDED::conversations with conversationId: ', childSnapshot.key, 'is not valid')
310
310
  }
311
311
  }
312
312
 
@@ -400,7 +400,7 @@ export class FirebaseConversationsHandler extends ConversationsHandlerService {
400
400
  this.conversationAdded.next(conversationAdded);
401
401
  }
402
402
  } else {
403
- this.logger.log('[FIREBASEConversationsHandlerSERVICE]ADDED::conversations with conversationId: ', childSnapshot.key, 'is not valid')
403
+ // this.logger.log('[FIREBASEConversationsHandlerSERVICE]ADDED::conversations with conversationId: ', childSnapshot.key, 'is not valid')
404
404
  }
405
405
  }
406
406
 
@@ -34,29 +34,37 @@ export class FirebaseNotifications extends NotificationsService {
34
34
  this.logger.error("[FIREBASE-NOTIFICATIONS] initialize - Service Worker isn't supported on this browser", navigator)
35
35
  return;
36
36
  }
37
- if (('serviceWorker' in navigator)) {
38
- // this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser ", navigator)
39
- navigator.serviceWorker.getRegistrations().then((serviceWorkerRegistrations) => {
40
- this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser serviceWorkerRegistrations", serviceWorkerRegistrations)
41
- if (serviceWorkerRegistrations.length > 0) {
42
- serviceWorkerRegistrations.forEach(registration => {
43
- this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser registration ", registration)
44
- // this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser registrations scriptURL", registrations.active.scriptURL)
45
- // this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser registrations state", registrations.active.state)
46
-
47
- });
48
- } else {
49
- this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser - !not registered",)
50
- // navigator.serviceWorker.register('http://localhost:8101/firebase-messaging-sw.js')
51
- // .then(function (registration) {
52
- // console.log('Service worker successfully registered.');
53
- // return registration;
54
- // }).catch(function (err) {
55
- // console.error('Unable to register service worker.', err);
56
- // });
57
- }
58
- });
59
- }
37
+ // if (('serviceWorker' in navigator)) {
38
+ // navigator.serviceWorker.register('firebase-messaging-sw.js')
39
+ // .then(function (registration) {
40
+ // console.log('[FIREBASE-NOTIFICATIONS] initialize serviceWorker Registration successful, scope is:', registration.scope);
41
+
42
+
43
+ // // this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser ", navigator)
44
+ // // navigator.serviceWorker.getRegistrations().then((serviceWorkerRegistrations) => {
45
+ // // this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser serviceWorkerRegistrations", serviceWorkerRegistrations)
46
+ // // if (serviceWorkerRegistrations.length > 0) {
47
+ // // serviceWorkerRegistrations.forEach(registration => {
48
+ // // this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser registration ", registration)
49
+ // // // this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser registrations scriptURL", registrations.active.scriptURL)
50
+ // // // this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser registrations state", registrations.active.state)
51
+
52
+ // // });
53
+ // // } else {
54
+ // // this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser - !not registered",)
55
+ // // // navigator.serviceWorker.register('http://localhost:8101/firebase-messaging-sw.js')
56
+ // // // .then(function (registration) {
57
+ // // // console.log('Service worker successfully registered.');
58
+ // // // return registration;
59
+ // // // }).catch(function (err) {
60
+ // // // console.error('Unable to register service worker.', err);
61
+ // // // });
62
+ // // }
63
+ // // });
64
+ // }).catch(function (err) {
65
+ // console.log('Service worker registration failed, error:', err);
66
+ // });
67
+ // }
60
68
  }
61
69
 
62
70