podchat 11.2.0 → 11.3.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.
- package/examples/index.html +27 -13
- package/package.json +3 -3
- package/src/chat.js +164 -1
package/examples/index.html
CHANGED
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
<script type="text/javascript" src="../node_modules/podasync/src/network/async.js"></script>
|
|
12
12
|
<script type="text/javascript" src="../node_modules/crypto-js/crypto-js.js"></script>
|
|
13
13
|
<script type="text/javascript" src="../node_modules/dexie/dist/dexie.min.js"></script>
|
|
14
|
+
<script type="text/javascript" src="../node_modules/dompurify/dist/purify.min.js"></script>
|
|
15
|
+
|
|
14
16
|
<script type="text/javascript" src="../src/chat.js"></script>
|
|
15
17
|
|
|
16
18
|
<!-- Production Mode -->
|
|
@@ -43,22 +45,22 @@
|
|
|
43
45
|
/**
|
|
44
46
|
* Main Server
|
|
45
47
|
*/
|
|
46
|
-
socketAddress: 'wss://msg.pod.ir/ws', // {**REQUIRED**} Socket Address
|
|
47
|
-
ssoHost: 'https://accounts.pod.ir', // {**REQUIRED**} Socket Address
|
|
48
|
-
platformHost: 'https://api.pod.ir/srv/core', // {**REQUIRED**} Platform Core Address
|
|
49
|
-
fileServer: 'https://core.pod.ir', // {**REQUIRED**} File Server Address
|
|
50
|
-
podSpaceFileServer: 'https://podspace.pod.ir', // {**REQUIRED**} File Server Address
|
|
51
|
-
serverName: 'chat-server', // {**REQUIRED**} Server to to register on
|
|
48
|
+
// socketAddress: 'wss://msg.pod.ir/ws', // {**REQUIRED**} Socket Address
|
|
49
|
+
// ssoHost: 'https://accounts.pod.ir', // {**REQUIRED**} Socket Address
|
|
50
|
+
// platformHost: 'https://api.pod.ir/srv/core', // {**REQUIRED**} Platform Core Address
|
|
51
|
+
// fileServer: 'https://core.pod.ir', // {**REQUIRED**} File Server Address
|
|
52
|
+
// podSpaceFileServer: 'https://podspace.pod.ir', // {**REQUIRED**} File Server Address
|
|
53
|
+
// serverName: 'chat-server', // {**REQUIRED**} Server to to register on
|
|
52
54
|
|
|
53
55
|
/**
|
|
54
56
|
* Sand Box
|
|
55
57
|
*/
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
socketAddress: "wss://chat-sandbox.pod.ir/ws",
|
|
59
|
+
ssoHost: "https://accounts.pod.ir",
|
|
60
|
+
platformHost: "https://sandbox.pod.ir:8043/srv/basic-platform",
|
|
61
|
+
fileServer: 'https://core.pod.ir',
|
|
62
|
+
podSpaceFileServer: 'https://podspace.pod.ir',
|
|
63
|
+
serverName: "chat-server",
|
|
62
64
|
|
|
63
65
|
/**
|
|
64
66
|
* PodSpace test
|
|
@@ -85,7 +87,7 @@
|
|
|
85
87
|
fullResponseObject: false,
|
|
86
88
|
mapApiKey: '8b77db18704aa646ee5aaea13e7370f4f88b9e8c',
|
|
87
89
|
// typeCode: "talk",
|
|
88
|
-
token: "
|
|
90
|
+
token: "0bea561f71af4cc9829afce8ac472f2f",
|
|
89
91
|
// token: "f19933ae1b1e424db9965a243bf3bcd3", // {**REQUIRED**} SSO Token ZiZi
|
|
90
92
|
// token: "81025b3fbc1a4f7184c3600a2f874673", // {**REQUIRED**} SSO Token JiJi
|
|
91
93
|
// token: "3c4d62b6068043aa898cf7426d5cae68", // {**REQUIRED**} SSO Token FiFi
|
|
@@ -799,6 +801,18 @@
|
|
|
799
801
|
break;
|
|
800
802
|
}
|
|
801
803
|
});
|
|
804
|
+
/**
|
|
805
|
+
* Listen to Call Events
|
|
806
|
+
*/
|
|
807
|
+
chatAgent.on("callEvents", function (event) {
|
|
808
|
+
var type = event.type;
|
|
809
|
+
console.log(event);
|
|
810
|
+
/*
|
|
811
|
+
switch (type) {
|
|
812
|
+
default:
|
|
813
|
+
break;
|
|
814
|
+
}*/
|
|
815
|
+
});
|
|
802
816
|
|
|
803
817
|
/**
|
|
804
818
|
* Listen to User Events
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "podchat",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.3.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.
|
|
11
|
+
"version:release": "npm version 11.3.0"
|
|
12
12
|
},
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"homepage": "https://github.com/FanapSoft/pod-chat-js-sdk#readme",
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"crypto-js": "^3.1.9-1",
|
|
34
|
-
"dexie": "^
|
|
34
|
+
"dexie": "^2.0.4",
|
|
35
35
|
"dompurify": "^2.3.3",
|
|
36
36
|
"faker": "^4.1.0",
|
|
37
37
|
"form-data": "^2.5.0",
|
package/src/chat.js
CHANGED
|
@@ -96,7 +96,8 @@
|
|
|
96
96
|
systemEvents: {},
|
|
97
97
|
chatReady: {},
|
|
98
98
|
error: {},
|
|
99
|
-
chatState: {}
|
|
99
|
+
chatState: {},
|
|
100
|
+
callEvents: {}
|
|
100
101
|
},
|
|
101
102
|
messagesCallbacks = {},
|
|
102
103
|
sendMessageCallbacks = {},
|
|
@@ -163,6 +164,14 @@
|
|
|
163
164
|
THREAD_ALL_BOTS: 69,
|
|
164
165
|
CONTACT_SYNCED: 90,
|
|
165
166
|
LOGOUT: 100,
|
|
167
|
+
|
|
168
|
+
RECORD_CALL: 121,
|
|
169
|
+
END_RECORD_CALL: 122,
|
|
170
|
+
DESTINATED_RECORD_CALL: 126,
|
|
171
|
+
ASSISTANT_CALL_STARTED: 127,
|
|
172
|
+
ASSISTANT_CALL_ENDED: 128,
|
|
173
|
+
EXPORT_CHAT: 152,
|
|
174
|
+
|
|
166
175
|
ERROR: 999
|
|
167
176
|
},
|
|
168
177
|
inviteeVOidTypes = {
|
|
@@ -3120,6 +3129,85 @@
|
|
|
3120
3129
|
});
|
|
3121
3130
|
break;
|
|
3122
3131
|
|
|
3132
|
+
/**
|
|
3133
|
+
* Type 121 Record Call Request
|
|
3134
|
+
*/
|
|
3135
|
+
case chatMessageVOTypes.RECORD_CALL:
|
|
3136
|
+
if (messagesCallbacks[uniqueId]) {
|
|
3137
|
+
messagesCallbacks[uniqueId](Utility.createReturnData(false, '', 0, messageContent, contentCount));
|
|
3138
|
+
}
|
|
3139
|
+
|
|
3140
|
+
fireEvent('callEvents', {
|
|
3141
|
+
type: 'START_RECORDING_CALL',
|
|
3142
|
+
result: messageContent
|
|
3143
|
+
});
|
|
3144
|
+
|
|
3145
|
+
break;
|
|
3146
|
+
|
|
3147
|
+
/**
|
|
3148
|
+
* Type 122 End Record Call Request
|
|
3149
|
+
*/
|
|
3150
|
+
case chatMessageVOTypes.END_RECORD_CALL:
|
|
3151
|
+
if (messagesCallbacks[uniqueId]) {
|
|
3152
|
+
messagesCallbacks[uniqueId](Utility.createReturnData(false, '', 0, messageContent, contentCount));
|
|
3153
|
+
}
|
|
3154
|
+
|
|
3155
|
+
fireEvent('callEvents', {
|
|
3156
|
+
type: 'STOP_RECORDING_CALL',
|
|
3157
|
+
result: messageContent
|
|
3158
|
+
});
|
|
3159
|
+
|
|
3160
|
+
break;
|
|
3161
|
+
|
|
3162
|
+
/**
|
|
3163
|
+
* Type 126 Destined Record Call Request
|
|
3164
|
+
*/
|
|
3165
|
+
case chatMessageVOTypes.DESTINATED_RECORD_CALL:
|
|
3166
|
+
if (messagesCallbacks[uniqueId]) {
|
|
3167
|
+
messagesCallbacks[uniqueId](Utility.createReturnData(false, '', 0, messageContent, contentCount));
|
|
3168
|
+
}
|
|
3169
|
+
|
|
3170
|
+
fireEvent('callEvents', {
|
|
3171
|
+
type: 'START_RECORDING_CALL',
|
|
3172
|
+
result: messageContent
|
|
3173
|
+
});
|
|
3174
|
+
|
|
3175
|
+
break;
|
|
3176
|
+
|
|
3177
|
+
/**
|
|
3178
|
+
* Type 127 Assistant call started
|
|
3179
|
+
*
|
|
3180
|
+
* Tells the assistant that a call started
|
|
3181
|
+
*/
|
|
3182
|
+
case chatMessageVOTypes.ASSISTANT_CALL_STARTED:
|
|
3183
|
+
/*if (messagesCallbacks[uniqueId]) {
|
|
3184
|
+
messagesCallbacks[uniqueId](Utility.createReturnData(false, '', 0, messageContent, contentCount));
|
|
3185
|
+
}*/
|
|
3186
|
+
|
|
3187
|
+
fireEvent('callEvents', {
|
|
3188
|
+
type: 'ASSISTANT_CALL_STARTED',
|
|
3189
|
+
result: {
|
|
3190
|
+
callId: threadId
|
|
3191
|
+
}
|
|
3192
|
+
});
|
|
3193
|
+
|
|
3194
|
+
break;
|
|
3195
|
+
|
|
3196
|
+
/**
|
|
3197
|
+
* Type 128 Assistant call ended
|
|
3198
|
+
*
|
|
3199
|
+
* Tells the assistant that a call ended
|
|
3200
|
+
*/
|
|
3201
|
+
case chatMessageVOTypes.ASSISTANT_CALL_ENDED:
|
|
3202
|
+
/* if (messagesCallbacks[uniqueId]) {
|
|
3203
|
+
messagesCallbacks[uniqueId](Utility.createReturnData(false, '', 0, messageContent, contentCount));
|
|
3204
|
+
}*/
|
|
3205
|
+
|
|
3206
|
+
fireEvent('callEvents', {
|
|
3207
|
+
type: 'ASSISTANT_CALL_ENDED'
|
|
3208
|
+
});
|
|
3209
|
+
|
|
3210
|
+
break;
|
|
3123
3211
|
|
|
3124
3212
|
/**
|
|
3125
3213
|
* Type 999 All unknown errors
|
|
@@ -11720,6 +11808,81 @@
|
|
|
11720
11808
|
|
|
11721
11809
|
this.generateUUID = Utility.generateUUID;
|
|
11722
11810
|
|
|
11811
|
+
this.startRecordingCall = function (params, callback) {
|
|
11812
|
+
var recordCallData = {
|
|
11813
|
+
chatMessageVOType: chatMessageVOTypes.RECORD_CALL,
|
|
11814
|
+
typeCode: params.typeCode,
|
|
11815
|
+
pushMsgType: 3,
|
|
11816
|
+
token: token,
|
|
11817
|
+
content: {}
|
|
11818
|
+
};
|
|
11819
|
+
|
|
11820
|
+
if (params) {
|
|
11821
|
+
if (typeof +params.callId === 'number' && params.callId > 0) {
|
|
11822
|
+
recordCallData.subjectId = +params.callId;
|
|
11823
|
+
} else {
|
|
11824
|
+
fireEvent('error', {
|
|
11825
|
+
code: 999,
|
|
11826
|
+
message: 'Invalid Call id!'
|
|
11827
|
+
});
|
|
11828
|
+
return;
|
|
11829
|
+
}
|
|
11830
|
+
|
|
11831
|
+
if(params.destinated === true) {
|
|
11832
|
+
recordCallData.chatMessageVOType = chatMessageVOTypes.DESTINATED_RECORD_CALL;
|
|
11833
|
+
recordCallData.content.recordType = typeof +params.recordType === 'number' ? params.recordType : 1;
|
|
11834
|
+
recordCallData.content.tags = Array.isArray(params.tags) ? params.tags : null;
|
|
11835
|
+
recordCallData.content.threadId = typeof +params.threadId === 'number' ? params.threadId : null;
|
|
11836
|
+
}
|
|
11837
|
+
} else {
|
|
11838
|
+
fireEvent('error', {
|
|
11839
|
+
code: 999,
|
|
11840
|
+
message: 'No params have been sent to Record call!'
|
|
11841
|
+
});
|
|
11842
|
+
return;
|
|
11843
|
+
}
|
|
11844
|
+
|
|
11845
|
+
return sendMessage(recordCallData, {
|
|
11846
|
+
onResult: function (result) {
|
|
11847
|
+
callback && callback(result);
|
|
11848
|
+
}
|
|
11849
|
+
});
|
|
11850
|
+
};
|
|
11851
|
+
|
|
11852
|
+
this.stopRecordingCall = function (params, callback) {
|
|
11853
|
+
var stopRecordingCallData = {
|
|
11854
|
+
chatMessageVOType: chatMessageVOTypes.END_RECORD_CALL,
|
|
11855
|
+
typeCode: params.typeCode,
|
|
11856
|
+
pushMsgType: 3,
|
|
11857
|
+
token: token
|
|
11858
|
+
};
|
|
11859
|
+
|
|
11860
|
+
if (params) {
|
|
11861
|
+
if (typeof +params.callId === 'number' && params.callId > 0) {
|
|
11862
|
+
stopRecordingCallData.subjectId = +params.callId;
|
|
11863
|
+
} else {
|
|
11864
|
+
fireEvent('error', {
|
|
11865
|
+
code: 999,
|
|
11866
|
+
message: 'Invalid Call id!'
|
|
11867
|
+
});
|
|
11868
|
+
return;
|
|
11869
|
+
}
|
|
11870
|
+
} else {
|
|
11871
|
+
fireEvent('error', {
|
|
11872
|
+
code: 999,
|
|
11873
|
+
message: 'No params have been sent to Stop Recording the call!'
|
|
11874
|
+
});
|
|
11875
|
+
return;
|
|
11876
|
+
}
|
|
11877
|
+
|
|
11878
|
+
return sendMessage(stopRecordingCallData, {
|
|
11879
|
+
onResult: function (result) {
|
|
11880
|
+
callback && callback(result);
|
|
11881
|
+
}
|
|
11882
|
+
});
|
|
11883
|
+
};
|
|
11884
|
+
|
|
11885
|
+
|
|
11723
11886
|
this.logout = function () {
|
|
11724
11887
|
clearChatServerCaches();
|
|
11725
11888
|
|