podchat 11.4.0 → 12.2.0

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 (3) hide show
  1. package/changelog.md +32 -2
  2. package/package.json +2 -2
  3. package/src/chat.js +51 -84
package/changelog.md CHANGED
@@ -4,9 +4,39 @@ All notable changes to this project will be documented here.
4
4
  to see complete list of changelog please visit [ChangeLog](https://github.com/masoudmanson/pod-chat/blob/master/changelog.md)
5
5
 
6
6
 
7
- ## [Unreleased]
8
7
 
9
- - Search in threads metadata
8
+ ## [11.4.0] - 11-12-2021
9
+ ### Added
10
+
11
+ - method: startCall
12
+ - method: startGroupCall
13
+ - method: endCall
14
+ - method: terminateCall
15
+ - method: rejectCall
16
+ - method: muteCallParticipants
17
+ - method: unMuteCallParticipants
18
+ - method: turnOnVideoCall
19
+ - method: turnOffVideoCall
20
+ - method: getCallParticipants
21
+ - method: addCallParticipants
22
+ - method: removeCallParticipants
23
+ - method: getCallsList
24
+ - event: callEvents.CALL_STARTED_ELSEWHERE
25
+ - event: callEvents.RECEIVE_CALL
26
+ - event: callEvents.CALL_SESSION_CREATED
27
+ - event: callEvents.ACCEPT_CALL
28
+ - event: callEvents.REJECT_CALL
29
+ - event: callEvents.PARTNER_RECEIVED_YOUR_CALL
30
+ - event: callEvents.CALL_SESSION_CREATED
31
+ - event: callEvents.CALL_STARTED
32
+ - event: callEvents.CALL_ENDED
33
+ - event: callEvents.CALL_PARTICIPANT_JOINED
34
+ - event: callEvents.CALL_PARTICIPANT_LEFT
35
+ - event: callEvents.CALL_PARTICIPANT_MUTE
36
+ - event: callEvents.CALL_PARTICIPANT_UNMUTE
37
+ - event: callEvents.TURN_ON_VIDEO_CALL
38
+ - event: callEvents.TURN_OFF_VIDEO_CALL
39
+ - event: callEvents.CALL_ERROR
10
40
 
11
41
 
12
42
  ## [11.3.0] - 27-11-2021
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "podchat",
3
- "version": "11.4.0",
3
+ "version": "12.2.0",
4
4
  "description": "Javascript SDK to use POD's Chat Service",
5
5
  "main": "./src/chat.js",
6
6
  "scripts": {
@@ -8,7 +8,7 @@
8
8
  "publish:snapshot": "npm run version:snapshot && npm publish --tag snapshot",
9
9
  "version:snapshot": "npm version prerelease --preid snapshot",
10
10
  "publish:release": "npm run version:release && npm publish",
11
- "version:release": "npm version 11.3.0"
11
+ "version:release": "npm version 12.2.0"
12
12
  },
13
13
  "repository": {
14
14
  "type": "git",
package/src/chat.js CHANGED
@@ -2727,45 +2727,17 @@
2727
2727
  * Type 31 Thread Last Seen Updated
2728
2728
  */
2729
2729
  case chatMessageVOTypes.LAST_SEEN_UPDATED:
2730
- if (fullResponseObject) {
2731
- getThreads({
2732
- threadIds: [messageContent.id]
2733
- }, function (threadsResult) {
2734
- var threads = threadsResult.result.threads;
2730
+ var threadObject = messageContent;
2731
+ threadObject.unreadCount = (messageContent.unreadCount) ? messageContent.unreadCount : 0;
2735
2732
 
2736
- if (!threadsResult.cache) {
2737
- fireEvent('threadEvents', {
2738
- type: 'THREAD_UNREAD_COUNT_UPDATED',
2739
- result: {
2740
- thread: threads[0],
2741
- unreadCount: messageContent.unreadCount
2742
- }
2743
- });
2744
-
2745
- fireEvent('threadEvents', {
2746
- type: 'THREAD_LAST_ACTIVITY_TIME',
2747
- result: {
2748
- thread: threads[0]
2749
- }
2750
- });
2751
- }
2752
- });
2753
- } else {
2754
- fireEvent('threadEvents', {
2755
- type: 'THREAD_UNREAD_COUNT_UPDATED',
2756
- result: {
2757
- thread: threadId,
2758
- unreadCount: messageContent.unreadCount
2759
- }
2760
- });
2733
+ fireEvent('threadEvents', {
2734
+ type: 'THREAD_UNREAD_COUNT_UPDATED',
2735
+ result: {
2736
+ thread: (fullResponseObject ? threadObject : messageContent.id),
2737
+ unreadCount: (messageContent.unreadCount) ? messageContent.unreadCount : 0
2738
+ }
2739
+ });
2761
2740
 
2762
- fireEvent('threadEvents', {
2763
- type: 'THREAD_LAST_ACTIVITY_TIME',
2764
- result: {
2765
- thread: threadId
2766
- }
2767
- });
2768
- }
2769
2741
 
2770
2742
  break;
2771
2743
 
@@ -3313,7 +3285,7 @@
3313
3285
 
3314
3286
  fireEvent('callEvents', {
3315
3287
  type: 'CALL_ENDED',
3316
- result: messageContent
3288
+ callId: threadId
3317
3289
  });
3318
3290
 
3319
3291
  callStop();
@@ -3574,10 +3546,6 @@
3574
3546
  * Tells the assistant that a call started
3575
3547
  */
3576
3548
  case chatMessageVOTypes.ASSISTANT_CALL_STARTED:
3577
- /*if (messagesCallbacks[uniqueId]) {
3578
- messagesCallbacks[uniqueId](Utility.createReturnData(false, '', 0, messageContent, contentCount));
3579
- }*/
3580
-
3581
3549
  fireEvent('callEvents', {
3582
3550
  type: 'ASSISTANT_CALL_STARTED',
3583
3551
  result: {
@@ -3593,12 +3561,9 @@
3593
3561
  * Tells the assistant that a call ended
3594
3562
  */
3595
3563
  case chatMessageVOTypes.ASSISTANT_CALL_ENDED:
3596
- /* if (messagesCallbacks[uniqueId]) {
3597
- messagesCallbacks[uniqueId](Utility.createReturnData(false, '', 0, messageContent, contentCount));
3598
- }*/
3599
-
3600
3564
  fireEvent('callEvents', {
3601
- type: 'ASSISTANT_CALL_ENDED'
3565
+ type: 'ASSISTANT_CALL_ENDED',
3566
+ callId: threadId
3602
3567
  });
3603
3568
 
3604
3569
  break;
@@ -3796,43 +3761,30 @@
3796
3761
  }
3797
3762
  });
3798
3763
 
3799
- if (fullResponseObject) {
3800
- getThreads({
3801
- threadIds: [threadId]
3802
- }, function (threadsResult) {
3803
- var threads = threadsResult.result.threads;
3764
+ var threadObject = message.conversation;
3765
+ var lastMessageVoCopy = Object.assign({}, message);
3766
+ lastMessageVoCopy.conversation && delete lastMessageVoCopy.conversation;
3804
3767
 
3805
- fireEvent('threadEvents', {
3806
- type: 'THREAD_UNREAD_COUNT_UPDATED',
3807
- result: {
3808
- thread: threads[0],
3809
- unreadCount: threads[0].unreadCount
3810
- }
3811
- });
3768
+ threadObject.lastParticipantImage = (!!message.participant && message.participant.hasOwnProperty('image')) ? message.participant.image : '';
3769
+ threadObject.lastMessageVO = lastMessageVoCopy;
3770
+ threadObject.lastParticipantName = (!!message.participant && message.participant.hasOwnProperty('name')) ? message.participant.name : '';
3771
+ threadObject.lastMessage = (message.hasOwnProperty('message')) ? message.message : '';
3812
3772
 
3813
- fireEvent('threadEvents', {
3814
- type: 'THREAD_LAST_ACTIVITY_TIME',
3815
- result: {
3816
- thread: threads[0]
3817
- }
3818
- });
3819
- });
3820
- } else {
3821
- fireEvent('threadEvents', {
3822
- type: 'THREAD_LAST_ACTIVITY_TIME',
3823
- result: {
3824
- thread: threadId
3825
- }
3826
- });
3827
3773
 
3828
- fireEvent('threadEvents', {
3829
- type: 'THREAD_UNREAD_COUNT_UPDATED',
3830
- result: {
3831
- thread: messageContent.id,
3832
- unreadCount: messageContent.conversation.unreadCount
3833
- }
3834
- });
3835
- }
3774
+ fireEvent('threadEvents', {
3775
+ type: 'THREAD_UNREAD_COUNT_UPDATED',
3776
+ result: {
3777
+ thread: (fullResponseObject ? threadObject : messageContent.id),
3778
+ unreadCount: (threadObject.unreadCount) ? threadObject.unreadCount : 0
3779
+ }
3780
+ });
3781
+
3782
+ fireEvent('threadEvents', {
3783
+ type: 'THREAD_LAST_ACTIVITY_TIME',
3784
+ result: {
3785
+ thread: (fullResponseObject ? threadObject : messageContent.id),
3786
+ }
3787
+ });
3836
3788
 
3837
3789
  /**
3838
3790
  * Update waitQ and remove sent messages from it
@@ -9181,7 +9133,7 @@
9181
9133
  callRequestController.callRequestReceived = false;
9182
9134
  currentCallParams = {};
9183
9135
  currentCallId = null;
9184
- },
9136
+ },
9185
9137
 
9186
9138
  /**
9187
9139
  * Reformat Call Participants
@@ -12469,7 +12421,15 @@
12469
12421
  content.threadId = +params.threadId;
12470
12422
  } else {
12471
12423
  if (Array.isArray(params.invitees)) {
12472
- content.invitees = params.invitees;
12424
+ content.invitees = [];//params.invitees;
12425
+ for (var i = 0; i < params.invitees.length; i++) {
12426
+ var tempInvitee = params.invitees[i];
12427
+
12428
+ if (tempInvitee && typeof tempInvitee.idType === "string") {
12429
+ tempInvitee.idType = inviteeVOidTypes[tempInvitee.idType];
12430
+ content.invitees.push(tempInvitee);
12431
+ }
12432
+ }
12473
12433
  } else {
12474
12434
  fireEvent('error', {
12475
12435
  code: 999,
@@ -12529,8 +12489,15 @@
12529
12489
  content.threadId = +params.threadId;
12530
12490
  } else {
12531
12491
  if (Array.isArray(params.invitees)) {
12532
- content.invitees = params.invitees;
12492
+ content.invitees = [];//params.invitees;
12493
+ for (var i = 0; i < params.invitees.length; i++) {
12494
+ var tempInvitee = params.invitees[i];
12533
12495
 
12496
+ if (tempInvitee && typeof tempInvitee.idType === "string") {
12497
+ tempInvitee.idType = inviteeVOidTypes[tempInvitee.idType];
12498
+ content.invitees.push(tempInvitee);
12499
+ }
12500
+ }
12534
12501
  } else {
12535
12502
  fireEvent('error', {
12536
12503
  code: 999,