@softtynet/zca-js 2.3.3 → 2.3.5
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/README.md +99 -21
- package/dist/apis/auth/exportSession.d.ts +7 -0
- package/dist/apis/auth/exportSession.js +17 -0
- package/dist/apis/call/addUserGroupCall.d.ts +11 -0
- package/dist/apis/call/addUserGroupCall.js +48 -0
- package/dist/apis/call/answerAckVoiceCall.d.ts +5 -0
- package/dist/apis/call/answerAckVoiceCall.js +38 -0
- package/dist/apis/call/answerGroupCall.d.ts +10 -0
- package/dist/apis/call/answerGroupCall.js +45 -0
- package/dist/apis/call/answerVoiceCall.d.ts +11 -0
- package/dist/apis/call/answerVoiceCall.js +50 -0
- package/dist/apis/call/broadcastGroupCallState.d.ts +10 -0
- package/dist/apis/call/broadcastGroupCallState.js +45 -0
- package/dist/apis/call/cancelGroupCall.d.ts +10 -0
- package/dist/apis/call/cancelGroupCall.js +45 -0
- package/dist/apis/call/cancelVoiceCall.d.ts +1 -1
- package/dist/apis/call/cancelVoiceCall.js +5 -1
- package/dist/apis/call/createController.d.ts +7 -0
- package/dist/apis/call/createController.js +9 -0
- package/dist/apis/call/createRtcSession.d.ts +8 -0
- package/dist/apis/call/createRtcSession.js +10 -0
- package/dist/apis/call/endGroupCall.d.ts +10 -0
- package/dist/apis/call/endGroupCall.js +45 -0
- package/dist/apis/call/finishGroupCall.d.ts +12 -0
- package/dist/apis/call/finishGroupCall.js +47 -0
- package/dist/apis/call/getGroupCallState.d.ts +3 -0
- package/dist/apis/call/getGroupCallState.js +38 -0
- package/dist/apis/call/holdVoiceCall.d.ts +5 -0
- package/dist/apis/call/holdVoiceCall.js +34 -0
- package/dist/apis/call/joinGroupCall.d.ts +11 -0
- package/dist/apis/call/joinGroupCall.js +46 -0
- package/dist/apis/call/logEndVoiceCall.d.ts +8 -0
- package/dist/apis/call/logEndVoiceCall.js +46 -0
- package/dist/apis/call/notifyGroupCall.d.ts +9 -0
- package/dist/apis/call/notifyGroupCall.js +44 -0
- package/dist/apis/call/pingGroupCall.d.ts +10 -0
- package/dist/apis/call/pingGroupCall.js +45 -0
- package/dist/apis/call/requestAudioToVideoCall.d.ts +5 -0
- package/dist/apis/call/requestAudioToVideoCall.js +37 -0
- package/dist/apis/call/requestGroupCall.d.ts +9 -0
- package/dist/apis/call/requestGroupCall.js +46 -0
- package/dist/apis/call/requestShareScreenCall.d.ts +5 -0
- package/dist/apis/call/requestShareScreenCall.js +37 -0
- package/dist/apis/call/requestVoiceCall.d.ts +10 -0
- package/dist/apis/call/requestVoiceCall.js +47 -0
- package/dist/apis/call/ringRingGroupCall.d.ts +10 -0
- package/dist/apis/call/ringRingGroupCall.js +45 -0
- package/dist/apis/call/ringRingVoiceCall.d.ts +5 -0
- package/dist/apis/call/ringRingVoiceCall.js +38 -0
- package/dist/apis/call/sendRequestGroupCall.d.ts +11 -0
- package/dist/apis/call/sendRequestGroupCall.js +48 -0
- package/dist/apis/call/sendRequestVoiceCall.d.ts +11 -0
- package/dist/apis/call/sendRequestVoiceCall.js +51 -0
- package/dist/apis/call/sendVoiceCall.d.ts +8 -1
- package/dist/apis/call/sendVoiceCall.js +10 -8
- package/dist/apis/call/shareScreenGroupCall.d.ts +10 -0
- package/dist/apis/call/shareScreenGroupCall.js +45 -0
- package/dist/apis/call/unholdVoiceCall.d.ts +5 -0
- package/dist/apis/call/unholdVoiceCall.js +34 -0
- package/dist/apis/call/updateCallMediaState.d.ts +7 -0
- package/dist/apis/call/updateCallMediaState.js +61 -0
- package/dist/apis/chat/getDirectMessageStatus.d.ts +14 -0
- package/dist/apis/chat/getDirectMessageStatus.js +52 -0
- package/dist/apis/chat/getSuggestedConversations.d.ts +5 -0
- package/dist/apis/chat/getSuggestedConversations.js +24 -0
- package/dist/apis/chat/updatePinConversations.d.ts +24 -0
- package/dist/apis/chat/updatePinConversations.js +40 -0
- package/dist/apis/friend/getFriendProfilesV2.d.ts +26 -0
- package/dist/apis/friend/getFriendProfilesV2.js +38 -0
- package/dist/apis/friend/getFriendsActivePCWeb.d.ts +6 -0
- package/dist/apis/friend/getFriendsActivePCWeb.js +15 -0
- package/dist/apis/friend/verifyFriend.d.ts +11 -0
- package/dist/apis/friend/verifyFriend.js +37 -0
- package/dist/apis/group/analyseGroup.d.ts +4 -0
- package/dist/apis/group/analyseGroup.js +28 -0
- package/dist/apis/group/checkQuotaCommunityMember.d.ts +6 -0
- package/dist/apis/group/checkQuotaCommunityMember.js +34 -0
- package/dist/apis/group/getE2eeGroupList.d.ts +7 -0
- package/dist/apis/group/getE2eeGroupList.js +15 -0
- package/dist/apis/group/getGroupCloudMessagePath.d.ts +19 -0
- package/dist/apis/group/getGroupCloudMessagePath.js +51 -0
- package/dist/apis/group/getMultiGroupCloudMessages.d.ts +5 -0
- package/dist/apis/group/getMultiGroupCloudMessages.js +29 -0
- package/dist/apis/media/getPersonalMedia.d.ts +8 -0
- package/dist/apis/media/getPersonalMedia.js +31 -0
- package/dist/apis/media/getPersonalMediaPreview.d.ts +3 -0
- package/dist/apis/media/getPersonalMediaPreview.js +24 -0
- package/dist/apis/media/removePersonalMedia.d.ts +9 -0
- package/dist/apis/media/removePersonalMedia.js +28 -0
- package/dist/apis.d.ts +126 -0
- package/dist/apis.js +210 -0
- package/dist/call-engine/ZRTPPacketCodec.d.ts +262 -0
- package/dist/call-engine/ZRTPPacketCodec.js +506 -0
- package/dist/call-engine/ZaloCallController.d.ts +134 -0
- package/dist/call-engine/ZaloCallController.js +638 -0
- package/dist/call-engine/ZaloCallTransport.d.ts +83 -0
- package/dist/call-engine/ZaloCallTransport.js +233 -0
- package/dist/call-engine/ZaloRtcSession.d.ts +609 -0
- package/dist/call-engine/ZaloRtcSession.js +2931 -0
- package/dist/call-engine/ZaloSrtpSession.d.ts +80 -0
- package/dist/call-engine/ZaloSrtpSession.js +278 -0
- package/dist/call-engine/index.d.ts +18 -0
- package/dist/call-engine/index.js +24 -0
- package/dist/cjs/apis/auth/exportSession.cjs +22 -0
- package/dist/cjs/apis/call/addUserGroupCall.cjs +53 -0
- package/dist/cjs/apis/call/answerAckVoiceCall.cjs +43 -0
- package/dist/cjs/apis/call/answerGroupCall.cjs +50 -0
- package/dist/cjs/apis/call/answerVoiceCall.cjs +55 -0
- package/dist/cjs/apis/call/broadcastGroupCallState.cjs +50 -0
- package/dist/cjs/apis/call/cancelGroupCall.cjs +50 -0
- package/dist/cjs/apis/call/cancelVoiceCall.cjs +5 -1
- package/dist/cjs/apis/call/createController.cjs +14 -0
- package/dist/cjs/apis/call/createRtcSession.cjs +15 -0
- package/dist/cjs/apis/call/endGroupCall.cjs +50 -0
- package/dist/cjs/apis/call/finishGroupCall.cjs +52 -0
- package/dist/cjs/apis/call/getGroupCallState.cjs +43 -0
- package/dist/cjs/apis/call/holdVoiceCall.cjs +39 -0
- package/dist/cjs/apis/call/joinGroupCall.cjs +51 -0
- package/dist/cjs/apis/call/logEndVoiceCall.cjs +51 -0
- package/dist/cjs/apis/call/notifyGroupCall.cjs +49 -0
- package/dist/cjs/apis/call/pingGroupCall.cjs +50 -0
- package/dist/cjs/apis/call/requestAudioToVideoCall.cjs +42 -0
- package/dist/cjs/apis/call/requestGroupCall.cjs +51 -0
- package/dist/cjs/apis/call/requestShareScreenCall.cjs +42 -0
- package/dist/cjs/apis/call/requestVoiceCall.cjs +52 -0
- package/dist/cjs/apis/call/ringRingGroupCall.cjs +50 -0
- package/dist/cjs/apis/call/ringRingVoiceCall.cjs +43 -0
- package/dist/cjs/apis/call/sendRequestGroupCall.cjs +53 -0
- package/dist/cjs/apis/call/sendRequestVoiceCall.cjs +56 -0
- package/dist/cjs/apis/call/sendVoiceCall.cjs +10 -8
- package/dist/cjs/apis/call/shareScreenGroupCall.cjs +50 -0
- package/dist/cjs/apis/call/unholdVoiceCall.cjs +39 -0
- package/dist/cjs/apis/call/updateCallMediaState.cjs +66 -0
- package/dist/cjs/apis/chat/getDirectMessageStatus.cjs +58 -0
- package/dist/cjs/apis/chat/getSuggestedConversations.cjs +29 -0
- package/dist/cjs/apis/chat/updatePinConversations.cjs +45 -0
- package/dist/cjs/apis/friend/getFriendProfilesV2.cjs +43 -0
- package/dist/cjs/apis/friend/getFriendsActivePCWeb.cjs +20 -0
- package/dist/cjs/apis/friend/verifyFriend.cjs +42 -0
- package/dist/cjs/apis/group/analyseGroup.cjs +33 -0
- package/dist/cjs/apis/group/checkQuotaCommunityMember.cjs +39 -0
- package/dist/cjs/apis/group/getE2eeGroupList.cjs +20 -0
- package/dist/cjs/apis/group/getGroupChatHistory.cjs +8 -7
- package/dist/cjs/apis/group/getGroupCloudMessagePath.cjs +69 -0
- package/dist/cjs/apis/group/getGroupHistoryLegacy.cjs +7 -6
- package/dist/cjs/apis/group/getGroupMessageStatus.cjs +7 -6
- package/dist/cjs/apis/group/getMultiGroupCloudMessages.cjs +34 -0
- package/dist/cjs/apis/media/getPersonalMedia.cjs +36 -0
- package/dist/cjs/apis/media/getPersonalMediaPreview.cjs +29 -0
- package/dist/cjs/apis/media/removePersonalMedia.cjs +33 -0
- package/dist/cjs/apis.cjs +210 -0
- package/dist/cjs/call-engine/ZRTPPacketCodec.cjs +525 -0
- package/dist/cjs/call-engine/ZaloCallController.cjs +643 -0
- package/dist/cjs/call-engine/ZaloCallTransport.cjs +239 -0
- package/dist/cjs/call-engine/ZaloRtcSession.cjs +2937 -0
- package/dist/cjs/call-engine/ZaloSrtpSession.cjs +287 -0
- package/dist/cjs/constants/protocol.cjs +1 -1
- package/dist/cjs/context.cjs +20 -2
- package/dist/cjs/core/zcloud-client.cjs +1 -2
- package/dist/cjs/crypto/ws-cipher.cjs +66 -2
- package/dist/cjs/index.cjs +63 -6
- package/dist/cjs/models/CallEvent.cjs +95 -1
- package/dist/cjs/realtime/handlers/control.handler.cjs +17 -3
- package/dist/cjs/realtime/listener.cjs +37 -6
- package/dist/cjs/update.cjs +10 -1
- package/dist/cjs/utils.cjs +21 -68
- package/dist/constants/protocol.d.ts +1 -1
- package/dist/constants/protocol.js +1 -1
- package/dist/context.d.ts +10 -0
- package/dist/context.js +20 -2
- package/dist/crypto/ws-cipher.d.ts +7 -0
- package/dist/crypto/ws-cipher.js +64 -2
- package/dist/index.d.ts +47 -4
- package/dist/index.js +2 -0
- package/dist/models/CallEvent.d.ts +15 -0
- package/dist/models/CallEvent.js +95 -1
- package/dist/realtime/handlers/control.handler.js +17 -3
- package/dist/realtime/listener.d.ts +6 -0
- package/dist/realtime/listener.js +37 -6
- package/dist/update.js +10 -1
- package/dist/utils.d.ts +0 -7
- package/dist/utils.js +15 -64
- package/index.d.ts +1 -1
- package/package.json +16 -5
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../../utils.cjs');
|
|
5
|
+
var sendVoiceCall = require('./sendVoiceCall.cjs');
|
|
6
|
+
|
|
7
|
+
const requestVoiceCallFactory = utils.apiFactory()((api, ctx, utils$1) => {
|
|
8
|
+
const voiceCallService = api.zpwServiceMap.voice_call?.[0];
|
|
9
|
+
/**
|
|
10
|
+
* Xin cấp phát phiên gọi thoại / video và máy chủ relay RTP/RTCP (`/api/voicecall/requestcall`, command `11300`, signal `401`).
|
|
11
|
+
*
|
|
12
|
+
* @param calleeId User ID của người nhận cuộc gọi
|
|
13
|
+
* @param options Tuỳ chọn loại cuộc gọi (`callType`), `callId` và `codec`
|
|
14
|
+
* @throws {ZaloApiError}
|
|
15
|
+
*/
|
|
16
|
+
return async function requestVoiceCall(calleeId, options = {}) {
|
|
17
|
+
if (!calleeId)
|
|
18
|
+
throw new ZaloApiError.ZaloApiError("Missing calleeId");
|
|
19
|
+
if (!voiceCallService)
|
|
20
|
+
throw new ZaloApiError.ZaloApiError("Missing voice_call service URL in zpwServiceMap");
|
|
21
|
+
const callType = options.callType ?? sendVoiceCall.CallType.Audio;
|
|
22
|
+
const callId = options.callId ?? Math.floor(Math.random() * 2_000_000_000);
|
|
23
|
+
const codec = options.codec ?? "[]";
|
|
24
|
+
const params = {
|
|
25
|
+
calleeId: String(calleeId),
|
|
26
|
+
callId,
|
|
27
|
+
codec,
|
|
28
|
+
typeRequest: callType,
|
|
29
|
+
imei: ctx.imei,
|
|
30
|
+
};
|
|
31
|
+
const encryptedParams = utils$1.encodeAES(JSON.stringify(params));
|
|
32
|
+
if (!encryptedParams)
|
|
33
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt requestVoiceCall params");
|
|
34
|
+
const url = utils$1.makeURL(`${voiceCallService}/api/voicecall/requestcall`, {
|
|
35
|
+
zpw_type: 24,
|
|
36
|
+
params: encryptedParams,
|
|
37
|
+
});
|
|
38
|
+
const response = await utils$1.request(url, {
|
|
39
|
+
method: "GET",
|
|
40
|
+
});
|
|
41
|
+
const serverInfo = await utils.resolveResponse(ctx, response, (result) => {
|
|
42
|
+
const raw = result.data;
|
|
43
|
+
return typeof raw === "string" ? JSON.parse(raw) : raw;
|
|
44
|
+
});
|
|
45
|
+
return {
|
|
46
|
+
...serverInfo,
|
|
47
|
+
callId,
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
exports.requestVoiceCallFactory = requestVoiceCallFactory;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../../utils.cjs');
|
|
5
|
+
var sendVoiceCall = require('./sendVoiceCall.cjs');
|
|
6
|
+
|
|
7
|
+
const ringRingGroupCallFactory = utils.apiFactory()((api, ctx, utils) => {
|
|
8
|
+
const voiceCallService = api.zpwServiceMap.voice_call?.[0];
|
|
9
|
+
/**
|
|
10
|
+
* Báo hiệu thiết bị đang đổ chuông cho cuộc gọi nhóm (`/api/voicecall/group/ringring`, command `12439`).
|
|
11
|
+
*
|
|
12
|
+
* @param callId ID của cuộc gọi nhóm
|
|
13
|
+
* @param options Thông tin `hostCall`, `calleeId`, `callType`, `partners` và `data`
|
|
14
|
+
* @throws {ZaloApiError}
|
|
15
|
+
*/
|
|
16
|
+
return async function ringRingGroupCall(callId, options) {
|
|
17
|
+
if (!callId)
|
|
18
|
+
throw new ZaloApiError.ZaloApiError("Missing callId");
|
|
19
|
+
if (!options?.hostCall)
|
|
20
|
+
throw new ZaloApiError.ZaloApiError("Missing hostCall");
|
|
21
|
+
if (!voiceCallService)
|
|
22
|
+
throw new ZaloApiError.ZaloApiError("Missing voice_call service URL in zpwServiceMap");
|
|
23
|
+
const dataStr = options.data === undefined
|
|
24
|
+
? "{}"
|
|
25
|
+
: typeof options.data === "string"
|
|
26
|
+
? options.data
|
|
27
|
+
: JSON.stringify(options.data);
|
|
28
|
+
const params = {
|
|
29
|
+
calleeId: String(options.calleeId ?? ctx.uid),
|
|
30
|
+
callId,
|
|
31
|
+
callType: options.callType ?? sendVoiceCall.CallType.GroupAudio,
|
|
32
|
+
hostCall: String(options.hostCall),
|
|
33
|
+
data: dataStr,
|
|
34
|
+
partners: (options.partners ?? []).map(String),
|
|
35
|
+
};
|
|
36
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
37
|
+
if (!encryptedParams)
|
|
38
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt ringRingGroupCall params");
|
|
39
|
+
const url = utils.makeURL(`${voiceCallService}/api/voicecall/group/ringring`, {
|
|
40
|
+
zpw_type: 24,
|
|
41
|
+
params: encryptedParams,
|
|
42
|
+
});
|
|
43
|
+
const response = await utils.request(url, {
|
|
44
|
+
method: "GET",
|
|
45
|
+
});
|
|
46
|
+
return utils.resolve(response);
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
exports.ringRingGroupCallFactory = ringRingGroupCallFactory;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const ringRingVoiceCallFactory = utils.apiFactory()((api, ctx, utils) => {
|
|
7
|
+
const voiceCallService = api.zpwServiceMap.voice_call?.[0];
|
|
8
|
+
/**
|
|
9
|
+
* Báo hiệu thiết bị của người nhận đang đổ chuông cho người gọi (`/api/voicecall/ringring`, command `11302`, signal `407`).
|
|
10
|
+
*
|
|
11
|
+
* @param callerId User ID của người gọi đến
|
|
12
|
+
* @param callId ID của cuộc gọi
|
|
13
|
+
* @param options Tuỳ chọn mã trạng thái (`status`, mặc định `0`)
|
|
14
|
+
* @throws {ZaloApiError}
|
|
15
|
+
*/
|
|
16
|
+
return async function ringRingVoiceCall(callerId, callId, options = {}) {
|
|
17
|
+
if (!callerId)
|
|
18
|
+
throw new ZaloApiError.ZaloApiError("Missing callerId");
|
|
19
|
+
if (!callId)
|
|
20
|
+
throw new ZaloApiError.ZaloApiError("Missing callId");
|
|
21
|
+
if (!voiceCallService)
|
|
22
|
+
throw new ZaloApiError.ZaloApiError("Missing voice_call service URL in zpwServiceMap");
|
|
23
|
+
const params = {
|
|
24
|
+
callerId: String(callerId),
|
|
25
|
+
callId,
|
|
26
|
+
status: options.status ?? 0,
|
|
27
|
+
imei: ctx.imei,
|
|
28
|
+
};
|
|
29
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
30
|
+
if (!encryptedParams)
|
|
31
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt ringRingVoiceCall params");
|
|
32
|
+
const url = utils.makeURL(`${voiceCallService}/api/voicecall/ringring`, {
|
|
33
|
+
zpw_type: 24,
|
|
34
|
+
params: encryptedParams,
|
|
35
|
+
});
|
|
36
|
+
const response = await utils.request(url, {
|
|
37
|
+
method: "GET",
|
|
38
|
+
});
|
|
39
|
+
return utils.resolve(response);
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
exports.ringRingVoiceCallFactory = ringRingVoiceCallFactory;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../../utils.cjs');
|
|
5
|
+
var sendVoiceCall = require('./sendVoiceCall.cjs');
|
|
6
|
+
|
|
7
|
+
const sendRequestGroupCallFactory = utils.apiFactory()((api, _ctx, utils) => {
|
|
8
|
+
const voiceCallService = api.zpwServiceMap.voice_call?.[0];
|
|
9
|
+
/**
|
|
10
|
+
* Gửi tín hiệu mời tham gia / đổ chuông cuộc gọi nhóm (`/api/voicecall/group/request`, command `12434`).
|
|
11
|
+
*
|
|
12
|
+
* @param groupId ID của nhóm
|
|
13
|
+
* @param options Thông tin `callId`, `session`, `partners`, `callType` và `data`
|
|
14
|
+
* @throws {ZaloApiError}
|
|
15
|
+
*/
|
|
16
|
+
return async function sendRequestGroupCall(groupId, options) {
|
|
17
|
+
if (!groupId)
|
|
18
|
+
throw new ZaloApiError.ZaloApiError("Missing groupId");
|
|
19
|
+
if (!options?.callId)
|
|
20
|
+
throw new ZaloApiError.ZaloApiError("Missing callId");
|
|
21
|
+
if (!options?.session)
|
|
22
|
+
throw new ZaloApiError.ZaloApiError("Missing session");
|
|
23
|
+
if (!voiceCallService)
|
|
24
|
+
throw new ZaloApiError.ZaloApiError("Missing voice_call service URL in zpwServiceMap");
|
|
25
|
+
const dataStr = options.data === undefined
|
|
26
|
+
? "{}"
|
|
27
|
+
: typeof options.data === "string"
|
|
28
|
+
? options.data
|
|
29
|
+
: JSON.stringify(options.data);
|
|
30
|
+
const params = {
|
|
31
|
+
calleeId: options.calleeId ?? "",
|
|
32
|
+
callId: options.callId,
|
|
33
|
+
callType: options.callType ?? sendVoiceCall.CallType.GroupAudio,
|
|
34
|
+
data: dataStr,
|
|
35
|
+
session: options.session,
|
|
36
|
+
partners: (options.partners ?? []).map(String),
|
|
37
|
+
groupId: String(groupId),
|
|
38
|
+
};
|
|
39
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
40
|
+
if (!encryptedParams)
|
|
41
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt sendRequestGroupCall params");
|
|
42
|
+
const url = utils.makeURL(`${voiceCallService}/api/voicecall/group/request`, {
|
|
43
|
+
zpw_type: 24,
|
|
44
|
+
params: encryptedParams,
|
|
45
|
+
});
|
|
46
|
+
const response = await utils.request(url, {
|
|
47
|
+
method: "GET",
|
|
48
|
+
});
|
|
49
|
+
return utils.resolve(response);
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
exports.sendRequestGroupCallFactory = sendRequestGroupCallFactory;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const sendRequestVoiceCallFactory = utils.apiFactory()((api, ctx, utils) => {
|
|
7
|
+
const voiceCallService = api.zpwServiceMap.voice_call?.[0];
|
|
8
|
+
/**
|
|
9
|
+
* Gửi tín hiệu đổ chuông kèm thông tin kết nối RTP/RTCP & `extendData` (`/api/voicecall/request`, command `11301`, signal `416`).
|
|
10
|
+
*
|
|
11
|
+
* @param calleeId User ID của người nhận cuộc gọi
|
|
12
|
+
* @param options Thông tin `callId`, `session`, `rtpAddress`, `rtcpAddress`, `codec` và `extendData`
|
|
13
|
+
* @throws {ZaloApiError}
|
|
14
|
+
*/
|
|
15
|
+
return async function sendRequestVoiceCall(calleeId, options) {
|
|
16
|
+
if (!calleeId)
|
|
17
|
+
throw new ZaloApiError.ZaloApiError("Missing calleeId");
|
|
18
|
+
if (!options?.callId)
|
|
19
|
+
throw new ZaloApiError.ZaloApiError("Missing callId");
|
|
20
|
+
if (!options?.session)
|
|
21
|
+
throw new ZaloApiError.ZaloApiError("Missing session");
|
|
22
|
+
if (!voiceCallService)
|
|
23
|
+
throw new ZaloApiError.ZaloApiError("Missing voice_call service URL in zpwServiceMap");
|
|
24
|
+
const extendDataStr = options.extendData === undefined
|
|
25
|
+
? undefined
|
|
26
|
+
: typeof options.extendData === "string"
|
|
27
|
+
? options.extendData
|
|
28
|
+
: JSON.stringify(options.extendData);
|
|
29
|
+
const params = {
|
|
30
|
+
calleeId: String(calleeId),
|
|
31
|
+
rtcpAddress: options.rtcpAddress ?? "",
|
|
32
|
+
rtpAddress: options.rtpAddress ?? "",
|
|
33
|
+
codec: options.codec ?? "[]",
|
|
34
|
+
session: options.session,
|
|
35
|
+
callId: options.callId,
|
|
36
|
+
imei: ctx.imei,
|
|
37
|
+
};
|
|
38
|
+
if (extendDataStr) {
|
|
39
|
+
params.extendData = extendDataStr;
|
|
40
|
+
params.subCommand = options.subCommand ?? 3;
|
|
41
|
+
}
|
|
42
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
43
|
+
if (!encryptedParams)
|
|
44
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt sendRequestVoiceCall params");
|
|
45
|
+
const url = utils.makeURL(`${voiceCallService}/api/voicecall/request`, {
|
|
46
|
+
zpw_type: 24,
|
|
47
|
+
params: encryptedParams,
|
|
48
|
+
});
|
|
49
|
+
const response = await utils.request(url, {
|
|
50
|
+
method: "GET",
|
|
51
|
+
});
|
|
52
|
+
return utils.resolve(response);
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
exports.sendRequestVoiceCallFactory = sendRequestVoiceCallFactory;
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var ZaloApiError = require('../../Errors/ZaloApiError.cjs');
|
|
4
|
+
var ZRTPPacketCodec = require('../../call-engine/ZRTPPacketCodec.cjs');
|
|
4
5
|
var utils = require('../../utils.cjs');
|
|
5
6
|
|
|
6
7
|
exports.CallType = void 0;
|
|
7
8
|
(function (CallType) {
|
|
8
9
|
CallType[CallType["Audio"] = 1] = "Audio";
|
|
9
10
|
CallType[CallType["Video"] = 3] = "Video";
|
|
11
|
+
CallType[CallType["GroupAudio"] = 5] = "GroupAudio";
|
|
12
|
+
CallType[CallType["GroupVideo"] = 6] = "GroupVideo";
|
|
10
13
|
})(exports.CallType || (exports.CallType = {}));
|
|
11
14
|
function parseServerEndpoint(addr) {
|
|
12
15
|
if (!addr)
|
|
@@ -35,7 +38,7 @@ const sendVoiceCallFactory = utils.apiFactory()((api, ctx, utils$1) => {
|
|
|
35
38
|
throw new ZaloApiError.ZaloApiError("Missing voice_call service URL in zpwServiceMap");
|
|
36
39
|
const callType = options.callType ?? exports.CallType.Audio;
|
|
37
40
|
const callId = options.callId ?? Math.floor(Math.random() * 2_000_000_000);
|
|
38
|
-
const codec = options.codec ??
|
|
41
|
+
const codec = options.codec ?? ZRTPPacketCodec.DEFAULT_ZALO_AUDIO_CODEC;
|
|
39
42
|
const normalizedCalleeId = String(calleeId);
|
|
40
43
|
// Step 1: Allocate call session & RTP/RTCP relay endpoints (/api/voicecall/requestcall, command 11300)
|
|
41
44
|
const step1Params = {
|
|
@@ -64,16 +67,15 @@ const sendVoiceCallFactory = utils.apiFactory()((api, ctx, utils$1) => {
|
|
|
64
67
|
const rtp = parseServerEndpoint(resolvedRtpServer);
|
|
65
68
|
const rtcp = parseServerEndpoint(resolvedRtcpServer);
|
|
66
69
|
const sessId = serverInfo?.sessId ?? `${normalizedCalleeId}_${callId}_401`;
|
|
67
|
-
const resolvedCodec = serverInfo?.codec
|
|
70
|
+
const resolvedCodec = serverInfo?.codec && serverInfo.codec !== "[]" ? serverInfo.codec : codec;
|
|
68
71
|
// Step 2: Send ringing signaling request (/api/voicecall/request, command 11301)
|
|
69
72
|
const isVideo = callType === exports.CallType.Video;
|
|
70
73
|
const extendData = JSON.stringify({
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
platform: 5,
|
|
74
|
+
...ZRTPPacketCodec.buildZrtcExtendData({
|
|
75
|
+
rtpAddress: rtp.host,
|
|
76
|
+
rtcpAddress: rtcp.host,
|
|
77
|
+
isVideo,
|
|
78
|
+
}),
|
|
77
79
|
rtcpDiff: 0,
|
|
78
80
|
rtcp: [{ ip: rtcp.ip, port: rtcp.port }],
|
|
79
81
|
rtp: [{ ip: rtp.ip, port: rtp.port }],
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const shareScreenGroupCallFactory = utils.apiFactory()((api, ctx, utils) => {
|
|
7
|
+
const voiceCallService = api.zpwServiceMap.voice_call?.[0];
|
|
8
|
+
/**
|
|
9
|
+
* Bật/tắt chia sẻ màn hình trong cuộc gọi nhóm (`/api/voicecall/group/sharescreen`, command `12044`).
|
|
10
|
+
*
|
|
11
|
+
* @param callId ID của cuộc gọi nhóm
|
|
12
|
+
* @param options Thông tin `hostCall`, `userId`, `status`, `audioState`, `videoState` và `data`
|
|
13
|
+
* @throws {ZaloApiError}
|
|
14
|
+
*/
|
|
15
|
+
return async function shareScreenGroupCall(callId, options) {
|
|
16
|
+
if (!callId)
|
|
17
|
+
throw new ZaloApiError.ZaloApiError("Missing callId");
|
|
18
|
+
if (!options?.hostCall)
|
|
19
|
+
throw new ZaloApiError.ZaloApiError("Missing hostCall");
|
|
20
|
+
if (!voiceCallService)
|
|
21
|
+
throw new ZaloApiError.ZaloApiError("Missing voice_call service URL in zpwServiceMap");
|
|
22
|
+
const dataStr = options.data === undefined
|
|
23
|
+
? "{}"
|
|
24
|
+
: typeof options.data === "string"
|
|
25
|
+
? options.data
|
|
26
|
+
: JSON.stringify(options.data);
|
|
27
|
+
const params = {
|
|
28
|
+
userId: String(options.userId ?? ctx.uid),
|
|
29
|
+
callId,
|
|
30
|
+
hostCall: String(options.hostCall),
|
|
31
|
+
status: options.status ?? 1,
|
|
32
|
+
audiostate: options.audioState ?? 1,
|
|
33
|
+
videostate: options.videoState ?? 1,
|
|
34
|
+
data: dataStr,
|
|
35
|
+
};
|
|
36
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
37
|
+
if (!encryptedParams)
|
|
38
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt shareScreenGroupCall params");
|
|
39
|
+
const url = utils.makeURL(`${voiceCallService}/api/voicecall/group/sharescreen`, {
|
|
40
|
+
zpw_type: 24,
|
|
41
|
+
params: encryptedParams,
|
|
42
|
+
});
|
|
43
|
+
const response = await utils.request(url, {
|
|
44
|
+
method: "GET",
|
|
45
|
+
});
|
|
46
|
+
return utils.resolve(response);
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
exports.shareScreenGroupCallFactory = shareScreenGroupCallFactory;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const unholdVoiceCallFactory = utils.apiFactory()((api, _ctx, utils) => {
|
|
7
|
+
const voiceCallService = api.zpwServiceMap.voice_call?.[0];
|
|
8
|
+
/**
|
|
9
|
+
* Gửi yêu cầu tiếp tục cuộc gọi đang tạm giữ (`/api/voicecall/unholdreq`, command `11309`, signal `413`)
|
|
10
|
+
* hoặc phản hồi tiếp tục cuộc gọi (`/api/voicecall/unholdresp`, command `11310`, signal `414`).
|
|
11
|
+
*
|
|
12
|
+
* @param toId User ID của đối phương trong cuộc gọi
|
|
13
|
+
* @param options Đặt `isResponse = true` nếu là gói phản hồi (`unholdresp`)
|
|
14
|
+
* @throws {ZaloApiError}
|
|
15
|
+
*/
|
|
16
|
+
return async function unholdVoiceCall(toId, options = {}) {
|
|
17
|
+
if (!toId)
|
|
18
|
+
throw new ZaloApiError.ZaloApiError("Missing toId");
|
|
19
|
+
if (!voiceCallService)
|
|
20
|
+
throw new ZaloApiError.ZaloApiError("Missing voice_call service URL in zpwServiceMap");
|
|
21
|
+
const params = {
|
|
22
|
+
toId: String(toId),
|
|
23
|
+
};
|
|
24
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
25
|
+
if (!encryptedParams)
|
|
26
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt unholdVoiceCall params");
|
|
27
|
+
const endpoint = options.isResponse ? "unholdresp" : "unholdreq";
|
|
28
|
+
const url = utils.makeURL(`${voiceCallService}/api/voicecall/${endpoint}`, {
|
|
29
|
+
zpw_type: 24,
|
|
30
|
+
params: encryptedParams,
|
|
31
|
+
});
|
|
32
|
+
const response = await utils.request(url, {
|
|
33
|
+
method: "GET",
|
|
34
|
+
});
|
|
35
|
+
return utils.resolve(response);
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
exports.unholdVoiceCallFactory = unholdVoiceCallFactory;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const updateCallMediaStateFactory = utils.apiFactory()((api, _ctx, utils) => {
|
|
7
|
+
const voiceCallService = api.zpwServiceMap.voice_call?.[0];
|
|
8
|
+
/**
|
|
9
|
+
* Đồng bộ trạng thái bật/tắt Camera và Microphone trong cuộc gọi 1-1 (`/api/voicecall/conf`, command `12006`).
|
|
10
|
+
* Khớp chính xác với `ZMessageSerializer::sendOnOffMicCam` (`0x100026cdc`):
|
|
11
|
+
* - Khi bật/tắt Camera (`UiOnOffCameraEvent`): `isOnCam = 1 | 0`, `isOnMic = -1`, `data = ""`
|
|
12
|
+
* - Khi bật/tắt Mic (`UiMuteEvent`): `isOnCam = -1`, `isOnMic = 1 | 0`, `data = ""`
|
|
13
|
+
*
|
|
14
|
+
* @param calleeId User ID của đối phương
|
|
15
|
+
* @param callId ID của cuộc gọi
|
|
16
|
+
* @param options Trạng thái `isOnCam`, `isOnMic` và `data` bổ sung
|
|
17
|
+
* @throws {ZaloApiError}
|
|
18
|
+
*/
|
|
19
|
+
return async function updateCallMediaState(calleeId, callId, options) {
|
|
20
|
+
if (!calleeId)
|
|
21
|
+
throw new ZaloApiError.ZaloApiError("Missing calleeId");
|
|
22
|
+
if (!callId)
|
|
23
|
+
throw new ZaloApiError.ZaloApiError("Missing callId");
|
|
24
|
+
if (!voiceCallService)
|
|
25
|
+
throw new ZaloApiError.ZaloApiError("Missing voice_call service URL in zpwServiceMap");
|
|
26
|
+
const dataStr = options.data === undefined
|
|
27
|
+
? ""
|
|
28
|
+
: typeof options.data === "string"
|
|
29
|
+
? options.data
|
|
30
|
+
: JSON.stringify(options.data);
|
|
31
|
+
const isOnCamVal = options.isOnCam === undefined
|
|
32
|
+
? -1
|
|
33
|
+
: typeof options.isOnCam === "boolean"
|
|
34
|
+
? options.isOnCam
|
|
35
|
+
? 1
|
|
36
|
+
: 0
|
|
37
|
+
: Number(options.isOnCam);
|
|
38
|
+
const isOnMicVal = options.isOnMic === undefined
|
|
39
|
+
? -1
|
|
40
|
+
: typeof options.isOnMic === "boolean"
|
|
41
|
+
? options.isOnMic
|
|
42
|
+
? 1
|
|
43
|
+
: 0
|
|
44
|
+
: Number(options.isOnMic);
|
|
45
|
+
const params = {
|
|
46
|
+
calleeId: String(calleeId),
|
|
47
|
+
callId,
|
|
48
|
+
isOnCam: isOnCamVal,
|
|
49
|
+
isOnMic: isOnMicVal,
|
|
50
|
+
data: dataStr,
|
|
51
|
+
};
|
|
52
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
53
|
+
if (!encryptedParams)
|
|
54
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt updateCallMediaState params");
|
|
55
|
+
const url = utils.makeURL(`${voiceCallService}/api/voicecall/conf`, {
|
|
56
|
+
zpw_type: 24,
|
|
57
|
+
params: encryptedParams,
|
|
58
|
+
});
|
|
59
|
+
const response = await utils.request(url, {
|
|
60
|
+
method: "GET",
|
|
61
|
+
});
|
|
62
|
+
return utils.resolve(response);
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
exports.updateCallMediaStateFactory = updateCallMediaStateFactory;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../../utils.cjs');
|
|
5
|
+
var wsCipher = require('../../crypto/ws-cipher.cjs');
|
|
6
|
+
|
|
7
|
+
const getDirectMessageStatusFactory = utils.apiFactory()((api, _ctx, utils) => {
|
|
8
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.chat[0]}/api/message/getStatusMsg`);
|
|
9
|
+
/**
|
|
10
|
+
* Truy vấn trạng thái Đã nhận (`deliver`) và Đã xem (`seen`) tin nhắn trong các hội thoại cá nhân 1-1 (command 12016)
|
|
11
|
+
*
|
|
12
|
+
* @param data Danh sách UID hoặc đối tượng truy vấn `{ tId }`
|
|
13
|
+
* @throws {ZaloApiError}
|
|
14
|
+
*/
|
|
15
|
+
return async function getDirectMessageStatus(data) {
|
|
16
|
+
if (!Array.isArray(data) || data.length === 0) {
|
|
17
|
+
throw new ZaloApiError.ZaloApiError("Missing data");
|
|
18
|
+
}
|
|
19
|
+
const formattedData = data.map((item) => (typeof item === "string" ? { tId: item } : item));
|
|
20
|
+
const params = {
|
|
21
|
+
param: JSON.stringify({
|
|
22
|
+
data: formattedData,
|
|
23
|
+
}),
|
|
24
|
+
};
|
|
25
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
26
|
+
if (!encryptedParams) {
|
|
27
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
|
|
28
|
+
}
|
|
29
|
+
const response = await utils.request(serviceURL, {
|
|
30
|
+
method: "POST",
|
|
31
|
+
body: new URLSearchParams({
|
|
32
|
+
params: encryptedParams,
|
|
33
|
+
}),
|
|
34
|
+
});
|
|
35
|
+
return utils.resolve(response, (result) => {
|
|
36
|
+
let rawData = result.data;
|
|
37
|
+
if (typeof rawData === "string" && rawData.length > 0) {
|
|
38
|
+
try {
|
|
39
|
+
const parsed = JSON.parse(wsCipher.preParseJsonIds(rawData));
|
|
40
|
+
rawData = "data" in parsed && parsed.data ? parsed.data : parsed;
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
// Giữ nguyên nếu không phải chuỗi JSON lồng
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (rawData && typeof rawData === "object") {
|
|
47
|
+
const obj = rawData;
|
|
48
|
+
return {
|
|
49
|
+
...obj,
|
|
50
|
+
statusInfos: Array.isArray(obj.statusInfos) ? obj.statusInfos : [],
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return { statusInfos: [] };
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
exports.getDirectMessageStatusFactory = getDirectMessageStatusFactory;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const getSuggestedConversationsFactory = utils.apiFactory()((api, ctx, utils) => {
|
|
7
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.conversation[0]}/api/suggestconvers/list`);
|
|
8
|
+
/**
|
|
9
|
+
* Lấy danh sách các cuộc hội thoại được gợi ý (command 11233)
|
|
10
|
+
*
|
|
11
|
+
* @param language Ngôn ngữ hiển thị (mặc định theo `ctx.language` hoặc `"vi"`)
|
|
12
|
+
* @throws {ZaloApiError}
|
|
13
|
+
*/
|
|
14
|
+
return async function getSuggestedConversations(language) {
|
|
15
|
+
const params = {
|
|
16
|
+
language: language ?? ctx.language ?? "vi",
|
|
17
|
+
};
|
|
18
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
19
|
+
if (!encryptedParams) {
|
|
20
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
|
|
21
|
+
}
|
|
22
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
|
|
23
|
+
method: "GET",
|
|
24
|
+
});
|
|
25
|
+
return utils.resolve(response);
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
exports.getSuggestedConversationsFactory = getSuggestedConversationsFactory;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const updatePinConversationsFactory = utils.apiFactory()((api, _ctx, utils) => {
|
|
7
|
+
const v1ServiceURL = utils.makeURL(`${api.zpwServiceMap.conversation[0]}/api/pinconvers/update`);
|
|
8
|
+
const v2ServiceURL = utils.makeURL(`${api.zpwServiceMap.conversation[0]}/api/pinconvers/updatev2`);
|
|
9
|
+
/**
|
|
10
|
+
* Cập nhật danh sách hội thoại ghim qua `/api/pinconvers/update` (command 12121) hoặc `/api/pinconvers/updatev2` (command 12122)
|
|
11
|
+
*
|
|
12
|
+
* @param options Cấu hình danh sách hội thoại ghim
|
|
13
|
+
* @throws {ZaloApiError}
|
|
14
|
+
*/
|
|
15
|
+
return async function updatePinConversations(options) {
|
|
16
|
+
if (!options || !Array.isArray(options.conversations)) {
|
|
17
|
+
throw new ZaloApiError.ZaloApiError("Missing conversations");
|
|
18
|
+
}
|
|
19
|
+
const useV2 = options.actionType !== undefined;
|
|
20
|
+
const targetURL = useV2 ? v2ServiceURL : v1ServiceURL;
|
|
21
|
+
const params = useV2
|
|
22
|
+
? {
|
|
23
|
+
actionType: options.actionType,
|
|
24
|
+
conversations: options.conversations,
|
|
25
|
+
tab: options.tab,
|
|
26
|
+
}
|
|
27
|
+
: {
|
|
28
|
+
version: options.version ?? 0,
|
|
29
|
+
conversations: options.conversations,
|
|
30
|
+
};
|
|
31
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
32
|
+
if (!encryptedParams) {
|
|
33
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
|
|
34
|
+
}
|
|
35
|
+
const response = await utils.request(targetURL, {
|
|
36
|
+
method: "POST",
|
|
37
|
+
body: new URLSearchParams({
|
|
38
|
+
params: encryptedParams,
|
|
39
|
+
}),
|
|
40
|
+
});
|
|
41
|
+
return utils.resolve(response);
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
exports.updatePinConversationsFactory = updatePinConversationsFactory;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const getFriendProfilesV2Factory = utils.apiFactory()((api, ctx, utils) => {
|
|
7
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.profile[0]}/api/social/friend/getprofiles/v2`);
|
|
8
|
+
/**
|
|
9
|
+
* Lấy hàng loạt hồ sơ chi tiết của danh sách bạn bè kèm trạng thái online qua `/api/social/friend/getprofiles/v2` (command 11140)
|
|
10
|
+
*
|
|
11
|
+
* @param friendIds Mảng UID cần lấy hồ sơ (có thể kèm hậu tố `_version` hoặc truyền UID thuần)
|
|
12
|
+
* @param options Tùy chọn truy vấn
|
|
13
|
+
* @throws {ZaloApiError}
|
|
14
|
+
*/
|
|
15
|
+
return async function getFriendProfilesV2(friendIds, options = {}) {
|
|
16
|
+
const rawIds = Array.isArray(friendIds) ? friendIds : [friendIds];
|
|
17
|
+
if (rawIds.length === 0) {
|
|
18
|
+
throw new ZaloApiError.ZaloApiError("Missing friendIds");
|
|
19
|
+
}
|
|
20
|
+
const friendPversionMap = rawIds.map((id) => (id.includes("_") ? id : `${id}_0`));
|
|
21
|
+
const params = {
|
|
22
|
+
phonebook_version: options.phonebookVersion ?? 0,
|
|
23
|
+
friend_pversion_map: friendPversionMap,
|
|
24
|
+
avatar_size: options.avatarSize ?? 120,
|
|
25
|
+
language: options.language ?? ctx.language ?? "vi",
|
|
26
|
+
show_online_status: options.showOnlineStatus !== false ? 1 : 0,
|
|
27
|
+
imei: ctx.imei,
|
|
28
|
+
};
|
|
29
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
30
|
+
if (!encryptedParams) {
|
|
31
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
|
|
32
|
+
}
|
|
33
|
+
const response = await utils.request(serviceURL, {
|
|
34
|
+
method: "POST",
|
|
35
|
+
body: new URLSearchParams({
|
|
36
|
+
params: encryptedParams,
|
|
37
|
+
}),
|
|
38
|
+
});
|
|
39
|
+
return utils.resolve(response);
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
exports.getFriendProfilesV2Factory = getFriendProfilesV2Factory;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var utils = require('../../utils.cjs');
|
|
4
|
+
|
|
5
|
+
const getFriendsActivePCWebFactory = utils.apiFactory()((api, _ctx, utils) => {
|
|
6
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.profile[0]}/api/social/friend/active-pcweb`);
|
|
7
|
+
/**
|
|
8
|
+
* Lấy danh sách bạn bè đang hoạt động trên Zalo PC / Web qua `/api/social/friend/active-pcweb` (command 12072)
|
|
9
|
+
*
|
|
10
|
+
* @throws {ZaloApiError}
|
|
11
|
+
*/
|
|
12
|
+
return async function getFriendsActivePCWeb() {
|
|
13
|
+
const response = await utils.request(serviceURL, {
|
|
14
|
+
method: "GET",
|
|
15
|
+
});
|
|
16
|
+
return utils.resolve(response);
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
exports.getFriendsActivePCWebFactory = getFriendsActivePCWebFactory;
|