@napuketto/adapter 0.13.2 → 0.14.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.
- package/README.md +7 -2
- package/dist/core/index.d.mts +1 -1
- package/dist/core/index.mjs +1 -1
- package/dist/{core-CMqpb5-m.mjs → core-CECIwO6s.mjs} +3 -3
- package/dist/core-CECIwO6s.mjs.map +1 -0
- package/dist/{essence-DzYnP60o.mjs → essence-Bdms4trk.mjs} +2 -2
- package/dist/{essence-DzYnP60o.mjs.map → essence-Bdms4trk.mjs.map} +1 -1
- package/dist/{index-DDPMbC_c.d.mts → index-Do2Oi2_e.d.mts} +3 -3
- package/dist/{index-DDPMbC_c.d.mts.map → index-Do2Oi2_e.d.mts.map} +1 -1
- package/dist/kurobot/index.d.mts +1 -1
- package/dist/kurobot/index.mjs +1 -1
- package/dist/milky/index.d.mts +6 -2
- package/dist/milky/index.d.mts.map +1 -1
- package/dist/milky/index.mjs +190 -195
- package/dist/milky/index.mjs.map +1 -1
- package/dist/onebot11/index.d.mts +6 -2
- package/dist/onebot11/index.d.mts.map +1 -1
- package/dist/onebot11/index.mjs +99 -2
- package/dist/onebot11/index.mjs.map +1 -1
- package/dist/satori/index.d.mts +1 -1
- package/dist/satori/index.mjs +1 -1
- package/package.json +2 -2
- package/dist/core-CMqpb5-m.mjs.map +0 -1
package/dist/milky/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as ActionRegistry, a as extractSysMsgEnvelope, c as narrowSysMsgBlobs, d as textOf, f as toHex, l as nodeAt, m as varintOf, p as varintAt, r as decodeProtoTree, u as recognizeSysMsg, y as BaseProtocolAdapter } from "../core-
|
|
2
|
-
import { a as MS_TO_SEC$2, i as narrowBuddyReqs, n as extractEssenceSetSysMsg, o as resolveUin, r as narrowEssenceGroupArg, t as diffEssenceList } from "../essence-
|
|
1
|
+
import { S as ActionRegistry, a as extractSysMsgEnvelope, c as narrowSysMsgBlobs, d as textOf, f as toHex, l as nodeAt, m as varintOf, p as varintAt, r as decodeProtoTree, u as recognizeSysMsg, y as BaseProtocolAdapter } from "../core-CECIwO6s.mjs";
|
|
2
|
+
import { a as MS_TO_SEC$2, i as narrowBuddyReqs, n as extractEssenceSetSysMsg, o as resolveUin, r as narrowEssenceGroupArg, t as diffEssenceList } from "../essence-Bdms4trk.mjs";
|
|
3
3
|
import { n as firstUntranslatedGrayTip, t as collectGrayTipUids } from "../gray-tip-ByF-MKeV.mjs";
|
|
4
4
|
import { r as subscribeRawMessages, t as forEachRawMessage } from "../raw-message-D2vA27kj.mjs";
|
|
5
5
|
import { ChatType, GrayTipSubType, GroupApi, GroupNotifyMsgStatus, GroupNotifyMsgType, NTGroupRequestOperateTypes, TicketApi, TipGroupElementType, isKernelError, kernelError, toCanonicalElements } from "@napuketto/kernel";
|
|
@@ -8,8 +8,8 @@ import { join } from "node:path";
|
|
|
8
8
|
import { detectFileType, downloadUrl, inferExtension } from "@napuketto/media";
|
|
9
9
|
import { z } from "zod";
|
|
10
10
|
import { randomUUID } from "node:crypto";
|
|
11
|
-
import { HttpClient, HttpServer, createSseResponse, isWsOpen } from "@napuketto/network";
|
|
12
11
|
import { fileURLToPath } from "node:url";
|
|
12
|
+
import { HttpClient, HttpServer, createSseResponse, isWsOpen } from "@napuketto/network";
|
|
13
13
|
// src/milky/api.ts
|
|
14
14
|
var MilkyApi = class {
|
|
15
15
|
msgApi;
|
|
@@ -21,6 +21,8 @@ var MilkyApi = class {
|
|
|
21
21
|
webApi;
|
|
22
22
|
groupNotifyApi;
|
|
23
23
|
richMediaApi;
|
|
24
|
+
/** kernel 闪传 API(文件投递:分享卡片,见 flash-transfer.ts 语义说明)。 */
|
|
25
|
+
flashTransferApi;
|
|
24
26
|
recentContactApi;
|
|
25
27
|
self;
|
|
26
28
|
groupCache;
|
|
@@ -41,6 +43,7 @@ var MilkyApi = class {
|
|
|
41
43
|
this.webApi = opts.webApi;
|
|
42
44
|
this.groupNotifyApi = opts.groupNotifyApi;
|
|
43
45
|
this.richMediaApi = opts.richMediaApi;
|
|
46
|
+
this.flashTransferApi = opts.flashTransferApi;
|
|
44
47
|
this.recentContactApi = opts.recentContactApi;
|
|
45
48
|
this.self = opts.self;
|
|
46
49
|
this.groupCache = opts.groupCache;
|
|
@@ -920,6 +923,184 @@ function picUrlOf(b) {
|
|
|
920
923
|
const url = b.pic?.url;
|
|
921
924
|
return typeof url === "string" && url !== "" ? url : null;
|
|
922
925
|
}
|
|
926
|
+
// src/milky/action/group-file.ts
|
|
927
|
+
const groupIdField = { group_id: z.number().int().min(10001) };
|
|
928
|
+
const fileIdField = { file_id: z.string().min(1) };
|
|
929
|
+
const optStr = z.string().nullable().optional();
|
|
930
|
+
/** get_group_files:获取群文件列表(根目录或指定文件夹;过滤 parent 匹配项)。 */
|
|
931
|
+
var GetGroupFilesAction = class extends MilkyApiAction {
|
|
932
|
+
name = "get_group_files";
|
|
933
|
+
schema = z.object({
|
|
934
|
+
...groupIdField,
|
|
935
|
+
parent_folder_id: optStr
|
|
936
|
+
});
|
|
937
|
+
async _handle(payload) {
|
|
938
|
+
const groupCode = String(payload.group_id);
|
|
939
|
+
const parent = payload.parent_folder_id ?? "";
|
|
940
|
+
const items = await this.api.richMediaApi.getGroupFileList(groupCode, parent);
|
|
941
|
+
const files = [];
|
|
942
|
+
const folders = [];
|
|
943
|
+
for (const item of items) if (item.fileInfo !== void 0) files.push(fileToEntity(item.fileInfo, payload.group_id));
|
|
944
|
+
else if (item.folderInfo !== void 0) folders.push(folderToEntity(item.folderInfo, payload.group_id));
|
|
945
|
+
return {
|
|
946
|
+
files,
|
|
947
|
+
folders
|
|
948
|
+
};
|
|
949
|
+
}
|
|
950
|
+
};
|
|
951
|
+
/** move_group_file:移动文件(target_folder_id 空 = 移到根目录;parent 入参仅 schema 兼容)。 */
|
|
952
|
+
var MoveGroupFileAction = class extends MilkyApiAction {
|
|
953
|
+
name = "move_group_file";
|
|
954
|
+
schema = z.object({
|
|
955
|
+
...groupIdField,
|
|
956
|
+
...fileIdField,
|
|
957
|
+
parent_folder_id: optStr,
|
|
958
|
+
target_folder_id: optStr
|
|
959
|
+
});
|
|
960
|
+
async _handle(payload) {
|
|
961
|
+
await this.api.richMediaApi.moveGroupFile(String(payload.group_id), [payload.file_id], payload.target_folder_id ?? "");
|
|
962
|
+
return {};
|
|
963
|
+
}
|
|
964
|
+
};
|
|
965
|
+
/** rename_group_file:重命名文件。 */
|
|
966
|
+
var RenameGroupFileAction = class extends MilkyApiAction {
|
|
967
|
+
name = "rename_group_file";
|
|
968
|
+
schema = z.object({
|
|
969
|
+
...groupIdField,
|
|
970
|
+
...fileIdField,
|
|
971
|
+
parent_folder_id: optStr,
|
|
972
|
+
new_file_name: z.string().min(1)
|
|
973
|
+
});
|
|
974
|
+
async _handle(payload) {
|
|
975
|
+
await this.api.richMediaApi.renameGroupFile(String(payload.group_id), payload.file_id, payload.new_file_name);
|
|
976
|
+
return {};
|
|
977
|
+
}
|
|
978
|
+
};
|
|
979
|
+
/** delete_group_file:删除文件。 */
|
|
980
|
+
var DeleteGroupFileAction = class extends MilkyApiAction {
|
|
981
|
+
name = "delete_group_file";
|
|
982
|
+
schema = z.object({
|
|
983
|
+
...groupIdField,
|
|
984
|
+
...fileIdField
|
|
985
|
+
});
|
|
986
|
+
async _handle(payload) {
|
|
987
|
+
await this.api.richMediaApi.deleteGroupFile(String(payload.group_id), [payload.file_id]);
|
|
988
|
+
return {};
|
|
989
|
+
}
|
|
990
|
+
};
|
|
991
|
+
/**
|
|
992
|
+
* persist_group_file:转存文件(RichMediaApi.transGroupFile,转存语义待对齐)。
|
|
993
|
+
*/
|
|
994
|
+
var PersistGroupFileAction = class extends MilkyApiAction {
|
|
995
|
+
name = "persist_group_file";
|
|
996
|
+
schema = z.object({
|
|
997
|
+
...groupIdField,
|
|
998
|
+
...fileIdField
|
|
999
|
+
});
|
|
1000
|
+
async _handle(payload) {
|
|
1001
|
+
await this.api.richMediaApi.transGroupFile(String(payload.group_id), payload.file_id);
|
|
1002
|
+
return {};
|
|
1003
|
+
}
|
|
1004
|
+
};
|
|
1005
|
+
/** create_group_folder:创建文件夹(返回 folder_id)。 */
|
|
1006
|
+
var CreateGroupFolderAction = class extends MilkyApiAction {
|
|
1007
|
+
name = "create_group_folder";
|
|
1008
|
+
schema = z.object({
|
|
1009
|
+
...groupIdField,
|
|
1010
|
+
folder_name: z.string().min(1)
|
|
1011
|
+
});
|
|
1012
|
+
async _handle(payload) {
|
|
1013
|
+
return { folder_id: await this.api.richMediaApi.createGroupFolder(String(payload.group_id), payload.folder_name) };
|
|
1014
|
+
}
|
|
1015
|
+
};
|
|
1016
|
+
/** delete_group_folder:删除文件夹。 */
|
|
1017
|
+
var DeleteGroupFolderAction = class extends MilkyApiAction {
|
|
1018
|
+
name = "delete_group_folder";
|
|
1019
|
+
schema = z.object({
|
|
1020
|
+
...groupIdField,
|
|
1021
|
+
folder_id: z.string().min(1)
|
|
1022
|
+
});
|
|
1023
|
+
async _handle(payload) {
|
|
1024
|
+
await this.api.richMediaApi.deleteGroupFolder(String(payload.group_id), payload.folder_id);
|
|
1025
|
+
return {};
|
|
1026
|
+
}
|
|
1027
|
+
};
|
|
1028
|
+
/** GroupFileItemInfo → GroupFileEntity(fileSize 原生为字符串;无源字段兜底)。 */
|
|
1029
|
+
function fileToEntity(info, groupId) {
|
|
1030
|
+
return {
|
|
1031
|
+
group_id: groupId,
|
|
1032
|
+
file_id: info.fileId,
|
|
1033
|
+
file_name: info.fileName,
|
|
1034
|
+
parent_folder_id: info.parent ?? "",
|
|
1035
|
+
file_size: Number(info.fileSize) || 0,
|
|
1036
|
+
uploaded_time: Number(info.uploadTime) || 0,
|
|
1037
|
+
expire_time: null,
|
|
1038
|
+
uploader_id: Number(info.uploaderUin) || 0,
|
|
1039
|
+
downloaded_times: 0
|
|
1040
|
+
};
|
|
1041
|
+
}
|
|
1042
|
+
/** GroupFolderInfo → GroupFolderEntity(元数据无类型字段防御读取,缺省 0)。 */
|
|
1043
|
+
function folderToEntity(info, groupId) {
|
|
1044
|
+
const num = (key) => {
|
|
1045
|
+
const v = info[key];
|
|
1046
|
+
return typeof v === "number" ? v : Number(v) || 0;
|
|
1047
|
+
};
|
|
1048
|
+
return {
|
|
1049
|
+
group_id: groupId,
|
|
1050
|
+
folder_id: info.folderId,
|
|
1051
|
+
parent_folder_id: info.folderUid ?? "",
|
|
1052
|
+
folder_name: info.folderName,
|
|
1053
|
+
created_time: num("createTime"),
|
|
1054
|
+
last_modified_time: num("modifyTime"),
|
|
1055
|
+
creator_id: 0,
|
|
1056
|
+
file_count: num("totalFileCount")
|
|
1057
|
+
};
|
|
1058
|
+
}
|
|
1059
|
+
/**
|
|
1060
|
+
* upload_group_file:上传并投递文件(**闪传通道**:分享链接卡片,见文件头语义说明)。
|
|
1061
|
+
* file_id 返回闪传文件集 id(非群文件 fileId)。
|
|
1062
|
+
*/
|
|
1063
|
+
var UploadGroupFileAction = class extends MilkyApiAction {
|
|
1064
|
+
name = "upload_group_file";
|
|
1065
|
+
schema = z.object({
|
|
1066
|
+
...groupIdField,
|
|
1067
|
+
parent_folder_id: optStr,
|
|
1068
|
+
file_uri: z.string().min(1),
|
|
1069
|
+
file_name: z.string().min(1)
|
|
1070
|
+
});
|
|
1071
|
+
async _handle(payload) {
|
|
1072
|
+
const path = await resolveUriToPath(payload.file_uri, this.api.mediaDir);
|
|
1073
|
+
const peer = {
|
|
1074
|
+
chatType: ChatType.GROUP,
|
|
1075
|
+
peerUid: String(payload.group_id)
|
|
1076
|
+
};
|
|
1077
|
+
return { file_id: (await this.api.flashTransferApi.sendFile(peer, [path], { name: payload.file_name })).fileSetId };
|
|
1078
|
+
}
|
|
1079
|
+
};
|
|
1080
|
+
/** get_group_file_download_url:群文件下载链接(url 字段待实机确认,仅根目录)。 */
|
|
1081
|
+
var GetGroupFileDownloadUrlAction = class extends MilkyApiAction {
|
|
1082
|
+
name = "get_group_file_download_url";
|
|
1083
|
+
schema = z.object({
|
|
1084
|
+
...groupIdField,
|
|
1085
|
+
...fileIdField
|
|
1086
|
+
});
|
|
1087
|
+
async _handle(payload) {
|
|
1088
|
+
return { download_url: await this.api.richMediaApi.getGroupFileDownloadUrl(String(payload.group_id), payload.file_id) };
|
|
1089
|
+
}
|
|
1090
|
+
};
|
|
1091
|
+
/** rename_group_folder:重命名群文件夹(renameGroupFile 同款形态,待校准)。 */
|
|
1092
|
+
var RenameGroupFolderAction = class extends MilkyApiAction {
|
|
1093
|
+
name = "rename_group_folder";
|
|
1094
|
+
schema = z.object({
|
|
1095
|
+
...groupIdField,
|
|
1096
|
+
folder_id: z.string().min(1),
|
|
1097
|
+
new_folder_name: z.string().min(1)
|
|
1098
|
+
});
|
|
1099
|
+
async _handle(payload) {
|
|
1100
|
+
await this.api.richMediaApi.renameGroupFolder(String(payload.group_id), payload.folder_id, payload.new_folder_name);
|
|
1101
|
+
return {};
|
|
1102
|
+
}
|
|
1103
|
+
};
|
|
923
1104
|
// src/milky/helper/message/segments.ts
|
|
924
1105
|
/**
|
|
925
1106
|
* Milky 消息段 ↔ canonical 元素转换(纯函数,ADR-008)
|
|
@@ -1648,7 +1829,11 @@ var GetResourceTempUrlAction = class extends MilkyApiAction {
|
|
|
1648
1829
|
throw kernelError(`资源 ${id} 无临时链接(resource_id 非链接形态)`, "NOT_FOUND");
|
|
1649
1830
|
}
|
|
1650
1831
|
};
|
|
1651
|
-
/**
|
|
1832
|
+
/**
|
|
1833
|
+
* upload_private_file:上传并投递私聊文件(**闪传通道**:分享链接卡片)。
|
|
1834
|
+
* file_id 返回闪传文件集 id(非文件消息 fileUuid)。语义降级同 upload_group_file:
|
|
1835
|
+
* 对端收到的是分享链接卡片而不是 fileElement 文件消息(kernel design §15)。
|
|
1836
|
+
*/
|
|
1652
1837
|
var UploadPrivateFileAction = class extends MilkyApiAction {
|
|
1653
1838
|
name = "upload_private_file";
|
|
1654
1839
|
schema = z.object({
|
|
@@ -1659,197 +1844,7 @@ var UploadPrivateFileAction = class extends MilkyApiAction {
|
|
|
1659
1844
|
async _handle(payload) {
|
|
1660
1845
|
const path = await resolveUriToPath(payload.file_uri, this.api.mediaDir);
|
|
1661
1846
|
const peer = await this.api.resolvePeer("friend", payload.user_id);
|
|
1662
|
-
return { file_id: await
|
|
1663
|
-
}
|
|
1664
|
-
};
|
|
1665
|
-
/**
|
|
1666
|
-
* 发送文件消息并回查 file_id:sendMessage(canonical file 元素,kernel 走
|
|
1667
|
-
* prepareFileElement 链)→ fetchMsgsByMsgId 取 fileElement.fileUuid(缺省 msgId)。
|
|
1668
|
-
* upload_private/group_file 共用。
|
|
1669
|
-
*/
|
|
1670
|
-
async function sendFileMessage(api, peer, path, fileName) {
|
|
1671
|
-
const { msgId } = await api.msgApi.sendMessage(peer, [{
|
|
1672
|
-
type: "file",
|
|
1673
|
-
path,
|
|
1674
|
-
name: fileName
|
|
1675
|
-
}]);
|
|
1676
|
-
const [sent] = await api.msgApi.fetchMsgsByMsgId(peer, [msgId]);
|
|
1677
|
-
const uuid = (sent?.elements.find((e) => e.fileElement != null))?.fileElement?.fileUuid;
|
|
1678
|
-
return uuid !== void 0 && uuid !== "" ? uuid : msgId;
|
|
1679
|
-
}
|
|
1680
|
-
// src/milky/action/group-file.ts
|
|
1681
|
-
const groupIdField = { group_id: z.number().int().min(10001) };
|
|
1682
|
-
const fileIdField = { file_id: z.string().min(1) };
|
|
1683
|
-
const optStr = z.string().nullable().optional();
|
|
1684
|
-
/** get_group_files:获取群文件列表(根目录或指定文件夹;过滤 parent 匹配项)。 */
|
|
1685
|
-
var GetGroupFilesAction = class extends MilkyApiAction {
|
|
1686
|
-
name = "get_group_files";
|
|
1687
|
-
schema = z.object({
|
|
1688
|
-
...groupIdField,
|
|
1689
|
-
parent_folder_id: optStr
|
|
1690
|
-
});
|
|
1691
|
-
async _handle(payload) {
|
|
1692
|
-
const groupCode = String(payload.group_id);
|
|
1693
|
-
const parent = payload.parent_folder_id ?? "";
|
|
1694
|
-
const items = await this.api.richMediaApi.getGroupFileList(groupCode, parent);
|
|
1695
|
-
const files = [];
|
|
1696
|
-
const folders = [];
|
|
1697
|
-
for (const item of items) if (item.fileInfo !== void 0) files.push(fileToEntity(item.fileInfo, payload.group_id));
|
|
1698
|
-
else if (item.folderInfo !== void 0) folders.push(folderToEntity(item.folderInfo, payload.group_id));
|
|
1699
|
-
return {
|
|
1700
|
-
files,
|
|
1701
|
-
folders
|
|
1702
|
-
};
|
|
1703
|
-
}
|
|
1704
|
-
};
|
|
1705
|
-
/** move_group_file:移动文件(target_folder_id 空 = 移到根目录;parent 入参仅 schema 兼容)。 */
|
|
1706
|
-
var MoveGroupFileAction = class extends MilkyApiAction {
|
|
1707
|
-
name = "move_group_file";
|
|
1708
|
-
schema = z.object({
|
|
1709
|
-
...groupIdField,
|
|
1710
|
-
...fileIdField,
|
|
1711
|
-
parent_folder_id: optStr,
|
|
1712
|
-
target_folder_id: optStr
|
|
1713
|
-
});
|
|
1714
|
-
async _handle(payload) {
|
|
1715
|
-
await this.api.richMediaApi.moveGroupFile(String(payload.group_id), [payload.file_id], payload.target_folder_id ?? "");
|
|
1716
|
-
return {};
|
|
1717
|
-
}
|
|
1718
|
-
};
|
|
1719
|
-
/** rename_group_file:重命名文件。 */
|
|
1720
|
-
var RenameGroupFileAction = class extends MilkyApiAction {
|
|
1721
|
-
name = "rename_group_file";
|
|
1722
|
-
schema = z.object({
|
|
1723
|
-
...groupIdField,
|
|
1724
|
-
...fileIdField,
|
|
1725
|
-
parent_folder_id: optStr,
|
|
1726
|
-
new_file_name: z.string().min(1)
|
|
1727
|
-
});
|
|
1728
|
-
async _handle(payload) {
|
|
1729
|
-
await this.api.richMediaApi.renameGroupFile(String(payload.group_id), payload.file_id, payload.new_file_name);
|
|
1730
|
-
return {};
|
|
1731
|
-
}
|
|
1732
|
-
};
|
|
1733
|
-
/** delete_group_file:删除文件。 */
|
|
1734
|
-
var DeleteGroupFileAction = class extends MilkyApiAction {
|
|
1735
|
-
name = "delete_group_file";
|
|
1736
|
-
schema = z.object({
|
|
1737
|
-
...groupIdField,
|
|
1738
|
-
...fileIdField
|
|
1739
|
-
});
|
|
1740
|
-
async _handle(payload) {
|
|
1741
|
-
await this.api.richMediaApi.deleteGroupFile(String(payload.group_id), [payload.file_id]);
|
|
1742
|
-
return {};
|
|
1743
|
-
}
|
|
1744
|
-
};
|
|
1745
|
-
/**
|
|
1746
|
-
* persist_group_file:转存文件(RichMediaApi.transGroupFile,转存语义待对齐)。
|
|
1747
|
-
*/
|
|
1748
|
-
var PersistGroupFileAction = class extends MilkyApiAction {
|
|
1749
|
-
name = "persist_group_file";
|
|
1750
|
-
schema = z.object({
|
|
1751
|
-
...groupIdField,
|
|
1752
|
-
...fileIdField
|
|
1753
|
-
});
|
|
1754
|
-
async _handle(payload) {
|
|
1755
|
-
await this.api.richMediaApi.transGroupFile(String(payload.group_id), payload.file_id);
|
|
1756
|
-
return {};
|
|
1757
|
-
}
|
|
1758
|
-
};
|
|
1759
|
-
/** create_group_folder:创建文件夹(返回 folder_id)。 */
|
|
1760
|
-
var CreateGroupFolderAction = class extends MilkyApiAction {
|
|
1761
|
-
name = "create_group_folder";
|
|
1762
|
-
schema = z.object({
|
|
1763
|
-
...groupIdField,
|
|
1764
|
-
folder_name: z.string().min(1)
|
|
1765
|
-
});
|
|
1766
|
-
async _handle(payload) {
|
|
1767
|
-
return { folder_id: await this.api.richMediaApi.createGroupFolder(String(payload.group_id), payload.folder_name) };
|
|
1768
|
-
}
|
|
1769
|
-
};
|
|
1770
|
-
/** delete_group_folder:删除文件夹。 */
|
|
1771
|
-
var DeleteGroupFolderAction = class extends MilkyApiAction {
|
|
1772
|
-
name = "delete_group_folder";
|
|
1773
|
-
schema = z.object({
|
|
1774
|
-
...groupIdField,
|
|
1775
|
-
folder_id: z.string().min(1)
|
|
1776
|
-
});
|
|
1777
|
-
async _handle(payload) {
|
|
1778
|
-
await this.api.richMediaApi.deleteGroupFolder(String(payload.group_id), payload.folder_id);
|
|
1779
|
-
return {};
|
|
1780
|
-
}
|
|
1781
|
-
};
|
|
1782
|
-
/** GroupFileItemInfo → GroupFileEntity(fileSize 原生为字符串;无源字段兜底)。 */
|
|
1783
|
-
function fileToEntity(info, groupId) {
|
|
1784
|
-
return {
|
|
1785
|
-
group_id: groupId,
|
|
1786
|
-
file_id: info.fileId,
|
|
1787
|
-
file_name: info.fileName,
|
|
1788
|
-
parent_folder_id: info.parent ?? "",
|
|
1789
|
-
file_size: Number(info.fileSize) || 0,
|
|
1790
|
-
uploaded_time: Number(info.uploadTime) || 0,
|
|
1791
|
-
expire_time: null,
|
|
1792
|
-
uploader_id: Number(info.uploaderUin) || 0,
|
|
1793
|
-
downloaded_times: 0
|
|
1794
|
-
};
|
|
1795
|
-
}
|
|
1796
|
-
/** GroupFolderInfo → GroupFolderEntity(元数据无类型字段防御读取,缺省 0)。 */
|
|
1797
|
-
function folderToEntity(info, groupId) {
|
|
1798
|
-
const num = (key) => {
|
|
1799
|
-
const v = info[key];
|
|
1800
|
-
return typeof v === "number" ? v : Number(v) || 0;
|
|
1801
|
-
};
|
|
1802
|
-
return {
|
|
1803
|
-
group_id: groupId,
|
|
1804
|
-
folder_id: info.folderId,
|
|
1805
|
-
parent_folder_id: info.folderUid ?? "",
|
|
1806
|
-
folder_name: info.folderName,
|
|
1807
|
-
created_time: num("createTime"),
|
|
1808
|
-
last_modified_time: num("modifyTime"),
|
|
1809
|
-
creator_id: 0,
|
|
1810
|
-
file_count: num("totalFileCount")
|
|
1811
|
-
};
|
|
1812
|
-
}
|
|
1813
|
-
/** upload_group_file:上传群文件(消息发送链;parent_folder_id 暂不参与定位)。 */
|
|
1814
|
-
var UploadGroupFileAction = class extends MilkyApiAction {
|
|
1815
|
-
name = "upload_group_file";
|
|
1816
|
-
schema = z.object({
|
|
1817
|
-
...groupIdField,
|
|
1818
|
-
parent_folder_id: optStr,
|
|
1819
|
-
file_uri: z.string().min(1),
|
|
1820
|
-
file_name: z.string().min(1)
|
|
1821
|
-
});
|
|
1822
|
-
async _handle(payload) {
|
|
1823
|
-
const path = await resolveUriToPath(payload.file_uri, this.api.mediaDir);
|
|
1824
|
-
const peer = {
|
|
1825
|
-
chatType: ChatType.GROUP,
|
|
1826
|
-
peerUid: String(payload.group_id)
|
|
1827
|
-
};
|
|
1828
|
-
return { file_id: await sendFileMessage(this.api, peer, path, payload.file_name) };
|
|
1829
|
-
}
|
|
1830
|
-
};
|
|
1831
|
-
/** get_group_file_download_url:群文件下载链接(url 字段待实机确认,仅根目录)。 */
|
|
1832
|
-
var GetGroupFileDownloadUrlAction = class extends MilkyApiAction {
|
|
1833
|
-
name = "get_group_file_download_url";
|
|
1834
|
-
schema = z.object({
|
|
1835
|
-
...groupIdField,
|
|
1836
|
-
...fileIdField
|
|
1837
|
-
});
|
|
1838
|
-
async _handle(payload) {
|
|
1839
|
-
return { download_url: await this.api.richMediaApi.getGroupFileDownloadUrl(String(payload.group_id), payload.file_id) };
|
|
1840
|
-
}
|
|
1841
|
-
};
|
|
1842
|
-
/** rename_group_folder:重命名群文件夹(renameGroupFile 同款形态,待校准)。 */
|
|
1843
|
-
var RenameGroupFolderAction = class extends MilkyApiAction {
|
|
1844
|
-
name = "rename_group_folder";
|
|
1845
|
-
schema = z.object({
|
|
1846
|
-
...groupIdField,
|
|
1847
|
-
folder_id: z.string().min(1),
|
|
1848
|
-
new_folder_name: z.string().min(1)
|
|
1849
|
-
});
|
|
1850
|
-
async _handle(payload) {
|
|
1851
|
-
await this.api.richMediaApi.renameGroupFolder(String(payload.group_id), payload.folder_id, payload.new_folder_name);
|
|
1852
|
-
return {};
|
|
1847
|
+
return { file_id: (await this.api.flashTransferApi.sendFile(peer, [path], { name: payload.file_name })).fileSetId };
|
|
1853
1848
|
}
|
|
1854
1849
|
};
|
|
1855
1850
|
// src/milky/action/profile.ts
|