fix(group-file): correct GroupFileExtra wire shape — server was rejecting with result=79

Two off-by-one bugs in the group-file chat-post element that combined
to make the QQ-NT server reject every group file send with result=79
(visible as "group file uploaded but chat post failed" in the logs):

1. Inner GroupFileInfo fields were shifted one tag left:
   - fileSha    was field 5, should be field 6
   - extInfo    was field 6, should be field 7
   - fileMd5    was field 7, should be field 8
   Field 5 is actually a uint32 placeholder (`field5` in both NapCat
   and acidify). With the bug, our fileSha bytes were landing where
   the server expected a varint and the rest of the message got
   skipped as garbage.

2. Outer GroupFileExtra was missing the magic field1=6 + fileName
   slots that NapCat's encoder writes
   (`packet/message/element.ts:589`). Acidify's schema also models
   them as required even though it serialises with defaults. The
   current server build rejects sends without these slots populated.

Cross-referenced:
- NapCat `GroupFileExtraInfo` (component.ts:146-155) — matches our
  new field numbers exactly
- acidify `GroupFileExtra.Inner.Info` (proto/message/extra/GroupFileExtra.kt)
  — same field numbers; their schema uses generic `field5`/`field7`
  names but the wire layout is identical

Changes:
- Proton + legacy schemas: shift inner fields, add outer field1/
  fileName/display
- `makeGroupFileElem`: write field1=6 + fileName on the outer wrapper
- Regression test asserts each inner tag lands at 50/58/66 (not the
  old 42/50/58) and verifies the new outer field1 + fileName bytes
  are present
This commit is contained in:
DrSmoothl committed 2026-05-19 21:51:35 +08:00
1 parent 04a905460b
commit 8f839f4f30
4 files changed
+100 -7

No files matched your search

+13 -3
View File
@@ -390,14 +390,21 @@ export const MsgInfoSchema = {
// --- GroupFileExtra (TransElem type=24) ---
// Field numbers cross-checked against NapCat (component.ts:146) +
// acidify (GroupFileExtra.kt:Inner.Info). Old schema had fileSha at 5
// / extInfoString at 6 / fileMd5 at 7 which mismatched the real wire
// shape — the server rejected the chat post with `result=79` because
// fileSha bytes were landing where it expected a uint32 (field 5).
// See proton/element.ts for the WHY comment.
export const GroupFileInfoSchema = {
busId: { field: 1, type: 'uint32' as const },
fileId: { field: 2, type: 'string' as const },
fileSize: { field: 3, type: 'uint64' as const },
fileName: { field: 4, type: 'string' as const },
fileSha: { field: 5, type: 'bytes' as const },
extInfoString: { field: 6, type: 'string' as const },
fileMd5: { field: 7, type: 'bytes' as const },
field5: { field: 5, type: 'uint32' as const },
fileSha: { field: 6, type: 'bytes' as const },
extInfoString: { field: 7, type: 'string' as const },
fileMd5: { field: 8, type: 'bytes' as const },
} satisfies ProtoSchema;
export const GroupFileExtraInnerSchema = {
@@ -405,6 +412,9 @@ export const GroupFileExtraInnerSchema = {
} satisfies ProtoSchema;
export const GroupFileExtraSchema = {
field1: { field: 1, type: 'uint32' as const },
fileName: { field: 2, type: 'string' as const },
display: { field: 3, type: 'string' as const },
inner: { field: 7, type: 'message' as const, schema: GroupFileExtraInnerSchema },
} satisfies ProtoSchema;