@softtynet/zca-js 2.3.2 → 2.3.3
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/dist/apis/group/getGroupChatHistory.d.ts +37 -6
- package/dist/apis/group/getGroupChatHistory.js +41 -19
- package/dist/apis/group/getGroupHistoryLegacy.d.ts +7 -0
- package/dist/apis/group/getGroupHistoryLegacy.js +62 -0
- package/dist/apis/group/getGroupInfoV2.d.ts +30 -0
- package/dist/apis/group/getGroupInfoV2.js +48 -0
- package/dist/apis/group/getGroupListV3.d.ts +19 -0
- package/dist/apis/group/getGroupListV3.js +29 -0
- package/dist/apis/group/getGroupMessageStatus.d.ts +26 -0
- package/dist/apis/group/getGroupMessageStatus.js +77 -0
- package/dist/apis/media/getConversationMedia.d.ts +10 -0
- package/dist/apis.d.ts +12 -0
- package/dist/apis.js +20 -0
- package/dist/cjs/apis/group/getGroupChatHistory.cjs +43 -21
- package/dist/cjs/apis/group/getGroupHistoryLegacy.cjs +79 -0
- package/dist/cjs/apis/group/getGroupInfoV2.cjs +53 -0
- package/dist/cjs/apis/group/getGroupListV3.cjs +34 -0
- package/dist/cjs/apis/group/getGroupMessageStatus.cjs +82 -0
- package/dist/cjs/apis.cjs +20 -0
- package/dist/cjs/constants/endpoints.cjs +13 -0
- package/dist/cjs/constants/protocol.cjs +1 -1
- package/dist/cjs/index.cjs +2 -7
- package/dist/cjs/utils.cjs +65 -1
- package/dist/constants/endpoints.d.ts +13 -0
- package/dist/constants/endpoints.js +13 -0
- package/dist/constants/protocol.d.ts +1 -1
- package/dist/constants/protocol.js +1 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.js +1 -1
- package/dist/utils.d.ts +7 -0
- package/dist/utils.js +63 -1
- package/package.json +1 -1
|
@@ -1,18 +1,49 @@
|
|
|
1
1
|
import { GroupMessage } from "../../models/index.js";
|
|
2
|
+
export type GetGroupChatHistoryOptions = {
|
|
3
|
+
/**
|
|
4
|
+
* Số lượng tin nhắn cần tải (mặc định: `50`).
|
|
5
|
+
*/
|
|
6
|
+
count?: number;
|
|
7
|
+
/**
|
|
8
|
+
* Con trỏ `globalMsgId` (`lastMsgId` của trang trước) để phân trang lùi sâu về quá khứ (mặc định: `0`).
|
|
9
|
+
*/
|
|
10
|
+
cursor?: number | string;
|
|
11
|
+
/**
|
|
12
|
+
* Số trang tối đa được phép gọi trong một lần thực thi.
|
|
13
|
+
*/
|
|
14
|
+
maxPages?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Sử dụng endpoint `/api/cm/getoldv2` (command 12507) thay vì `/api/cm/getrecentv2` (command 12506).
|
|
17
|
+
*/
|
|
18
|
+
useOldEndpoint?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Danh sách `msgIds` cục bộ bổ sung (mặc định: `[]`).
|
|
21
|
+
*/
|
|
22
|
+
msgIds?: Array<string | number>;
|
|
23
|
+
/**
|
|
24
|
+
* Nguồn truy vấn (mặc định: `3`).
|
|
25
|
+
*/
|
|
26
|
+
src?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Cờ hội thoại OA (tùy chọn).
|
|
29
|
+
*/
|
|
30
|
+
isOA?: boolean;
|
|
31
|
+
};
|
|
2
32
|
export type GetGroupChatHistoryResponse = {
|
|
3
33
|
error?: number;
|
|
4
|
-
lastMsgId?: number;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
34
|
+
lastMsgId?: number | string;
|
|
35
|
+
nextCursor?: number | string;
|
|
36
|
+
minMsgId?: number | string;
|
|
37
|
+
maxMsgId?: number | string;
|
|
38
|
+
msgJumpId?: number | string;
|
|
8
39
|
hasMore?: boolean;
|
|
9
40
|
isOld?: boolean;
|
|
10
41
|
isFiltered?: boolean;
|
|
11
|
-
rootMsgId?: number;
|
|
42
|
+
rootMsgId?: number | string;
|
|
12
43
|
isRootDel?: boolean;
|
|
13
44
|
groupMsgs: GroupMessage[];
|
|
14
45
|
tsJoinGroup?: number;
|
|
15
46
|
isFilteredByPhase?: boolean;
|
|
16
47
|
isFilteredByTimeJoin?: boolean;
|
|
17
48
|
};
|
|
18
|
-
export declare const getGroupChatHistoryFactory: (ctx: import("../../context.js").ContextBase, api: import("../../apis.js").API) => (groupId: string,
|
|
49
|
+
export declare const getGroupChatHistoryFactory: (ctx: import("../../context.js").ContextBase, api: import("../../apis.js").API) => (groupId: string, countOrOptions?: number | GetGroupChatHistoryOptions) => Promise<GetGroupChatHistoryResponse>;
|
|
@@ -1,64 +1,86 @@
|
|
|
1
1
|
import { ZaloApiError } from "../../Errors/ZaloApiError.js";
|
|
2
|
-
import { apiFactory } from "../../utils.js";
|
|
2
|
+
import { apiFactory, preParseJsonIds } from "../../utils.js";
|
|
3
3
|
import { GroupMessage } from "../../models/index.js";
|
|
4
4
|
export const getGroupChatHistoryFactory = apiFactory()((api, ctx, utils) => {
|
|
5
|
-
const
|
|
5
|
+
const recentServiceURL = utils.makeURL(`${api.zpwServiceMap.group_cloud_message[0]}/api/cm/getrecentv2`);
|
|
6
|
+
const oldServiceURL = utils.makeURL(`${api.zpwServiceMap.group_cloud_message[0]}/api/cm/getoldv2`);
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
+
* Lấy lịch sử tin nhắn nhóm từ Zalo Cloud Message (hỗ trợ cả `/api/cm/getrecentv2` cmd 12506 và `/api/cm/getoldv2` cmd 12507)
|
|
8
9
|
*
|
|
9
|
-
* @param groupId
|
|
10
|
-
* @param
|
|
10
|
+
* @param groupId ID nhóm
|
|
11
|
+
* @param countOrOptions Số lượng tin nhắn cần tải (mặc định: `50`) hoặc đối tượng cấu hình phân trang `GetGroupChatHistoryOptions`
|
|
11
12
|
*
|
|
12
13
|
* @throws {ZaloApiError}
|
|
13
14
|
*/
|
|
14
|
-
return async function getGroupChatHistory(groupId,
|
|
15
|
+
return async function getGroupChatHistory(groupId, countOrOptions = 50) {
|
|
15
16
|
if (!groupId)
|
|
16
17
|
throw new ZaloApiError("Missing groupId");
|
|
17
18
|
if (groupId.startsWith("g"))
|
|
18
19
|
groupId = groupId.slice(1);
|
|
19
|
-
const
|
|
20
|
+
const options = typeof countOrOptions === "number" ? { count: countOrOptions } : countOrOptions || {};
|
|
21
|
+
const requestedCount = Math.max(options.count ?? 50, 1);
|
|
22
|
+
const maxPages = options.maxPages ?? Math.max(10, Math.ceil(requestedCount / 50) + 2);
|
|
23
|
+
const targetServiceURL = options.useOldEndpoint ? oldServiceURL : recentServiceURL;
|
|
24
|
+
const msgIds = options.msgIds ?? [];
|
|
25
|
+
const src = options.src ?? 3;
|
|
20
26
|
const messages = [];
|
|
21
|
-
|
|
27
|
+
const seenMsgIds = new Set();
|
|
28
|
+
let cursor = options.cursor ?? 0;
|
|
22
29
|
let lastPage = null;
|
|
23
30
|
let pageCount = 0;
|
|
24
|
-
while (messages.length <
|
|
31
|
+
while (messages.length < requestedCount && pageCount < maxPages) {
|
|
25
32
|
pageCount++;
|
|
26
33
|
const params = {
|
|
27
34
|
groupId,
|
|
28
35
|
globalMsgId: cursor,
|
|
29
|
-
count: Math.min(50,
|
|
30
|
-
msgIds
|
|
36
|
+
count: Math.min(50, requestedCount - messages.length),
|
|
37
|
+
msgIds,
|
|
31
38
|
imei: ctx.imei,
|
|
32
|
-
src
|
|
39
|
+
src,
|
|
33
40
|
};
|
|
41
|
+
if (options.isOA) {
|
|
42
|
+
params.isOA = 1;
|
|
43
|
+
}
|
|
34
44
|
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
35
45
|
if (!encryptedParams)
|
|
36
46
|
throw new ZaloApiError("Failed to encrypt params");
|
|
37
|
-
const response = await utils.request(utils.makeURL(
|
|
47
|
+
const response = await utils.request(utils.makeURL(targetServiceURL, { params: encryptedParams, nretry: 0 }), {
|
|
38
48
|
method: "GET",
|
|
39
49
|
});
|
|
40
50
|
lastPage = await utils.resolve(response, (result) => {
|
|
41
51
|
let data = result.data;
|
|
42
52
|
if (typeof data === "string") {
|
|
43
|
-
data = JSON.parse(data);
|
|
53
|
+
data = JSON.parse(preParseJsonIds(data));
|
|
44
54
|
}
|
|
45
55
|
return data;
|
|
46
56
|
});
|
|
47
57
|
if (!lastPage || !Array.isArray(lastPage.groupMsgs))
|
|
48
58
|
break;
|
|
49
59
|
for (const rawMsg of lastPage.groupMsgs) {
|
|
50
|
-
if (messages.length >=
|
|
60
|
+
if (messages.length >= requestedCount)
|
|
51
61
|
break;
|
|
52
|
-
|
|
62
|
+
const msgIdKey = String(rawMsg.msgId ?? rawMsg.cliMsgId ?? "");
|
|
63
|
+
if (msgIdKey && seenMsgIds.has(msgIdKey))
|
|
53
64
|
continue;
|
|
65
|
+
if (msgIdKey)
|
|
66
|
+
seenMsgIds.add(msgIdKey);
|
|
54
67
|
messages.push(rawMsg);
|
|
55
68
|
}
|
|
56
|
-
const nextCursor =
|
|
57
|
-
if (!lastPage.hasMore ||
|
|
69
|
+
const nextCursor = lastPage.lastMsgId;
|
|
70
|
+
if (!lastPage.hasMore ||
|
|
71
|
+
nextCursor === undefined ||
|
|
72
|
+
nextCursor === null ||
|
|
73
|
+
nextCursor === "" ||
|
|
74
|
+
nextCursor === 0 ||
|
|
75
|
+
String(nextCursor) === String(cursor)) {
|
|
58
76
|
break;
|
|
77
|
+
}
|
|
59
78
|
cursor = nextCursor;
|
|
60
79
|
}
|
|
61
80
|
const groupMsgs = messages.map((data) => new GroupMessage(ctx.uid, data));
|
|
62
|
-
return Object.assign({}, lastPage || {}, {
|
|
81
|
+
return Object.assign({}, lastPage || {}, {
|
|
82
|
+
groupMsgs,
|
|
83
|
+
nextCursor: lastPage?.lastMsgId,
|
|
84
|
+
});
|
|
63
85
|
};
|
|
64
86
|
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { GroupMessage } from "../../models/index.js";
|
|
2
|
+
export type GetGroupHistoryLegacyResponse = {
|
|
3
|
+
groupMsgs?: GroupMessage[];
|
|
4
|
+
msgs?: GroupMessage[];
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
};
|
|
7
|
+
export declare const getGroupHistoryLegacyFactory: (ctx: import("../../context.js").ContextBase, api: import("../../apis.js").API) => (groupId: string, count?: number) => Promise<GetGroupHistoryLegacyResponse>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ZaloApiError } from "../../Errors/ZaloApiError.js";
|
|
2
|
+
import { GroupMessage } from "../../models/index.js";
|
|
3
|
+
import { apiFactory, preParseJsonIds } from "../../utils.js";
|
|
4
|
+
export const getGroupHistoryLegacyFactory = apiFactory()((api, ctx, utils) => {
|
|
5
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.group[0]}/api/group/history`);
|
|
6
|
+
/**
|
|
7
|
+
* Lấy lịch sử tin nhắn nhóm qua endpoint `/api/group/history` trên miền `group` (command 11240)
|
|
8
|
+
*
|
|
9
|
+
* @param groupId ID của nhóm
|
|
10
|
+
* @param count Số lượng tin nhắn cần tải (mặc định: `20`)
|
|
11
|
+
* @throws {ZaloApiError}
|
|
12
|
+
*/
|
|
13
|
+
return async function getGroupHistoryLegacy(groupId, count = 20) {
|
|
14
|
+
if (!groupId) {
|
|
15
|
+
throw new ZaloApiError("Missing groupId");
|
|
16
|
+
}
|
|
17
|
+
const cleanGroupId = groupId.startsWith("g") ? groupId.slice(1) : groupId;
|
|
18
|
+
const params = {
|
|
19
|
+
grid: cleanGroupId,
|
|
20
|
+
count,
|
|
21
|
+
};
|
|
22
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
23
|
+
if (!encryptedParams) {
|
|
24
|
+
throw new ZaloApiError("Failed to encrypt params");
|
|
25
|
+
}
|
|
26
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
|
|
27
|
+
method: "GET",
|
|
28
|
+
});
|
|
29
|
+
return utils.resolve(response, (result) => {
|
|
30
|
+
let data = result.data;
|
|
31
|
+
if (typeof data === "string") {
|
|
32
|
+
try {
|
|
33
|
+
data = JSON.parse(preParseJsonIds(data));
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
data = {};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (Array.isArray(data)) {
|
|
40
|
+
const groupMsgs = data.map((m) => new GroupMessage(ctx.uid, m));
|
|
41
|
+
return { groupMsgs };
|
|
42
|
+
}
|
|
43
|
+
if (data && typeof data === "object") {
|
|
44
|
+
const obj = data;
|
|
45
|
+
const rawList = Array.isArray(obj.groupMsgs)
|
|
46
|
+
? obj.groupMsgs
|
|
47
|
+
: Array.isArray(obj.msgs)
|
|
48
|
+
? obj.msgs
|
|
49
|
+
: null;
|
|
50
|
+
if (rawList) {
|
|
51
|
+
const groupMsgs = rawList.map((m) => new GroupMessage(ctx.uid, m));
|
|
52
|
+
return {
|
|
53
|
+
...obj,
|
|
54
|
+
groupMsgs,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return obj;
|
|
58
|
+
}
|
|
59
|
+
return { groupMsgs: [] };
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { GroupCurrentMem, GroupInfo } from "../../models/index.js";
|
|
2
|
+
import type { GroupInfoPendingApprove } from "./getGroupInfo.js";
|
|
3
|
+
export type GetGroupInfoV2Options = {
|
|
4
|
+
/**
|
|
5
|
+
* Trang thành viên cần lấy (mặc định: `1`).
|
|
6
|
+
*/
|
|
7
|
+
mpage?: number;
|
|
8
|
+
/**
|
|
9
|
+
* Số lượng thành viên mỗi trang (mặc định: `100`).
|
|
10
|
+
*/
|
|
11
|
+
mcount?: number;
|
|
12
|
+
/**
|
|
13
|
+
* Kích thước ảnh đại diện nhóm (mặc định: `120`).
|
|
14
|
+
*/
|
|
15
|
+
avatarSize?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Kích thước ảnh đại diện thành viên (mặc định: `120`).
|
|
18
|
+
*/
|
|
19
|
+
memberAvatarSize?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Sử dụng endpoint `/api/group/getgi` (bản V1) thay vì `/api/group/getgi/v2` (mặc định: `false`).
|
|
22
|
+
*/
|
|
23
|
+
useV1Endpoint?: boolean;
|
|
24
|
+
};
|
|
25
|
+
export type GetGroupInfoV2Response = GroupInfo & {
|
|
26
|
+
admins?: GroupCurrentMem[];
|
|
27
|
+
pendingApprove?: GroupInfoPendingApprove;
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
};
|
|
30
|
+
export declare const getGroupInfoV2Factory: (ctx: import("../../context.js").ContextBase, api: import("../../apis.js").API) => (groupId: string, pageOrOptions?: number | GetGroupInfoV2Options) => Promise<GetGroupInfoV2Response>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ZaloApiError } from "../../Errors/ZaloApiError.js";
|
|
2
|
+
import { apiFactory } from "../../utils.js";
|
|
3
|
+
export const getGroupInfoV2Factory = apiFactory()((api, ctx, utils) => {
|
|
4
|
+
const v2ServiceURL = utils.makeURL(`${api.zpwServiceMap.group[0]}/api/group/getgi/v2`);
|
|
5
|
+
const v1ServiceURL = utils.makeURL(`${api.zpwServiceMap.group[0]}/api/group/getgi`);
|
|
6
|
+
/**
|
|
7
|
+
* Lấy thông tin nhóm và danh sách thành viên theo trang qua `/api/group/getgi/v2` hoặc `/api/group/getgi` (command 11162)
|
|
8
|
+
*
|
|
9
|
+
* @param groupId ID của nhóm
|
|
10
|
+
* @param pageOrOptions Số trang `mpage` (mặc định: `1`) hoặc cấu hình `GetGroupInfoV2Options`
|
|
11
|
+
* @throws {ZaloApiError}
|
|
12
|
+
*/
|
|
13
|
+
return async function getGroupInfoV2(groupId, pageOrOptions = 1) {
|
|
14
|
+
if (!groupId) {
|
|
15
|
+
throw new ZaloApiError("Missing groupId");
|
|
16
|
+
}
|
|
17
|
+
const cleanGroupId = groupId.startsWith("g") ? groupId.slice(1) : groupId;
|
|
18
|
+
const options = typeof pageOrOptions === "number" ? { mpage: pageOrOptions } : pageOrOptions || {};
|
|
19
|
+
const mpage = options.mpage ?? 1;
|
|
20
|
+
const mcount = options.mcount ?? 100;
|
|
21
|
+
const avatarSize = options.avatarSize ?? 120;
|
|
22
|
+
const memberAvatarSize = options.memberAvatarSize ?? 120;
|
|
23
|
+
const useV1 = Boolean(options.useV1Endpoint);
|
|
24
|
+
const targetURL = useV1 ? v1ServiceURL : v2ServiceURL;
|
|
25
|
+
const params = useV1
|
|
26
|
+
? {
|
|
27
|
+
grid: cleanGroupId,
|
|
28
|
+
avatar_size: avatarSize,
|
|
29
|
+
member_avatar_size: memberAvatarSize,
|
|
30
|
+
}
|
|
31
|
+
: {
|
|
32
|
+
grid: cleanGroupId,
|
|
33
|
+
avatar_size: avatarSize,
|
|
34
|
+
member_avatar_size: memberAvatarSize,
|
|
35
|
+
mpage,
|
|
36
|
+
mcount,
|
|
37
|
+
imei: ctx.imei,
|
|
38
|
+
};
|
|
39
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
40
|
+
if (!encryptedParams) {
|
|
41
|
+
throw new ZaloApiError("Failed to encrypt params");
|
|
42
|
+
}
|
|
43
|
+
const response = await utils.request(utils.makeURL(targetURL, { params: encryptedParams }), {
|
|
44
|
+
method: "GET",
|
|
45
|
+
});
|
|
46
|
+
return utils.resolve(response);
|
|
47
|
+
};
|
|
48
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { GroupInfo } from "../../models/index.js";
|
|
2
|
+
export type GetGroupListV3Options = {
|
|
3
|
+
/**
|
|
4
|
+
* Số trang cần lấy (mặc định: `1`).
|
|
5
|
+
*/
|
|
6
|
+
page?: number;
|
|
7
|
+
/**
|
|
8
|
+
* Số lượng nhóm mỗi trang (mặc định: `100`).
|
|
9
|
+
*/
|
|
10
|
+
count?: number;
|
|
11
|
+
};
|
|
12
|
+
export type GetGroupListV3Response = {
|
|
13
|
+
groups: GroupInfo[];
|
|
14
|
+
hasMore?: number | boolean;
|
|
15
|
+
total?: number;
|
|
16
|
+
suggestGroup?: unknown;
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
};
|
|
19
|
+
export declare const getGroupListV3Factory: (ctx: import("../../context.js").ContextBase, api: import("../../apis.js").API) => (pageOrOptions?: number | GetGroupListV3Options) => Promise<GetGroupListV3Response>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ZaloApiError } from "../../Errors/ZaloApiError.js";
|
|
2
|
+
import { apiFactory } from "../../utils.js";
|
|
3
|
+
export const getGroupListV3Factory = apiFactory()((api, ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.group[0]}/api/group/getlg/v3`);
|
|
5
|
+
/**
|
|
6
|
+
* Lấy danh sách nhóm theo trang kèm thông tin thành viên đại diện (`currentMems`) và gợi ý nhóm (`suggestGroup`) qua `/api/group/getlg/v3` (command 11161)
|
|
7
|
+
*
|
|
8
|
+
* @param pageOrOptions Số trang (mặc định: `1`) hoặc cấu hình `GetGroupListV3Options`
|
|
9
|
+
* @throws {ZaloApiError}
|
|
10
|
+
*/
|
|
11
|
+
return async function getGroupListV3(pageOrOptions = 1) {
|
|
12
|
+
const options = typeof pageOrOptions === "number" ? { page: pageOrOptions } : pageOrOptions || {};
|
|
13
|
+
const params = {
|
|
14
|
+
page: options.page ?? 1,
|
|
15
|
+
count: options.count ?? 100,
|
|
16
|
+
avatar_size: 120,
|
|
17
|
+
member_avatar_size: 120,
|
|
18
|
+
imei: ctx.imei,
|
|
19
|
+
};
|
|
20
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
21
|
+
if (!encryptedParams) {
|
|
22
|
+
throw new ZaloApiError("Failed to encrypt params");
|
|
23
|
+
}
|
|
24
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
|
|
25
|
+
method: "GET",
|
|
26
|
+
});
|
|
27
|
+
return utils.resolve(response);
|
|
28
|
+
};
|
|
29
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type GroupMessageStatusMemberItem = {
|
|
2
|
+
id: string;
|
|
3
|
+
seen?: string | number;
|
|
4
|
+
deliver?: string | number;
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
};
|
|
7
|
+
export type GroupMessageStatusThreadInfo = {
|
|
8
|
+
tId?: string;
|
|
9
|
+
ids: GroupMessageStatusMemberItem[];
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
};
|
|
12
|
+
export type GetGroupMessageStatusQueryItem = {
|
|
13
|
+
/**
|
|
14
|
+
* ID nhóm (không có tiền tố `g`).
|
|
15
|
+
*/
|
|
16
|
+
tId: string;
|
|
17
|
+
/**
|
|
18
|
+
* Danh sách UID thành viên cần truy vấn trạng thái `seen` / `deliver` trong nhóm.
|
|
19
|
+
*/
|
|
20
|
+
ids: string[];
|
|
21
|
+
};
|
|
22
|
+
export type GetGroupMessageStatusResponse = {
|
|
23
|
+
statusInfos: GroupMessageStatusThreadInfo[];
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
};
|
|
26
|
+
export declare const getGroupMessageStatusFactory: (ctx: import("../../context.js").ContextBase, api: import("../../apis.js").API) => (groupIdOrItems: string | GetGroupMessageStatusQueryItem[], memberIds?: string[]) => Promise<GetGroupMessageStatusResponse>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { ZaloApiError } from "../../Errors/ZaloApiError.js";
|
|
2
|
+
import { apiFactory, preParseJsonIds } from "../../utils.js";
|
|
3
|
+
export const getGroupMessageStatusFactory = apiFactory()((api, _ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.group[0]}/api/group/getStatusMsg`);
|
|
5
|
+
/**
|
|
6
|
+
* Truy vấn trạng thái Đã nhận (`deliver`) và Đã xem (`seen`) tin nhắn của danh sách thành viên trong nhóm (command 12017)
|
|
7
|
+
*
|
|
8
|
+
* @param groupIdOrItems ID nhóm (hoặc mảng cấu hình `{ tId, ids }`)
|
|
9
|
+
* @param memberIds Danh sách UID thành viên cần kiểm tra (khi tham số đầu là `groupId`)
|
|
10
|
+
* @throws {ZaloApiError}
|
|
11
|
+
*/
|
|
12
|
+
return async function getGroupMessageStatus(groupIdOrItems, memberIds = []) {
|
|
13
|
+
let queryData;
|
|
14
|
+
if (Array.isArray(groupIdOrItems)) {
|
|
15
|
+
queryData = groupIdOrItems.map((item) => ({
|
|
16
|
+
tId: item.tId.startsWith("g") ? item.tId.slice(1) : item.tId,
|
|
17
|
+
ids: item.ids.map(String),
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
if (!groupIdOrItems) {
|
|
22
|
+
throw new ZaloApiError("Missing groupId");
|
|
23
|
+
}
|
|
24
|
+
const cleanGroupId = groupIdOrItems.startsWith("g") ? groupIdOrItems.slice(1) : groupIdOrItems;
|
|
25
|
+
queryData = [
|
|
26
|
+
{
|
|
27
|
+
tId: cleanGroupId,
|
|
28
|
+
ids: memberIds.map(String),
|
|
29
|
+
},
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
const params = {
|
|
33
|
+
param: JSON.stringify({
|
|
34
|
+
data: queryData,
|
|
35
|
+
}),
|
|
36
|
+
};
|
|
37
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
38
|
+
if (!encryptedParams) {
|
|
39
|
+
throw new ZaloApiError("Failed to encrypt params");
|
|
40
|
+
}
|
|
41
|
+
const response = await utils.request(serviceURL, {
|
|
42
|
+
method: "POST",
|
|
43
|
+
body: new URLSearchParams({
|
|
44
|
+
params: encryptedParams,
|
|
45
|
+
}),
|
|
46
|
+
});
|
|
47
|
+
return utils.resolve(response, (result) => {
|
|
48
|
+
let rawData = result.data;
|
|
49
|
+
if (typeof rawData === "string" && rawData.length > 0) {
|
|
50
|
+
try {
|
|
51
|
+
const parsed = JSON.parse(preParseJsonIds(rawData));
|
|
52
|
+
if (parsed && typeof parsed === "object" && "data" in parsed && parsed.data) {
|
|
53
|
+
rawData = parsed.data;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
rawData = parsed;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
// Giữ nguyên nếu không phải chuỗi JSON lồng
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (rawData && typeof rawData === "object") {
|
|
64
|
+
const obj = rawData;
|
|
65
|
+
if (Array.isArray(obj.statusInfos)) {
|
|
66
|
+
return obj;
|
|
67
|
+
}
|
|
68
|
+
if (obj.data && typeof obj.data === "object" && Array.isArray(obj.data.statusInfos)) {
|
|
69
|
+
return obj.data;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
statusInfos: Array.isArray(rawData) ? rawData : [],
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
});
|
|
@@ -10,11 +10,21 @@ export type GetConversationMediaOptions = {
|
|
|
10
10
|
export type MediaStoreItem = {
|
|
11
11
|
id: number | string;
|
|
12
12
|
type: string;
|
|
13
|
+
sub_type?: number;
|
|
14
|
+
owner_id?: string;
|
|
15
|
+
group_id?: string;
|
|
16
|
+
global_msg_id?: string | number;
|
|
17
|
+
client_msg_id?: string | number;
|
|
13
18
|
title?: string;
|
|
14
19
|
src_url?: string;
|
|
15
20
|
thumb_url?: string;
|
|
16
21
|
previewThumb?: string | null;
|
|
17
22
|
created_time?: number;
|
|
23
|
+
file_size?: number;
|
|
24
|
+
checksum?: string;
|
|
25
|
+
width?: number;
|
|
26
|
+
height?: number;
|
|
27
|
+
duration?: number;
|
|
18
28
|
[key: string]: unknown;
|
|
19
29
|
};
|
|
20
30
|
export type GetConversationMediaResponse = {
|
package/dist/apis.d.ts
CHANGED
|
@@ -80,12 +80,16 @@ import { getFullAvatarFactory } from "./apis/profile/getFullAvatar.js";
|
|
|
80
80
|
import { getGroupBlockedMemberFactory } from "./apis/group/getGroupBlockedMember.js";
|
|
81
81
|
import { getGroupChatHistoryFactory } from "./apis/group/getGroupChatHistory.js";
|
|
82
82
|
import { getGroupCloudMessageJumpFactory } from "./apis/group/getGroupCloudMessageJump.js";
|
|
83
|
+
import { getGroupHistoryLegacyFactory } from "./apis/group/getGroupHistoryLegacy.js";
|
|
83
84
|
import { getGroupInfoFactory } from "./apis/group/getGroupInfo.js";
|
|
85
|
+
import { getGroupInfoV2Factory } from "./apis/group/getGroupInfoV2.js";
|
|
84
86
|
import { getGroupInviteBoxInfoFactory } from "./apis/group/getGroupInviteBoxInfo.js";
|
|
85
87
|
import { getGroupInviteBoxListFactory } from "./apis/group/getGroupInviteBoxList.js";
|
|
86
88
|
import { getGroupLinkDetailFactory } from "./apis/group/getGroupLinkDetail.js";
|
|
87
89
|
import { getGroupLinkInfoFactory } from "./apis/group/getGroupLinkInfo.js";
|
|
90
|
+
import { getGroupListV3Factory } from "./apis/group/getGroupListV3.js";
|
|
88
91
|
import { getGroupMembersInfoFactory } from "./apis/group/getGroupMembersInfo.js";
|
|
92
|
+
import { getGroupMessageStatusFactory } from "./apis/group/getGroupMessageStatus.js";
|
|
89
93
|
import { getHiddenConversationsFactory } from "./apis/chat/getHiddenConversations.js";
|
|
90
94
|
import { getLabelsFactory } from "./apis/business/getLabels.js";
|
|
91
95
|
import { getLastReadContactTabFactory } from "./apis/friend/getLastReadContactTab.js";
|
|
@@ -362,12 +366,16 @@ export type GroupDomainAPI = {
|
|
|
362
366
|
readonly getGroupBlockedMember: ReturnType<typeof getGroupBlockedMemberFactory>;
|
|
363
367
|
readonly getGroupChatHistory: ReturnType<typeof getGroupChatHistoryFactory>;
|
|
364
368
|
readonly getGroupCloudMessageJump: ReturnType<typeof getGroupCloudMessageJumpFactory>;
|
|
369
|
+
readonly getGroupHistoryLegacy: ReturnType<typeof getGroupHistoryLegacyFactory>;
|
|
365
370
|
readonly getGroupInfo: ReturnType<typeof getGroupInfoFactory>;
|
|
371
|
+
readonly getGroupInfoV2: ReturnType<typeof getGroupInfoV2Factory>;
|
|
366
372
|
readonly getGroupInviteBoxInfo: ReturnType<typeof getGroupInviteBoxInfoFactory>;
|
|
367
373
|
readonly getGroupInviteBoxList: ReturnType<typeof getGroupInviteBoxListFactory>;
|
|
368
374
|
readonly getGroupLinkDetail: ReturnType<typeof getGroupLinkDetailFactory>;
|
|
369
375
|
readonly getGroupLinkInfo: ReturnType<typeof getGroupLinkInfoFactory>;
|
|
376
|
+
readonly getGroupListV3: ReturnType<typeof getGroupListV3Factory>;
|
|
370
377
|
readonly getGroupMembersInfo: ReturnType<typeof getGroupMembersInfoFactory>;
|
|
378
|
+
readonly getGroupMessageStatus: ReturnType<typeof getGroupMessageStatusFactory>;
|
|
371
379
|
readonly getPendingGroupMembers: ReturnType<typeof getPendingGroupMembersFactory>;
|
|
372
380
|
readonly getQuotaCommunity: ReturnType<typeof getQuotaCommunityFactory>;
|
|
373
381
|
readonly getRelatedFriendGroup: ReturnType<typeof getRelatedFriendGroupFactory>;
|
|
@@ -538,12 +546,16 @@ export declare class API {
|
|
|
538
546
|
get getGroupBlockedMember(): ReturnType<typeof getGroupBlockedMemberFactory>;
|
|
539
547
|
get getGroupChatHistory(): ReturnType<typeof getGroupChatHistoryFactory>;
|
|
540
548
|
get getGroupCloudMessageJump(): ReturnType<typeof getGroupCloudMessageJumpFactory>;
|
|
549
|
+
get getGroupHistoryLegacy(): ReturnType<typeof getGroupHistoryLegacyFactory>;
|
|
541
550
|
get getGroupInfo(): ReturnType<typeof getGroupInfoFactory>;
|
|
551
|
+
get getGroupInfoV2(): ReturnType<typeof getGroupInfoV2Factory>;
|
|
542
552
|
get getGroupInviteBoxInfo(): ReturnType<typeof getGroupInviteBoxInfoFactory>;
|
|
543
553
|
get getGroupInviteBoxList(): ReturnType<typeof getGroupInviteBoxListFactory>;
|
|
544
554
|
get getGroupLinkDetail(): ReturnType<typeof getGroupLinkDetailFactory>;
|
|
545
555
|
get getGroupLinkInfo(): ReturnType<typeof getGroupLinkInfoFactory>;
|
|
556
|
+
get getGroupListV3(): ReturnType<typeof getGroupListV3Factory>;
|
|
546
557
|
get getGroupMembersInfo(): ReturnType<typeof getGroupMembersInfoFactory>;
|
|
558
|
+
get getGroupMessageStatus(): ReturnType<typeof getGroupMessageStatusFactory>;
|
|
547
559
|
get getHiddenConversations(): ReturnType<typeof getHiddenConversationsFactory>;
|
|
548
560
|
get getLabels(): ReturnType<typeof getLabelsFactory>;
|
|
549
561
|
get getLastReadContactTab(): ReturnType<typeof getLastReadContactTabFactory>;
|
package/dist/apis.js
CHANGED
|
@@ -80,12 +80,16 @@ import { getFullAvatarFactory } from "./apis/profile/getFullAvatar.js";
|
|
|
80
80
|
import { getGroupBlockedMemberFactory } from "./apis/group/getGroupBlockedMember.js";
|
|
81
81
|
import { getGroupChatHistoryFactory } from "./apis/group/getGroupChatHistory.js";
|
|
82
82
|
import { getGroupCloudMessageJumpFactory } from "./apis/group/getGroupCloudMessageJump.js";
|
|
83
|
+
import { getGroupHistoryLegacyFactory } from "./apis/group/getGroupHistoryLegacy.js";
|
|
83
84
|
import { getGroupInfoFactory } from "./apis/group/getGroupInfo.js";
|
|
85
|
+
import { getGroupInfoV2Factory } from "./apis/group/getGroupInfoV2.js";
|
|
84
86
|
import { getGroupInviteBoxInfoFactory } from "./apis/group/getGroupInviteBoxInfo.js";
|
|
85
87
|
import { getGroupInviteBoxListFactory } from "./apis/group/getGroupInviteBoxList.js";
|
|
86
88
|
import { getGroupLinkDetailFactory } from "./apis/group/getGroupLinkDetail.js";
|
|
87
89
|
import { getGroupLinkInfoFactory } from "./apis/group/getGroupLinkInfo.js";
|
|
90
|
+
import { getGroupListV3Factory } from "./apis/group/getGroupListV3.js";
|
|
88
91
|
import { getGroupMembersInfoFactory } from "./apis/group/getGroupMembersInfo.js";
|
|
92
|
+
import { getGroupMessageStatusFactory } from "./apis/group/getGroupMessageStatus.js";
|
|
89
93
|
import { getHiddenConversationsFactory } from "./apis/chat/getHiddenConversations.js";
|
|
90
94
|
import { getLabelsFactory } from "./apis/business/getLabels.js";
|
|
91
95
|
import { getLastReadContactTabFactory } from "./apis/friend/getLastReadContactTab.js";
|
|
@@ -415,12 +419,16 @@ export class API {
|
|
|
415
419
|
get getGroupBlockedMember() { return api.getGroupBlockedMember; },
|
|
416
420
|
get getGroupChatHistory() { return api.getGroupChatHistory; },
|
|
417
421
|
get getGroupCloudMessageJump() { return api.getGroupCloudMessageJump; },
|
|
422
|
+
get getGroupHistoryLegacy() { return api.getGroupHistoryLegacy; },
|
|
418
423
|
get getGroupInfo() { return api.getGroupInfo; },
|
|
424
|
+
get getGroupInfoV2() { return api.getGroupInfoV2; },
|
|
419
425
|
get getGroupInviteBoxInfo() { return api.getGroupInviteBoxInfo; },
|
|
420
426
|
get getGroupInviteBoxList() { return api.getGroupInviteBoxList; },
|
|
421
427
|
get getGroupLinkDetail() { return api.getGroupLinkDetail; },
|
|
422
428
|
get getGroupLinkInfo() { return api.getGroupLinkInfo; },
|
|
429
|
+
get getGroupListV3() { return api.getGroupListV3; },
|
|
423
430
|
get getGroupMembersInfo() { return api.getGroupMembersInfo; },
|
|
431
|
+
get getGroupMessageStatus() { return api.getGroupMessageStatus; },
|
|
424
432
|
get getPendingGroupMembers() { return api.getPendingGroupMembers; },
|
|
425
433
|
get getQuotaCommunity() { return api.getQuotaCommunity; },
|
|
426
434
|
get getRelatedFriendGroup() { return api.getRelatedFriendGroup; },
|
|
@@ -770,9 +778,15 @@ export class API {
|
|
|
770
778
|
get getGroupCloudMessageJump() {
|
|
771
779
|
return (this._cache.getGroupCloudMessageJump ??= getGroupCloudMessageJumpFactory(this.ctx, this));
|
|
772
780
|
}
|
|
781
|
+
get getGroupHistoryLegacy() {
|
|
782
|
+
return (this._cache.getGroupHistoryLegacy ??= getGroupHistoryLegacyFactory(this.ctx, this));
|
|
783
|
+
}
|
|
773
784
|
get getGroupInfo() {
|
|
774
785
|
return (this._cache.getGroupInfo ??= getGroupInfoFactory(this.ctx, this));
|
|
775
786
|
}
|
|
787
|
+
get getGroupInfoV2() {
|
|
788
|
+
return (this._cache.getGroupInfoV2 ??= getGroupInfoV2Factory(this.ctx, this));
|
|
789
|
+
}
|
|
776
790
|
get getGroupInviteBoxInfo() {
|
|
777
791
|
return (this._cache.getGroupInviteBoxInfo ??= getGroupInviteBoxInfoFactory(this.ctx, this));
|
|
778
792
|
}
|
|
@@ -785,9 +799,15 @@ export class API {
|
|
|
785
799
|
get getGroupLinkInfo() {
|
|
786
800
|
return (this._cache.getGroupLinkInfo ??= getGroupLinkInfoFactory(this.ctx, this));
|
|
787
801
|
}
|
|
802
|
+
get getGroupListV3() {
|
|
803
|
+
return (this._cache.getGroupListV3 ??= getGroupListV3Factory(this.ctx, this));
|
|
804
|
+
}
|
|
788
805
|
get getGroupMembersInfo() {
|
|
789
806
|
return (this._cache.getGroupMembersInfo ??= getGroupMembersInfoFactory(this.ctx, this));
|
|
790
807
|
}
|
|
808
|
+
get getGroupMessageStatus() {
|
|
809
|
+
return (this._cache.getGroupMessageStatus ??= getGroupMessageStatusFactory(this.ctx, this));
|
|
810
|
+
}
|
|
791
811
|
get getHiddenConversations() {
|
|
792
812
|
return (this._cache.getHiddenConversations ??= getHiddenConversationsFactory(this.ctx, this));
|
|
793
813
|
}
|