fix(core): handle group file storage limits

Retry eligible storage failures as temporary files and preserve their storage type for later use. Reject incompatible mixed content before chat publication.

Refs #644
This commit is contained in:
DrSmoothl committed 2026-11-07 15:14:55 +08:00
1 parent 84f4cde85e
commit 8bea681aa2
16 files changed
+750 -104

No files matched your search

+2
View File
@@ -31,6 +31,8 @@ export interface UploadedFileMeta {
scope: 'group' | 'private';
/** Group id if scope='group', else `undefined`. */
groupId?: number;
/** Server-selected group storage type: 102 permanent, 104 temporary. */
busId?: number;
/** Friend uin if scope='private', else `undefined`. */
userId?: number;
fileName: string;
+4 -2
View File
@@ -607,6 +607,8 @@ function makeGroupFileElem(element: MessageElement, ctx?: SendContext): ProtoEle
}
const cached = ctx?.bridge.recallUploadedFile(element.fileId);
const busId =
cached?.scope === 'group' && cached.groupId === ctx?.groupId ? (cached.busId ?? 102) : 102;
const fileSize = element.fileSize ?? cached?.fileSize ?? 0;
const fileName = element.fileName ?? cached?.fileName ?? '';
const md5 = element.md5Hex
@@ -618,13 +620,13 @@ function makeGroupFileElem(element: MessageElement, ctx?: SendContext): ProtoEle
// Outer field1 is hardcoded to 6 in NapCat's encoder
// (`packet/message/element.ts:589`). Inner GroupFileExtraInfo carries
// busId=102 + the file_id + name + size + sha1/md5 hashes.
// the storage type + file_id + name + size + sha1/md5 hashes.
const extraBytes = protobuf_encode<GroupFileExtra>({
field1: 6,
fileName,
inner: {
info: {
busId: 102,
busId,
fileId: element.fileId,
fileSize: BigInt(fileSize),
fileName,
@@ -21,6 +21,7 @@ export namespace PublishGroupFile {
export interface Params {
groupId: number;
fileId: string;
busId?: number;
}
export type Deps = OidbSender;
@@ -29,7 +30,7 @@ export namespace PublishGroupFile {
groupUin: p.groupId,
type: 2,
info: {
busiType: 102,
busiType: p.busId ?? 102,
fileId: p.fileId,
field3: Math.floor(Math.random() * 0x7fffffff) >>> 0,
field5: true,
@@ -33,6 +33,7 @@ export namespace UploadGroupFileRequest {
fileSize: number;
fileSha1: Uint8Array;
fileMd5: Uint8Array;
busId?: 102 | 104;
}
export type Deps = OidbSender;
@@ -41,7 +42,7 @@ export namespace UploadGroupFileRequest {
file: {
groupUin: p.groupId,
appId: 4,
busId: 102,
busId: p.busId ?? 102,
entrance: 6,
targetDirectory: p.folderId,
fileName: p.fileName,