@chat21/chat21-web-widget 5.0.53-rc.3 → 5.0.53-rc.4

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 (43) hide show
  1. package/CHANGELOG.md +15 -2
  2. package/package.json +1 -1
  3. package/src/app/app.component.ts +18 -8
  4. package/src/app/app.module.ts +10 -8
  5. package/src/app/component/conversation-detail/conversation/conversation.component.ts +15 -1
  6. package/src/app/component/conversation-detail/conversation-content/conversation-content.component.spec.ts +2 -2
  7. package/src/app/component/last-message/last-message.component.html +83 -72
  8. package/src/app/component/last-message/last-message.component.scss +98 -42
  9. package/src/app/component/last-message/last-message.component.spec.ts +2 -2
  10. package/src/app/component/last-message/last-message.component.ts +49 -25
  11. package/src/app/component/list-all-conversations/list-all-conversations.component.ts +1 -1
  12. package/src/app/component/message/bubble-message/bubble-message.component.html +0 -5
  13. package/src/app/component/message/html/html.component.spec.ts +1 -1
  14. package/src/app/component/message/info-message/info-message.component.spec.ts +1 -1
  15. package/src/app/component/message/text/text.component.scss +4 -0
  16. package/src/app/component/message/text/text.component.spec.ts +2 -2
  17. package/src/app/component/message-attachment/message-attachment.component.html +1 -1
  18. package/src/app/component/message-attachment/message-attachment.component.ts +2 -0
  19. package/src/app/{directives → pipe}/html-entites-encode.pipe.spec.ts +0 -0
  20. package/src/app/{directives → pipe}/html-entities-encode.pipe.ts +0 -0
  21. package/src/app/{directives → pipe}/marked.pipe.spec.ts +0 -0
  22. package/src/app/{directives → pipe}/marked.pipe.ts +0 -0
  23. package/src/app/{directives → pipe}/safe-html.pipe.spec.ts +0 -0
  24. package/src/app/{directives → pipe}/safe-html.pipe.ts +0 -0
  25. package/src/app/providers/events.service.spec.ts +16 -0
  26. package/src/app/providers/events.service.ts +76 -0
  27. package/src/app/providers/global-settings.service.ts +11 -12
  28. package/src/app/utils/globals.ts +4 -1
  29. package/src/app/utils/rules.ts +88 -5
  30. package/src/assets/js/chat21client.js +27 -4
  31. package/src/assets/twp/chatbot-panel.html +0 -5
  32. package/src/chat21-core/models/conversation.ts +2 -2
  33. package/src/chat21-core/models/upload.ts +1 -0
  34. package/src/chat21-core/providers/abstract/presence.service.ts +1 -0
  35. package/src/chat21-core/providers/firebase/firebase-conversation-handler.ts +78 -106
  36. package/src/chat21-core/providers/firebase/firebase-presence.service.ts +4 -0
  37. package/src/chat21-core/providers/mqtt/mqtt-conversation-handler.ts +2 -29
  38. package/src/chat21-core/providers/mqtt/mqtt-presence.service.ts +13 -156
  39. package/src/chat21-core/providers/tiledesk/tiledesk-requests.service.ts +21 -4
  40. package/src/chat21-core/utils/utils-message.ts +36 -0
  41. package/src/iframe-style.css +2 -2
  42. package/src/models/project.ts +4 -1
  43. package/src/models/rule.ts +18 -0
@@ -1,3 +1,6 @@
1
+ import { MessageModel } from './../../../chat21-core/models/message';
2
+ import { UserModel } from './../../../chat21-core/models/user';
3
+ import { EventsService } from './../../providers/events.service';
1
4
  import { Component, OnInit, Output, OnDestroy, AfterViewInit, EventEmitter, Input, SimpleChanges } from '@angular/core';
2
5
  import { Subscription } from 'rxjs';
3
6
  // services
@@ -6,9 +9,9 @@ import { Globals } from 'src/app/utils/globals';
6
9
  // utils
7
10
  import { popupUrl, isPopupUrl, strip_tags } from '../../utils/utils';
8
11
 
9
- import { MAX_WIDTH_IMAGES} from 'src/app/utils/constants';
12
+ import { MIN_WIDTH_IMAGES } from 'src/app/utils/constants';
10
13
  import { ConversationModel } from 'src/chat21-core/models/conversation';
11
- import { isImage } from 'src/chat21-core/utils/utils-message';
14
+ import { conversationToMessage, isEmojii, isImage } from 'src/chat21-core/utils/utils-message';
12
15
  import { ImageRepoService } from 'src/chat21-core/providers/abstract/image-repo.service';
13
16
  import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
14
17
  import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
@@ -30,15 +33,14 @@ export class LastMessageComponent implements OnInit, AfterViewInit, OnDestroy {
30
33
  subscriptions: Subscription[] = []; /** */
31
34
  // ========= end:: sottoscrizioni ======= //
32
35
 
33
- isPopupUrl = isPopupUrl;
34
- popupUrl = popupUrl;
35
- strip_tags = strip_tags;
36
- isImage = isImage;
37
-
36
+ isEmojii = isEmojii;
37
+
38
38
  private logger: LoggerService = LoggerInstance.getInstance();
39
+ public fileSelected: any;
40
+ public message: MessageModel;
39
41
 
40
42
  constructor(
41
- private imageRepoService: ImageRepoService,
43
+ private events: EventsService,
42
44
  public g: Globals,
43
45
  // public conversationsService: ConversationsService
44
46
  ) { }
@@ -54,32 +56,52 @@ export class LastMessageComponent implements OnInit, AfterViewInit, OnDestroy {
54
56
  ngOnChanges(changes: SimpleChanges) {
55
57
  this.logger.debug('[LASTMESSAGE] onChanges', changes)
56
58
  if(this.conversation){
57
- this.conversation.image = this.imageRepoService.getImagePhotoUrl(this.conversation.sender)
59
+ this.message = conversationToMessage(this.conversation, this.g.senderId)
60
+ console.log('messsageeeeeeeee', this.message)
61
+ // if(isImage(this.conversation)){
62
+ // this.fileSelected = Object.assign({}, this.conversation.metadata)
63
+ // this.fileSelected = Object.assign(this.fileSelected, this.getMetadataSize(this.fileSelected))
64
+ // }
58
65
  }
59
66
  }
60
67
 
61
- /**
62
- *
63
- * @param message
64
- */
65
- getMetadataSize(metadata): any {
66
- if(metadata.width === undefined){
67
- metadata.width= MAX_WIDTH_IMAGES
68
- }
69
- if(metadata.height === undefined){
70
- metadata.height = MAX_WIDTH_IMAGES
71
- }
68
+
69
+
70
+ getMetadataSize(metadata): {width, height} {
71
+ const MAX_WIDTH_IMAGES_PREVIEW = 230
72
+ const MAX_HEIGHT_IMAGES_PREIEW = 150
73
+ // if(metadata.width === undefined){
74
+ // metadata.width= MAX_WIDTH_IMAGES_PREVIEW
75
+ // }
76
+ // if(metadata.height === undefined){
77
+ // metadata.height = MAX_HEIGHT_IMAGES_PREIEW
78
+ // }
72
79
  // const MAX_WIDTH_IMAGES = 300;
80
+
73
81
  const sizeImage = {
74
82
  width: metadata.width,
75
83
  height: metadata.height
76
84
  };
77
- // that.g.wdLog(['message::: ', metadata);
78
- if (metadata.width && metadata.width > (MAX_WIDTH_IMAGES)) {
79
- const rapporto = (metadata['width'] / metadata['height']);
80
- sizeImage.width = MAX_WIDTH_IMAGES;
81
- sizeImage.height = (MAX_WIDTH_IMAGES) / rapporto;
85
+
86
+
87
+ // SCALE IN WIDTH --> for horizontal images
88
+ if (metadata.width && metadata.width > MAX_WIDTH_IMAGES_PREVIEW) {
89
+ const ratio = (metadata['width'] / metadata['height']);
90
+ sizeImage.width = metadata.width = MAX_WIDTH_IMAGES_PREVIEW;
91
+ sizeImage.height = metadata.height = MAX_WIDTH_IMAGES_PREVIEW / ratio;
92
+ } else if(metadata.width && metadata.width <= 55){
93
+ const ratio = (metadata['width'] / metadata['height']);
94
+ sizeImage.width = MIN_WIDTH_IMAGES;
95
+ sizeImage.height = MIN_WIDTH_IMAGES / ratio;
82
96
  }
97
+
98
+ // SCALE IN HEIGHT --> for vertical images
99
+ if(metadata.height && metadata.height > MAX_HEIGHT_IMAGES_PREIEW){
100
+ const ratio = (MAX_HEIGHT_IMAGES_PREIEW / metadata['width']);
101
+ sizeImage.width = MAX_HEIGHT_IMAGES_PREIEW / ratio;
102
+ sizeImage.height = MAX_HEIGHT_IMAGES_PREIEW ;
103
+ }
104
+
83
105
  return sizeImage; // h.toString();
84
106
  }
85
107
 
@@ -90,6 +112,8 @@ export class LastMessageComponent implements OnInit, AfterViewInit, OnDestroy {
90
112
  onAttachmentButtonClicked(event: any){
91
113
  // this.onAttachmentButtonClicked.emit(event)
92
114
  this.logger.debug('[LASTMESSAGE] onAttachmentButtonClicked', event)
115
+ this.events.publish('lastMessage:attachmentButtonClicked', event)
116
+ this.openConversationByID(this.conversation);
93
117
  }
94
118
  /** */
95
119
  openConversationByID(conversation) {
@@ -149,7 +149,7 @@ export class ListAllConversationsComponent implements OnInit, OnDestroy, AfterVi
149
149
  }
150
150
 
151
151
  onConversationLoadedFN(conversation: ConversationModel){
152
- this.logger.debug('[LISTALLCONVERSATIONS] onImageLoadedFN', conversation)
152
+ this.logger.debug('[LISTALLCONVERSATIONS] onConversationLoadedFN', conversation)
153
153
  }
154
154
 
155
155
  // private openConversationByID(conversation) {
@@ -80,11 +80,6 @@
80
80
  </div>
81
81
 
82
82
  </div>
83
-
84
- <!-- icon status message -->
85
- <!-- <chat-return-receipt *ngIf="isSender"
86
- [status]="message.status">
87
- </chat-return-receipt> -->
88
83
 
89
84
 
90
85
 
@@ -1,4 +1,4 @@
1
- import { SafeHtmlPipe } from './../../../directives/safe-html.pipe';
1
+ import { SafeHtmlPipe } from './../../../pipe/safe-html.pipe';
2
2
  import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
3
3
 
4
4
  import { HtmlComponent } from './html.component';
@@ -2,7 +2,7 @@ import { CustomLogger } from './../../../../chat21-core/providers/logger/customL
2
2
  import { LoggerInstance } from './../../../../chat21-core/providers/logger/loggerInstance';
3
3
  import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
4
4
  import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
5
- import { MarkedPipe } from '../../../directives/marked.pipe';
5
+ import { MarkedPipe } from '../../../pipe/marked.pipe';
6
6
 
7
7
  import { InfoMessageComponent } from './info-message.component';
8
8
  import { NGXLogger } from 'ngx-logger';
@@ -25,4 +25,8 @@ p {
25
25
  font-variant: normal;
26
26
  font-weight: 300;
27
27
  overflow: hidden;
28
+ }
29
+
30
+ p ::ng-deep a {
31
+ word-break: break-all
28
32
  }
@@ -1,5 +1,5 @@
1
- import { HtmlEntitiesEncodePipe } from './../../../directives/html-entities-encode.pipe';
2
- import { MarkedPipe } from './../../../directives/marked.pipe';
1
+ import { HtmlEntitiesEncodePipe } from './../../../pipe/html-entities-encode.pipe';
2
+ import { MarkedPipe } from './../../../pipe/marked.pipe';
3
3
  import { async, ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
4
4
 
5
5
  import { TextComponent } from './text.component';
@@ -1,7 +1,7 @@
1
1
  <div id="buttons-in-message">
2
2
  <div class="buttons-wrapper">
3
3
 
4
- <span *ngFor="let button of buttons" class="div-button">
4
+ <span *ngFor="let button of buttons | slice:0:limit" class="div-button">
5
5
 
6
6
  <chat-text-button-attachment *ngIf="button.type === 'text' && isLastMessage === true" class="div-button"
7
7
  [button]="button"
@@ -14,6 +14,8 @@ export class MessageAttachmentComponent implements OnInit {
14
14
  @Input() message: MessageModel;
15
15
  @Input() isConversationArchived: boolean;
16
16
  @Input() isLastMessage: boolean;
17
+ @Input() fullscreenMode: boolean;
18
+ @Input() limit: number;
17
19
  @Input() stylesMap: Map<string, string>;
18
20
  @Output() onAttachmentButtonClicked = new EventEmitter<any>();
19
21
  @Output() onElementRendered = new EventEmitter<{element: string, status: boolean}>()
File without changes
File without changes
File without changes
@@ -0,0 +1,16 @@
1
+ import { TestBed } from '@angular/core/testing';
2
+
3
+ import { EventsService } from './events.service';
4
+
5
+ describe('EventsService', () => {
6
+ let service: EventsService;
7
+
8
+ beforeEach(() => {
9
+ TestBed.configureTestingModule({});
10
+ service = TestBed.inject(EventsService);
11
+ });
12
+
13
+ it('should be created', () => {
14
+ expect(service).toBeTruthy();
15
+ });
16
+ });
@@ -0,0 +1,76 @@
1
+ import { Injectable } from '@angular/core';
2
+ export type EventHandler = (...args: any[]) => any;
3
+ @Injectable({
4
+ providedIn: 'root'
5
+ })
6
+ export class EventsService {
7
+ private c = new Map<string, EventHandler[]>();
8
+ constructor() { }
9
+
10
+ /**
11
+ * Subscribe to an event topic. Events that get posted to that topic will trigger the provided handler.
12
+ *
13
+ * @param topic the topic to subscribe to
14
+ * @param handler the event handler
15
+ */
16
+ subscribe(topic: string, ...handlers: EventHandler[]) {
17
+ let topics = this.c.get(topic);
18
+ if (!topics) {
19
+ this.c.set(topic, topics = []);
20
+ }
21
+ topics.push(...handlers);
22
+ }
23
+
24
+ /**
25
+ * Unsubscribe from the given topic. Your handler will no longer receive events published to this topic.
26
+ *
27
+ * @param topic the topic to unsubscribe from
28
+ * @param handler the event handler
29
+ *
30
+ * @return true if a handler was removed
31
+ */
32
+ unsubscribe(topic: string, handler?: EventHandler): boolean {
33
+ if (!handler) {
34
+ return this.c.delete(topic);
35
+ }
36
+
37
+ const topics = this.c.get(topic);
38
+ if (!topics) {
39
+ return false;
40
+ }
41
+
42
+ // We need to find and remove a specific handler
43
+ const index = topics.indexOf(handler);
44
+
45
+ if (index < 0) {
46
+ // Wasn't found, wasn't removed
47
+ return false;
48
+ }
49
+ topics.splice(index, 1);
50
+ if (topics.length === 0) {
51
+ this.c.delete(topic);
52
+ }
53
+ return true;
54
+ }
55
+
56
+ /**
57
+ * Publish an event to the given topic.
58
+ *
59
+ * @param topic the topic to publish to
60
+ * @param eventData the data to send as the event
61
+ */
62
+ publish(topic: string, ...args: any[]): any[] | null {
63
+ const topics = this.c.get(topic);
64
+ if (!topics) {
65
+ return null;
66
+ }
67
+ return topics.map(handler => {
68
+ try {
69
+ return handler(...args);
70
+ } catch (e) {
71
+ console.error(e);
72
+ return null;
73
+ }
74
+ });
75
+ }
76
+ }
@@ -408,12 +408,17 @@ export class GlobalSettingsService {
408
408
  this.logger.error('[GLOBAL-SET] setVariablesFromService > Error is departments: ', error);
409
409
  }
410
410
 
411
- // DEPARTMENTS
412
- // if (response && response.departments !== null) {
413
- // this.logger.debug('[GLOBAL-SET] response DEP ::::', response.departments);
414
- // // globals.setParameter('departments', response.departments);
415
- // this.initDepartments(response.departments);
416
- // }
411
+ // BOTS_RULES
412
+ try{
413
+ const botsRules = response.botsRules
414
+ if (typeof botsRules !== 'undefined') {
415
+ this.logger.debug('[GLOBAL-SET] setVariablesFromService > botsRules ::::', botsRules);
416
+ this.globals.botsRules = botsRules
417
+ }
418
+ }catch(error){
419
+ this.logger.error('[GLOBAL-SET] setVariablesFromService > Error is botsRules: ', error);
420
+ }
421
+
417
422
 
418
423
  // AVAILABLE AGENTS
419
424
  try {
@@ -427,12 +432,6 @@ export class GlobalSettingsService {
427
432
  this.logger.error('[GLOBAL-SET] setVariablesFromService > Error is departments: ', error);
428
433
  }
429
434
 
430
- // AVAILABLE AGENTS
431
- // if (response && response.user_available !== null) {
432
- // //this.logger.error('[GLOBAL-SET] setVariablesFromService > user_available ::::', response.user_available);
433
- // this.setAvailableAgentsStatus(response.user_available);
434
- // }
435
-
436
435
  // WIDGET
437
436
  try {
438
437
  const variables = response.project.widget;
@@ -14,6 +14,7 @@ import { DepartmentModel } from 'src/models/department';
14
14
  import { avatarPlaceholder, detectIfIsMobile, getParameterByName, setColorFromString } from 'src/app/utils/utils';
15
15
  import { ConversationModel } from 'src/chat21-core/models/conversation';
16
16
  import { convertColorToRGBA } from 'src/chat21-core/utils/utils';
17
+ import { Rule } from 'src/models/rule';
17
18
 
18
19
  @Injectable({
19
20
  providedIn: 'root'
@@ -24,7 +25,7 @@ export class Globals {
24
25
  obsIsOpen = new BehaviorSubject<boolean>(null);
25
26
 
26
27
  BASE_LOCATION = 'https://widget.tiledesk.com/v2';
27
- POWERED_BY ='<a tabindex="-1" target="_blank" href="http://www.tiledesk.com/"><img src="https://support-pre.tiledesk.com/dashboard/assets/img/logos/tiledesk-logo_new_gray.svg"/></a>'
28
+ POWERED_BY ='<a tabindex="-1" target="_blank" href="http://www.tiledesk.com/?utm_source=widget"><img src="https://support-pre.tiledesk.com/dashboard/assets/img/logos/tiledesk-logo_new_gray.svg"/></a>'
28
29
  DEFAULT_LOGO_CHAT = '/assets/images/tiledesk_logo_white_small.svg';
29
30
  WIDGET_TITLE = 'Tiledesk';
30
31
 
@@ -64,6 +65,8 @@ export class Globals {
64
65
  isOpenMenuOptions: boolean;
65
66
  isOpenPrechatForm: boolean;
66
67
 
68
+ botsRules: Rule[];
69
+
67
70
  // areAgentsAvailable = false;
68
71
  areAgentsAvailableText: string;
69
72
  availableAgentsStatus = false; // indica quando è impostato lo stato degli agenti nel subscribe
@@ -1,13 +1,96 @@
1
+ import { AppStorageService } from 'src/chat21-core/providers/abstract/app-storage.service';
2
+ import { Globals } from './globals';
3
+ import { UserModel } from './../../chat21-core/models/user';
1
4
  import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
2
5
  import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
3
- export class Rules {
6
+ import { TiledeskAuthService } from 'src/chat21-core/providers/tiledesk/tiledesk-auth.service';
7
+ import { TiledeskRequestsService } from 'src/chat21-core/providers/tiledesk/tiledesk-requests.service';
8
+ import { Inject, Injectable } from '@angular/core';
9
+ import { IRules, Rule } from 'src/models/rule';
10
+ import { getDateDifference } from 'src/chat21-core/utils/utils';
11
+
4
12
 
5
- private url = window.location
13
+ @Injectable({
14
+ providedIn: 'root'
15
+ })
16
+ export class Rules {
6
17
 
18
+ private windowContext:Window = window
19
+ private tiledeskToken: string;
20
+ private currentUser: UserModel;
21
+ private request_id: string;
22
+ private rules: Rule[]
7
23
  private logger: LoggerService = LoggerInstance.getInstance()
8
- constructor(){}
24
+ constructor(
25
+ private tiledeskRequestsService: TiledeskRequestsService,
26
+ private appStorageService: AppStorageService,
27
+ private g: Globals
28
+ ){}
29
+
30
+
31
+ initRules(context: Window, tiledeskToken: string, currentUser: UserModel, request_id: string, rules:Rule[]){
32
+ this.logger.info('[RULES] initRules',context, currentUser, rules)
33
+ this.windowContext = context
34
+ this.tiledeskToken = tiledeskToken
35
+ this.currentUser = currentUser
36
+ this.request_id = request_id
37
+ this.rules = rules
38
+ this.checkRules()
39
+ }
40
+
41
+ checkRules(){
42
+ this.rules.forEach((rule, index)=>{
43
+ if(rule.when && new RegExp(rule.when.urlMatches).test(this.windowContext.location.href)){
44
+ if(this.checkIfAlreadyDone(rule)){
45
+ this.doAction(rule.do)
46
+ return;
47
+ }
48
+
49
+ }
50
+ })
51
+ }
9
52
 
10
- initRules(){
11
- console.log('locationnnnnnn', this.url)
53
+ private doAction(action: Rule['do']){
54
+ this.logger.info('[RULES] doAction', this.currentUser, action)
55
+ let message = action.filter(obj => Object.keys(obj).includes('message'))
56
+ let wait = action.filter(obj => Object.keys(obj).includes('wait'))
57
+ if(message && message.length>0){
58
+ message[0]['message'].attributes = { ...this.g.attributes, ...message[0]['message'].attributes}
59
+ message[0]['message'].userAgent = this.g.attributes['client']
60
+ message[0]['message'].request_id = this.request_id
61
+ message[0]['message'].sourcePage = this.g.attributes['sourcePage']
62
+ message[0]['message'].language = this.g.lang
63
+ message[0]['message'].departmentid = this.g.attributes.departmentId
64
+ console.log('message[0]', message[0]['message'])
65
+ setTimeout(() => {
66
+ this.tiledeskRequestsService.sendMessageToRequest(this.request_id, this.tiledeskToken, message[0]['message'])
67
+ console.log('rulessss', this.appStorageService.getItem('_botsRules'))
68
+ }, wait[0]['wait']);
69
+ }
12
70
  }
71
+
72
+
73
+ private checkIfAlreadyDone(rule: Rule): boolean{
74
+ let storedRules = JSON.parse(this.appStorageService.getItem('_rules')) || {}
75
+ let canHandleAction: boolean = false
76
+ if(storedRules && storedRules.hasOwnProperty(rule.uid)){
77
+ let timeDifference = getDateDifference(storedRules[rule.uid], Date.now())
78
+ if(timeDifference.hours > rule.when.triggerEvery){
79
+ storedRules[rule.uid]= Date.now()
80
+ canHandleAction = true
81
+ }else{
82
+ canHandleAction = false
83
+ }
84
+ }else{
85
+ canHandleAction = true
86
+ storedRules[rule.uid]= Date.now()
87
+
88
+ }
89
+ this.appStorageService.setItem('_rules', JSON.stringify(storedRules))
90
+ return canHandleAction
91
+ }
92
+
93
+
94
+
95
+
13
96
  }
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  Chat21Client
3
3
 
4
- v0.1.12.3
4
+ v0.1.12.4
5
5
 
6
6
  @Author Andrea Sponziello
7
7
  (c) Tiledesk 2020
@@ -966,7 +966,7 @@ class Chat21Client {
966
966
  if (this.client) {
967
967
  this.client.end()
968
968
  }
969
- const presence_topic = 'apps/tilechat/users/' + this.user_id + '/presence/' + this.client_id
969
+ this.presence_topic = 'apps/tilechat/users/' + this.user_id + '/presence/' + this.client_id
970
970
  let options = {
971
971
  keepalive: 10,
972
972
  // protocolId: 'MQTT',
@@ -975,7 +975,7 @@ class Chat21Client {
975
975
  reconnectPeriod: 1000,
976
976
  // connectTimeout: 30 * 1000,
977
977
  will: {
978
- topic: presence_topic,
978
+ topic: this.presence_topic,
979
979
  payload: '{"disconnected":true}',
980
980
  qos: 1,
981
981
  retain: true
@@ -985,7 +985,7 @@ class Chat21Client {
985
985
  password: jwt,
986
986
  rejectUnauthorized: false
987
987
  }
988
- if (this.log) {console.log("starting mqtt connection with LWT on:", presence_topic, this.endpoint)}
988
+ if (this.log) {console.log("starting mqtt connection with LWT on:", this.presence_topic, this.endpoint)}
989
989
  // client = mqtt.connect('mqtt://127.0.0.1:15675/ws',options)
990
990
  this.client = mqtt.connect(this.endpoint,options)
991
991
 
@@ -999,6 +999,15 @@ class Chat21Client {
999
999
  callback();
1000
1000
  });
1001
1001
  }
1002
+ this.client.publish(
1003
+ this.presence_topic,
1004
+ JSON.stringify({connected: true}),
1005
+ null, (err) => {
1006
+ if (err) {
1007
+ console.error("Error con presence publish:", err);
1008
+ }
1009
+ }
1010
+ );
1002
1011
  }
1003
1012
  );
1004
1013
  this.client.on('reconnect',
@@ -1023,6 +1032,20 @@ class Chat21Client {
1023
1032
  );
1024
1033
  }
1025
1034
 
1035
+ ImHere() {
1036
+ if (this.client) {
1037
+ this.client.publish(
1038
+ this.presence_topic,
1039
+ JSON.stringify({connected: true}),
1040
+ null, (err) => {
1041
+ if (err) {
1042
+ console.error("Error on presence publish:", err);
1043
+ }
1044
+ }
1045
+ );
1046
+ }
1047
+ }
1048
+
1026
1049
  close(callback) {
1027
1050
  if (this.topic_inbox) {
1028
1051
  this.client.unsubscribe(this.topic_inbox, (err) => {
@@ -298,11 +298,6 @@
298
298
  setTimeout(() => {
299
299
  document.getElementById("preloader").style.display = "none";
300
300
  if(event_data && event_data.detail && event_data.detail.appConfigs){
301
-
302
- var enbedJs = event_data.detail.appConfigs.enbedJs? event_data.detail.appConfigs.enbedJs : false;
303
- document.getElementById("enbed").style.display = enbedJs? "inline-block": "none";
304
- document.getElementById("base_url").innerHTML = enbedJs ? baseUrl + '/launch.js': null;
305
-
306
301
  baseUrlConsole = event_data.detail.appConfigs.dashboardUrl? event_data.detail.appConfigs.dashboardUrl : baseUrlConsole;
307
302
  }
308
303
  }, 1000);
@@ -20,6 +20,6 @@ export class ConversationModel {
20
20
  public color: string,
21
21
  public avatar: string,
22
22
  public archived: boolean,
23
- public type: string,
23
+ public type: string
24
24
  ) { }
25
- }
25
+ }
@@ -5,6 +5,7 @@ export class UploadModel {
5
5
  url: string;
6
6
  progress: number;
7
7
  createdAt: Date = new Date();
8
+
8
9
  constructor(file: File) {
9
10
  this.file = file;
10
11
  }
@@ -31,5 +31,6 @@ export abstract class PresenceService {
31
31
  abstract userIsOnline(userid: string): Observable<any>
32
32
  abstract lastOnlineForUser(userid: string): void;
33
33
  abstract setPresence(userid: string): void;
34
+ abstract imHere():void;
34
35
  abstract removePresence(): void;
35
36
  }