@chat21/chat21-ionic 3.0.94 → 3.0.96-rc.1

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 (56) hide show
  1. package/.github/workflows/docker-community-push-latest.yml +1 -1
  2. package/.github/workflows/docker-image-tag-community-tag-push.yml +1 -1
  3. package/CHANGELOG.md +14 -0
  4. package/package.json +1 -1
  5. package/src/app/app.module.ts +4 -3
  6. package/src/app/chatlib/conversation-detail/conversation-content/conversation-content.component.ts +18 -15
  7. package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.html +2 -2
  8. package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.scss +0 -7
  9. package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.ts +0 -1
  10. package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.html +1 -1
  11. package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.scss +0 -15
  12. package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.ts +11 -2
  13. package/src/app/chatlib/conversation-detail/message/text/text.component.scss +8 -3
  14. package/src/app/chatlib/list-conversations-component/list-conversations/list-conversations.component.html +1 -2
  15. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.html +5 -0
  16. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.scss +7 -0
  17. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.ts +1 -1
  18. package/src/app/components/navbar/navbar.component.ts +1 -1
  19. package/src/app/pages/conversation-detail/conversation-detail.page.ts +39 -25
  20. package/src/app/services/websocket/websocket.service.ts +3 -3
  21. package/src/assets/i18n/ar.json +1 -0
  22. package/src/assets/i18n/az.json +1 -0
  23. package/src/assets/i18n/de.json +1 -0
  24. package/src/assets/i18n/en.json +1 -0
  25. package/src/assets/i18n/es.json +1 -0
  26. package/src/assets/i18n/fr.json +1 -0
  27. package/src/assets/i18n/it.json +1 -0
  28. package/src/assets/i18n/kk.json +1 -0
  29. package/src/assets/i18n/pt.json +1 -0
  30. package/src/assets/i18n/ru.json +1 -0
  31. package/src/assets/i18n/sr.json +1 -0
  32. package/src/assets/i18n/sv.json +1 -0
  33. package/src/assets/i18n/tr.json +1 -0
  34. package/src/assets/i18n/uk.json +1 -0
  35. package/src/assets/i18n/uz.json +1 -0
  36. package/src/chat21-core/providers/abstract/archivedconversations-handler.service.ts +5 -5
  37. package/src/chat21-core/providers/abstract/conversation-handler.service.ts +6 -6
  38. package/src/chat21-core/providers/abstract/conversations-handler.service.ts +6 -7
  39. package/src/chat21-core/providers/abstract/groups-handler.service.ts +5 -5
  40. package/src/chat21-core/providers/abstract/messagingAuth.service.ts +2 -2
  41. package/src/chat21-core/providers/abstract/presence.service.ts +3 -2
  42. package/src/chat21-core/providers/abstract/typing.service.ts +2 -2
  43. package/src/chat21-core/providers/abstract/upload.service.ts +1 -1
  44. package/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts +2 -13
  45. package/src/chat21-core/providers/firebase/firebase-auth-service.ts +1 -1
  46. package/src/chat21-core/providers/firebase/firebase-conversations-handler.ts +1 -11
  47. package/src/chat21-core/providers/firebase/firebase-presence.service.ts +4 -3
  48. package/src/chat21-core/providers/mqtt/mqtt-archivedconversations-handler.ts +1 -34
  49. package/src/chat21-core/providers/mqtt/mqtt-auth-service.ts +0 -6
  50. package/src/chat21-core/providers/mqtt/mqtt-conversation-handler.ts +0 -1
  51. package/src/chat21-core/providers/mqtt/mqtt-conversations-handler.ts +2 -12
  52. package/src/chat21-core/providers/mqtt/mqtt-presence.service.ts +25 -19
  53. package/src/chat21-core/providers/mqtt/mqtt-typing.service.ts +0 -2
  54. package/src/chat21-core/providers/native/native-upload-service.ts +1 -0
  55. package/src/chat21-core/utils/utils-message.ts +69 -16
  56. package/src/chat21-core/utils/utils.ts +97 -97
@@ -7,14 +7,14 @@ import { ImageRepoService } from './image-repo.service';
7
7
  export abstract class ArchivedConversationsHandlerService {
8
8
 
9
9
  // BehaviorSubject
10
- abstract BSConversationDetail: BehaviorSubject<ConversationModel> = new BehaviorSubject<ConversationModel>(null);
11
- abstract archivedConversationAdded: BehaviorSubject<ConversationModel> = new BehaviorSubject<ConversationModel>(null);
12
- abstract archivedConversationChanged: BehaviorSubject<ConversationModel> = new BehaviorSubject<ConversationModel>(null);
13
- abstract archivedConversationRemoved: BehaviorSubject<ConversationModel> = new BehaviorSubject<ConversationModel>(null);
10
+ abstract BSConversationDetail: BehaviorSubject<ConversationModel>;
11
+ abstract archivedConversationAdded: BehaviorSubject<ConversationModel>;
12
+ abstract archivedConversationChanged: BehaviorSubject<ConversationModel>;
13
+ abstract archivedConversationRemoved: BehaviorSubject<ConversationModel>;
14
14
  // abstract readAllMessages: BehaviorSubject<string> = new BehaviorSubject<string>(null);
15
15
 
16
16
  // params
17
- abstract archivedConversations: Array<ConversationModel> = [];
17
+ abstract archivedConversations: Array<ConversationModel>;
18
18
  abstract uidConvSelected: string;
19
19
  //abstract imageRepo: ImageRepoService;
20
20
 
@@ -12,15 +12,15 @@ import { UserModel } from '../../models/user';
12
12
  export abstract class ConversationHandlerService {
13
13
 
14
14
  // BehaviorSubject
15
- abstract messageAdded: BehaviorSubject<MessageModel> = new BehaviorSubject<MessageModel>(null);
16
- abstract messageChanged: BehaviorSubject<MessageModel> = new BehaviorSubject<MessageModel>(null);
17
- abstract messageRemoved: BehaviorSubject<string> = new BehaviorSubject<string>(null);
18
- abstract messageWait: BehaviorSubject<any> = new BehaviorSubject<any>(null);
19
- abstract messageInfo: BehaviorSubject<MessageModel> = new BehaviorSubject<MessageModel>(null);
15
+ abstract messageAdded: BehaviorSubject<MessageModel>;
16
+ abstract messageChanged: BehaviorSubject<MessageModel>;
17
+ abstract messageRemoved: BehaviorSubject<string>;
18
+ abstract messageWait: BehaviorSubject<any>;
19
+ abstract messageInfo: BehaviorSubject<MessageModel>;
20
20
 
21
21
  // params
22
22
  abstract attributes: any;
23
- abstract messages: Array<MessageModel> = [];
23
+ abstract messages: Array<MessageModel>;
24
24
  abstract conversationWith: string;
25
25
 
26
26
  constructor() {}
@@ -14,20 +14,19 @@ import { ConversationModel } from './../../models/conversation';
14
14
  export abstract class ConversationsHandlerService {
15
15
 
16
16
  // BehaviorSubject
17
- abstract BSConversationDetail: BehaviorSubject<ConversationModel> = new BehaviorSubject<ConversationModel>(null);
18
- abstract conversationAdded: BehaviorSubject<ConversationModel> = new BehaviorSubject<ConversationModel>(null);
19
- abstract conversationChanged: BehaviorSubject<ConversationModel> = new BehaviorSubject<ConversationModel>(null);
20
- abstract conversationChangedDetailed: BehaviorSubject<{value: ConversationModel, previousValue: ConversationModel}> = new BehaviorSubject<{value: ConversationModel, previousValue: ConversationModel}>(null);
21
- abstract conversationRemoved: BehaviorSubject<ConversationModel> = new BehaviorSubject<ConversationModel>(null);
17
+ abstract BSConversationDetail: BehaviorSubject<ConversationModel>;
18
+ abstract conversationAdded: BehaviorSubject<ConversationModel>;
19
+ abstract conversationChanged: BehaviorSubject<ConversationModel>;
20
+ abstract conversationChangedDetailed: BehaviorSubject<{value: ConversationModel, previousValue: ConversationModel}>;
21
+ abstract conversationRemoved: BehaviorSubject<ConversationModel>;
22
22
  // abstract readAllMessages: BehaviorSubject<string> = new BehaviorSubject<string>(null);
23
23
 
24
24
  // params
25
- abstract conversations: Array<ConversationModel> = [];
25
+ abstract conversations: Array<ConversationModel>;
26
26
  abstract uidConvSelected: string;
27
27
 
28
28
  // functions
29
29
  abstract initialize(tenant: string, userId: string, translationMap: Map<string, string>): void;
30
- // abstract connect(): void;
31
30
  abstract subscribeToConversations(lastConversatioTimestamp: number, callback: any): void;
32
31
  abstract countIsNew(): number;
33
32
  abstract setConversationRead(conversationId: string): void;
@@ -11,11 +11,11 @@ import { UserModel } from 'src/chat21-core/models/user';
11
11
  export abstract class GroupsHandlerService {
12
12
 
13
13
  // BehaviorSubject
14
- abstract BSgroupDetail: BehaviorSubject<GroupModel> = new BehaviorSubject<GroupModel>(null);
15
- abstract SgroupDetail: Subject<GroupModel> = new Subject<GroupModel>();
16
- abstract groupAdded: BehaviorSubject<GroupModel> = new BehaviorSubject<GroupModel>(null);
17
- abstract groupChanged: BehaviorSubject<GroupModel> = new BehaviorSubject<GroupModel>(null);
18
- abstract groupRemoved: BehaviorSubject<GroupModel> = new BehaviorSubject<GroupModel>(null);
14
+ abstract BSgroupDetail: BehaviorSubject<GroupModel>;
15
+ abstract SgroupDetail: Subject<GroupModel>;
16
+ abstract groupAdded: BehaviorSubject<GroupModel>;
17
+ abstract groupChanged: BehaviorSubject<GroupModel>;
18
+ abstract groupRemoved: BehaviorSubject<GroupModel>;
19
19
 
20
20
  abstract initialize(tenant: string, loggedUserId: string): void;
21
21
  abstract connect(): void;
@@ -12,8 +12,8 @@ import { UserModel } from '../../models/user';
12
12
  export abstract class MessagingAuthService {
13
13
 
14
14
  // BehaviorSubject
15
- abstract BSAuthStateChanged: BehaviorSubject<any> = new BehaviorSubject<any>(null);
16
- abstract BSSignOut: BehaviorSubject<any> = new BehaviorSubject<any>(null);
15
+ abstract BSAuthStateChanged: BehaviorSubject<any>;
16
+ abstract BSSignOut: BehaviorSubject<any>;
17
17
 
18
18
  // params
19
19
  public DEFAULT_PERSISTENCE: string = 'NONE';
@@ -9,8 +9,8 @@ import { environment } from 'src/environments/environment';
9
9
  export abstract class PresenceService {
10
10
 
11
11
  // BehaviorSubject
12
- abstract BSIsOnline: BehaviorSubject<any> = new BehaviorSubject<any>(null);
13
- abstract BSLastOnline: BehaviorSubject<any> = new BehaviorSubject<any>(null);
12
+ abstract BSIsOnline: BehaviorSubject<any>;
13
+ abstract BSLastOnline: BehaviorSubject<any>;
14
14
 
15
15
  // params
16
16
  // abstract tenant = environment.tenant;
@@ -30,5 +30,6 @@ export abstract class PresenceService {
30
30
  abstract userIsOnline(userid: string): Observable<any>
31
31
  abstract lastOnlineForUser(userid: string): void;
32
32
  abstract setPresence(userid: string): void;
33
+ abstract imHere():void;
33
34
  abstract removePresence(): void;
34
35
  }
@@ -9,8 +9,8 @@ import { environment } from 'src/environments/environment';
9
9
  export abstract class TypingService {
10
10
 
11
11
  // BehaviorSubject
12
- BSIsTyping: BehaviorSubject<any> = new BehaviorSubject<any>(null);
13
- BSSetTyping: BehaviorSubject<any> = new BehaviorSubject<any>(null);
12
+ abstract BSIsTyping: BehaviorSubject<any>;
13
+ abstract BSSetTyping: BehaviorSubject<any>;
14
14
 
15
15
  // params
16
16
  // private _tenant: string;
@@ -28,7 +28,7 @@ export abstract class UploadService {
28
28
  }
29
29
 
30
30
  //BehaviorSubject
31
- abstract BSStateUpload: BehaviorSubject<any> = new BehaviorSubject<any>(null);
31
+ abstract BSStateUpload: BehaviorSubject<any>;
32
32
 
33
33
  // params
34
34
  // abstract tenant = environment.tenant;
@@ -14,7 +14,7 @@ import { ConversationModel } from '../../models/conversation';
14
14
 
15
15
  // utils
16
16
  import { avatarPlaceholder, getColorBck } from '../../utils/utils-user';
17
- import { compareValues, getFromNow, searchIndexInArrayForUid, archivedConversationsPathForUserId, isGroup } from '../../utils/utils';
17
+ import { compareValues, searchIndexInArrayForUid, archivedConversationsPathForUserId, isGroup, getTimeLastMessage } from '../../utils/utils';
18
18
  import { ArchivedConversationsHandlerService } from '../abstract/archivedconversations-handler.service';
19
19
  import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
20
20
  import { LoggerInstance } from '../logger/loggerInstance';
@@ -396,7 +396,7 @@ export class FirebaseArchivedConversationsHandler extends ArchivedConversationsH
396
396
  conv.conversation_with = conversation_with;
397
397
  conv.conversation_with_fullname = conversation_with_fullname;
398
398
  conv.status = this.setStatusConversation(conv.sender, conv.uid);
399
- // conv.time_last_message = this.getTimeLastMessage(conv.timestamp); // evaluate if is used
399
+ conv.time_last_message = getTimeLastMessage(conv.timestamp); // evaluate if is used
400
400
  conv.avatar = avatarPlaceholder(conversation_with_fullname);
401
401
  conv.color = getColorBck(conversation_with_fullname);
402
402
  conv.archived = true;
@@ -415,17 +415,6 @@ export class FirebaseArchivedConversationsHandler extends ArchivedConversationsH
415
415
  return status;
416
416
  }
417
417
 
418
- /**
419
- * calcolo il tempo trascorso da ora al timestamp passato
420
- * @param timestamp
421
- */
422
- private getTimeLastMessage(timestamp: string) {
423
- const timestampNumber = parseInt(timestamp, 10) / 1000;
424
- const time = getFromNow(timestampNumber);
425
- return time;
426
- }
427
-
428
-
429
418
  /**
430
419
  * check if the conversations is valid or not
431
420
  */
@@ -74,7 +74,7 @@ export class FirebaseAuthService extends MessagingAuthService {
74
74
  this.URL_TILEDESK_CREATE_CUSTOM_TOKEN = this.SERVER_BASE_URL + 'chat21/firebase/auth/createCustomToken';
75
75
  this.logger.log('[FIREBASEAuthSERVICE] - initialize URL_TILEDESK_CREATE_CUSTOM_TOKEN ', this.URL_TILEDESK_CREATE_CUSTOM_TOKEN)
76
76
 
77
-
77
+
78
78
  let firebasePersistence;
79
79
  // console.log('FB-AUTH firebasePersistence', this.getPersistence())
80
80
  switch (this.getPersistence()) {
@@ -21,7 +21,7 @@ import { AppConfigProvider } from 'src/app/services/app-config';
21
21
 
22
22
  // utils
23
23
  import { avatarPlaceholder, getColorBck } from '../../utils/utils-user';
24
- import { compareValues, getFromNow, conversationsPathForUserId, searchIndexInArrayForUid, isGroup } from '../../utils/utils';
24
+ import { compareValues, conversationsPathForUserId, searchIndexInArrayForUid, isGroup } from '../../utils/utils';
25
25
  import { TOUCHING_OPERATOR } from '../../utils/constants';
26
26
  import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
27
27
 
@@ -650,16 +650,6 @@ export class FirebaseConversationsHandler extends ConversationsHandlerService {
650
650
  return status;
651
651
  }
652
652
 
653
- /**
654
- * calcolo il tempo trascorso da ora al timestamp passato
655
- * @param timestamp
656
- */
657
- private getTimeLastMessage(timestamp: string) {
658
- const timestampNumber = parseInt(timestamp, 10) / 1000;
659
- const time = getFromNow(timestampNumber);
660
- return time;
661
- }
662
-
663
653
  /**
664
654
  * check if the conversations is valid or not
665
655
  */
@@ -14,9 +14,6 @@ import { PresenceService } from '../abstract/presence.service';
14
14
  import { CustomLogger } from '../logger/customLogger';
15
15
  import { LoggerInstance } from '../logger/loggerInstance';
16
16
 
17
- // utils
18
- // import { setLastDate } from '../../utils/utils';
19
- // import { environment } from '../../../environments/environment';
20
17
 
21
18
  // @Injectable({providedIn: 'root'})
22
19
  @Injectable()
@@ -149,6 +146,10 @@ export class FirebasePresenceService extends PresenceService {
149
146
  });
150
147
  }
151
148
 
149
+ public imHere(){
150
+ //NOT IMPLEMENTED FOR FIREBASE ENGINE
151
+ }
152
+
152
153
  /**
153
154
  * removePresence
154
155
  * richiamato prima del logout
@@ -13,7 +13,7 @@ import { ConversationsHandlerService } from '../abstract/conversations-handler.s
13
13
  // utils
14
14
  import { TYPE_GROUP } from '../../utils/constants';
15
15
  import { getImageUrlThumbFromFirebasestorage, avatarPlaceholder, getColorBck } from '../../utils/utils-user';
16
- import { compareValues, getFromNow, conversationsPathForUserId, searchIndexInArrayForUid } from '../../utils/utils';
16
+ import { compareValues, conversationsPathForUserId, searchIndexInArrayForUid } from '../../utils/utils';
17
17
  import { ArchivedConversationsHandlerService } from '../abstract/archivedconversations-handler.service';
18
18
  import { LoggerService } from '../abstract/logger.service';
19
19
  import { LoggerInstance } from '../logger/loggerInstance';
@@ -370,39 +370,6 @@ export class MQTTArchivedConversationsHandler extends ArchivedConversationsHandl
370
370
  return status;
371
371
  }
372
372
 
373
- /**
374
- * calcolo il tempo trascorso da ora al timestamp passato
375
- * @param timestamp
376
- */
377
- private getTimeLastMessage(timestamp: string) {
378
- const timestampNumber = parseInt(timestamp) / 1000;
379
- const time = getFromNow(timestampNumber);
380
- return time;
381
- }
382
-
383
- // removeByUid(uid) {
384
- // const index = searchIndexInArrayForUid(this.conversations, uid);
385
- // if (index > -1) {
386
- // this.conversations.splice(index, 1);
387
- // // this.events.publish('conversationsChanged', this.conversations);
388
- // this.conversationsChanged.next(this.conversations);
389
- // }
390
- // }
391
-
392
- // addConversationListener(uidUser, conversationId) {
393
- // var that = this;
394
- // this.tenant = environment.tenant;
395
- // // const tenant = this.chatManager.getTenant();
396
- // const url = '/apps/' + this.tenant + '/users/' + uidUser + '/conversations/' + conversationId;
397
- // const reference = firebase.database().ref(url);
398
- // console.log("ChatConversationsHandler::addConversationListener::reference:",url, reference.toString());
399
- // reference.on('value', function (snapshot) {
400
- // setTimeout(function () {
401
- // // that.events.publish(conversationId + '-listener', snapshot);
402
- // }, 100);
403
- // });
404
- // }
405
-
406
373
  /**
407
374
  * restituisce il numero di conversazioni nuove
408
375
  */
@@ -6,12 +6,6 @@ import { environment } from '../../../environments/environment';
6
6
  import { LoggerService } from '../abstract/logger.service';
7
7
  import { LoggerInstance } from '../logger/loggerInstance';
8
8
 
9
- // // firebase
10
- // import * as firebase from 'firebase/app';
11
- // import 'firebase/messaging';
12
- // import 'firebase/database';
13
- // import 'firebase/auth';
14
-
15
9
  // services
16
10
  // import { EventsService } from '../events-service';
17
11
  import { MessagingAuthService } from '../abstract/messagingAuth.service';
@@ -21,7 +21,6 @@ import {
21
21
  htmlEntities,
22
22
  compareValues,
23
23
  searchIndexInArrayForUid,
24
- setHeaderDate,
25
24
  conversationMessagesRef
26
25
  } from '../../utils/utils';
27
26
  import { isSender, messageType } from '../../utils/utils-message';
@@ -13,7 +13,7 @@ import { ConversationsHandlerService } from '../abstract/conversations-handler.s
13
13
 
14
14
  // utils
15
15
  import { getImageUrlThumbFromFirebasestorage, avatarPlaceholder, getColorBck } from '../../utils/utils-user';
16
- import { compareValues, getFromNow, conversationsPathForUserId, searchIndexInArrayForUid } from '../../utils/utils';
16
+ import { compareValues, conversationsPathForUserId, searchIndexInArrayForUid } from '../../utils/utils';
17
17
  import { LoggerService } from '../abstract/logger.service';
18
18
  import { LoggerInstance } from '../logger/loggerInstance';
19
19
  import { THIS_EXPR } from '@angular/compiler/src/output/output_ast';
@@ -383,7 +383,7 @@ export class MQTTConversationsHandler extends ConversationsHandlerService {
383
383
  conv.conversation_with_fullname = conversation_with_fullname;
384
384
  conv.conversation_with = conversation_with;
385
385
  conv.status = this.setStatusConversation(conv.sender, conv.uid);
386
- conv.time_last_message = this.getTimeLastMessage(conv.timestamp);
386
+ // conv.time_last_message = this.getTimeLastMessage(conv.timestamp);
387
387
  conv.avatar = avatarPlaceholder(conversation_with_fullname);
388
388
  conv.color = getColorBck(conversation_with_fullname);
389
389
  if (!conv.last_message_text) {
@@ -417,16 +417,6 @@ export class MQTTConversationsHandler extends ConversationsHandlerService {
417
417
  return status;
418
418
  }
419
419
 
420
- /**
421
- * calcolo il tempo trascorso da ora al timestamp passato
422
- * @param timestamp
423
- */
424
- private getTimeLastMessage(timestamp: string) {
425
- const timestampNumber = parseInt(timestamp) / 1000;
426
- const time = getFromNow(timestampNumber);
427
- return time;
428
- }
429
-
430
420
  /**
431
421
  * restituisce il numero di conversazioni nuove
432
422
  */
@@ -1,4 +1,4 @@
1
- import { Injectable } from '@angular/core';
1
+ import { Inject, Injectable, Optional } from '@angular/core';
2
2
  import { BehaviorSubject, Observable } from 'rxjs';
3
3
 
4
4
  // firebase
@@ -11,10 +11,8 @@ import 'firebase/database';
11
11
  import { PresenceService } from '../abstract/presence.service';
12
12
  import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
13
13
  import { LoggerInstance } from '../logger/loggerInstance';
14
+ import { Chat21Service } from './chat-service';
14
15
 
15
- // utils
16
- import { setLastDate } from '../../utils/utils';
17
- import { environment } from '../../../environments/environment';
18
16
 
19
17
  @Injectable({
20
18
  providedIn: 'root'
@@ -30,7 +28,8 @@ export class MQTTPresenceService extends PresenceService {
30
28
  private urlNodePresence: string;
31
29
  private logger: LoggerService = LoggerInstance.getInstance();
32
30
  constructor(
33
- // private events: EventsService
31
+ public chat21Service: Chat21Service,
32
+ @Optional() @Inject('webSocketService') public webSocketService?: any,
34
33
  ) {
35
34
  super();
36
35
  }
@@ -43,20 +42,20 @@ export class MQTTPresenceService extends PresenceService {
43
42
  }
44
43
 
45
44
  userIsOnline(userid: string): Observable<any> {
46
- // console.log('userIsOnline', userid);
47
- // const that = this;
48
- // const urlNodeConnections = this.urlNodePresence + userid + '/connections';
49
- // console.log('userIsOnline: ', urlNodeConnections);
50
- // const connectionsRef = firebase.database().ref().child(urlNodeConnections);
51
- // connectionsRef.on('value', (child) => {
52
- // console.log('is-online-' + userid);
53
- // if (child.val()) {
54
- // that.events.publish('is-online-' + userid, userid, true);
55
- // } else {
56
- // that.events.publish('is-online-' + userid, userid, false);
57
- // }
58
- // });
59
- return this.BSIsOnline
45
+ const that = this;
46
+ let local_BSIsOnline = new BehaviorSubject<any>(null);
47
+ this.webSocketService.wsRequesterStatus$.subscribe((data: any) => {
48
+ this.logger.log('[NATIVEPresenceSERVICE] $subs to wsService - data ', data, userid);
49
+ if (data && data.presence && data.presence.status === 'online' ) {
50
+ that.BSIsOnline.next({ uid: data.uuid_user, isOnline: true });
51
+ local_BSIsOnline.next({ uid: data.uuid_user, isOnline: true });
52
+ } else {
53
+ that.BSIsOnline.next({ uid: data.uuid_user, isOnline: false });
54
+ local_BSIsOnline.next({ uid: data.uuid_user, isOnline: false });
55
+ }
56
+ });
57
+
58
+ return local_BSIsOnline
60
59
  }
61
60
 
62
61
  lastOnlineForUser(userid: string) {
@@ -96,6 +95,13 @@ export class MQTTPresenceService extends PresenceService {
96
95
  // });
97
96
  }
98
97
 
98
+ public imHere(): void {
99
+ this.logger.debug('[MQTT-PRESENCE] imHere', this.tenant);
100
+ setTimeout(() => {
101
+ this.chat21Service.chatClient.ImHere()
102
+ }, 2000);
103
+ }
104
+
99
105
  /**
100
106
  * removePresence
101
107
  * richiamato prima del logout
@@ -11,8 +11,6 @@ import { PresenceService } from '../abstract/presence.service';
11
11
  import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
12
12
  import { LoggerInstance } from '../logger/loggerInstance';
13
13
  // utils
14
- import { setLastDate } from '../../utils/utils';
15
- import { environment } from '../../../environments/environment';
16
14
  import { TypingService } from '../abstract/typing.service';
17
15
  import { BehaviorSubject } from 'rxjs';
18
16
 
@@ -67,6 +67,7 @@ export class NativeUploadService extends UploadService {
67
67
  if(upload.file.type.includes('pdf')){
68
68
  downloadURL = this.URL_TILEDESK_FILE + '?path=' + encodeURI(data['filename']);
69
69
  }
70
+ resolve(downloadURL)
70
71
  // that.BSStateUpload.next({upload: upload});
71
72
  }, (error) => {
72
73
  this.logger.error('[NATIVE UPLOAD] - ERROR upload new file ', error)
@@ -1,3 +1,6 @@
1
+ import { MessageModel } from '../models/message';
2
+ import { ConversationModel } from '../models/conversation';
3
+ import { v4 as uuidv4 } from 'uuid';
1
4
  import {
2
5
  MESSAGE_TYPE_INFO,
3
6
  MESSAGE_TYPE_MINE,
@@ -7,22 +10,6 @@ import {
7
10
  TYPE_SUPPORT_GROUP
8
11
  } from '../../chat21-core/utils/constants';
9
12
 
10
- /** */
11
- export function isFirstMessage(i: number) {
12
- if (i > 0) {
13
- try {
14
- const message = this.messages[i];
15
- const prevMessage = this.messages[i - 1];
16
- if (prevMessage.sender !== message.sender || message.headerDate || (prevMessage && this.isInfo(prevMessage))) {
17
- return true;
18
- }
19
- return false;
20
- } catch (err) {
21
- console.error('error: ', err);
22
- }
23
- }
24
- }
25
-
26
13
  /** */
27
14
  export function isImage(message: any) {
28
15
  if (message && message.type && message.metadata && message.metadata.src && message.type === 'image') {
@@ -74,6 +61,27 @@ export function isSender(sender: string, currentUserId: string) {
74
61
  }
75
62
  }
76
63
 
64
+ export function isSameSender(messages, senderId, index):boolean{
65
+ if(senderId && messages[index - 1] && (senderId === messages[index - 1].sender)){
66
+ return true;
67
+ }
68
+ return false;
69
+ }
70
+
71
+ export function isLastMessage(messages, idMessage):boolean {
72
+ if (idMessage === messages[messages.length - 1].uid) {
73
+ return true;
74
+ }
75
+ return false;
76
+ }
77
+
78
+ export function isFirstMessage(messages, senderId, index):boolean{
79
+ if(senderId && index == 0 && messages[index] && (messages[index] !== senderId)){
80
+ return true;
81
+ }
82
+ return false;
83
+ }
84
+
77
85
  /** */
78
86
  export function messageType(msgType: string, message: any) {
79
87
 
@@ -153,6 +161,13 @@ export function isEmojii(message: any){
153
161
  }
154
162
  }
155
163
 
164
+ export function isJustRecived(startedAt, time) {
165
+ if (time > startedAt) {
166
+ return true;
167
+ }
168
+ return false;
169
+ }
170
+
156
171
  export function checkIfIsMemberJoinedGroup(msg, loggedUser): boolean{
157
172
  if(msg && msg.attributes && msg.attributes.messagelabel
158
173
  && msg.attributes.messagelabel['key']=== "MEMBER_JOINED_GROUP"
@@ -186,4 +201,42 @@ export function getProjectIdSelectedConversation(conversationWith: string): stri
186
201
  return projectId
187
202
  }
188
203
 
204
+ export function conversationToMessage(conversation: ConversationModel, currentUserId: string): MessageModel{
205
+ let message: any = {}
206
+ message.uid = conversation['message_id']? conversation['message_id'] : uuidv4()
207
+ message.text = conversation.text? conversation.text.trim(): conversation.last_message_text.trim()
208
+ message.sender = conversation.sender
209
+ message.sender_fullname = conversation.sender_fullname
210
+ message.recipient = conversation.recipient
211
+ message.recipient_fullname = conversation.recipient_fullname
212
+ message.status = +conversation.status
213
+ message.timestamp = conversation.timestamp
214
+ message.metadata = conversation['metadata']
215
+ message.channel_type = conversation.channel_type
216
+ message.type = conversation.type
217
+ message.isSender = isSender(message.sender, currentUserId)
218
+ message.attributes = conversation.attributes
219
+
220
+ return message as MessageModel
221
+ }
222
+
223
+ export function commandToMessage(msg: MessageModel, conversation: ConversationModel, currentUserId: string): MessageModel{
224
+ let message: any = {}
225
+ message.uid = conversation['message_id']? conversation['message_id'] : uuidv4()
226
+ message.text = msg.text? msg.text.trim(): '';
227
+ message.sender = conversation.sender
228
+ message.sender_fullname = conversation.sender_fullname
229
+ message.recipient = conversation.recipient
230
+ message.recipient_fullname = conversation.recipient_fullname
231
+ message.status = +conversation.status
232
+ message.timestamp = conversation.timestamp
233
+ message.metadata = msg['metadata']
234
+ message.channel_type = conversation.channel_type
235
+ message.type = msg.type
236
+ message.isSender = isSender(message.sender, currentUserId)
237
+ message.attributes = conversation.attributes
238
+
239
+ return message as MessageModel
240
+ }
241
+
189
242