From 1dffb22d053318552ad786bd743f4887fe9f8c11 Mon Sep 17 00:00:00 2001 From: DrSmoothl <1787882683@qq.com> Date: Mon, 21 Sep 2026 14:13:16 +0800 Subject: [PATCH] fix(core): write album comments with the official header fields The comment packet header only needs the feed time and id. Extra locator fields from the feed cell are not part of the official write. Refs #436 --- packages/core/src/bridge/apis/group-album.ts | 15 +++------ .../core/tests/actions/group-album.test.ts | 31 +++---------------- .../src/oidb-actions/group-album.ts | 3 +- 3 files changed, 11 insertions(+), 38 deletions(-) diff --git a/packages/core/src/bridge/apis/group-album.ts b/packages/core/src/bridge/apis/group-album.ts index 8fa2d505..e4e84429 100644 --- a/packages/core/src/bridge/apis/group-album.ts +++ b/packages/core/src/bridge/apis/group-album.ts @@ -2,6 +2,7 @@ import type { JsonObject, JsonValue } from '@snowluma/common/json'; import { createLogger } from '@snowluma/common/logger'; import type { AlbumCreator, + CommentReqBodyHeader, CommentReqPhotoInfo, CommentRespData, DeleteMediasRequest, @@ -344,7 +345,7 @@ export class GroupAlbumApi { groupId: groupId.toString(), field3: 2, reqBody: { - field1: commentReqHeader(feed.cellCommon, groupId, albumId, batchId, mediaLloc), + field1: commentReqHeader(feed.cellCommon), ...(ownerUin ? { field2: { field1: { uin: ownerUin } } } : {}), field5: photoInfo, }, @@ -693,16 +694,10 @@ function qunFeedCellId( return `${head}^||^421_1_0_${groupId}|${albumId}|${lloc}^||^0`; } -function commentReqHeader( - cell: QunFeedCellCommon, - groupId: number, - albumId: string, - batchId: bigint, - lloc: string, -): QunFeedCellCommon { +function commentReqHeader(cell: QunFeedCellCommon): CommentReqBodyHeader { return { - ...cell, - cellId: cell.cellId || qunFeedCellId(groupId, albumId, batchId, lloc), + ...(cell.time !== undefined ? { time: cell.time } : {}), + ...(cell.feedId ? { feedId: cell.feedId } : {}), }; } diff --git a/packages/core/tests/actions/group-album.test.ts b/packages/core/tests/actions/group-album.test.ts index 1baabfd4..4e020922 100644 --- a/packages/core/tests/actions/group-album.test.ts +++ b/packages/core/tests/actions/group-album.test.ts @@ -704,11 +704,8 @@ describe('apis/group-album', () => { field3: 2, reqBody: { field1: { - type: 422, time: 1700000123n, feedId: 'official-feed-id', - cellId: '421_1_0_12345|album-id|77^||^421_1_0_12345|album-id|photo-lloc^||^0', - field6: 3, }, field2: { field1: { uin: '3119936551' } }, field5: { @@ -777,7 +774,7 @@ describe('apis/group-album', () => { }); }); - it('copies the official feed cell_common locator into the comment header', async () => { + it('writes only the official comment header fields even when the feed cell has extra locator data', async () => { const cellId = '421_1_0_964445447|album-id|2147483665^||^421_1_0_964445447|album-id|photo-lloc^||^0'; const bridge = mockBridge(); bridge.sendRawPacket.mockImplementation(commentMocks((cmd) => { @@ -792,31 +789,13 @@ describe('apis/group-album', () => { await new GroupAlbumApi(bridge as never).comment(964445447, 'album-id', 'photo-lloc', 'hello'); - expect(commentRequestOf(bridge).body?.reqBody?.field1).toEqual({ - type: 422, + expect(commentRequestOf(bridge).body?.reqBody?.field1).toMatchObject({ time: 1789315793n, feedId: '422_0_2147483665', - cellId, - field6: 3, - }); - }); - - it('synthesizes the 421 locator when the official feed omits cell_common field 5', async () => { - const bridge = mockBridge(); - bridge.sendRawPacket.mockImplementation(commentMocks((cmd) => { - if (cmd.endsWith('GetQunFeedDetail')) { - return packFeedDetail('422_0_77', 1700000123n, { ownerUin: '3119936551' }); - } - return undefined; - })); - - await new GroupAlbumApi(bridge as never).comment(12345, 'album-id', 'photo-lloc', 'hello'); - - expect(commentRequestOf(bridge).body?.reqBody?.field1).toMatchObject({ - time: 1700000123n, - feedId: '422_0_77', - cellId: '421_1_0_12345|album-id|77^||^421_1_0_12345|album-id|photo-lloc^||^0', }); + expect(commentRequestOf(bridge).body?.reqBody?.field1?.type ?? 0).toBe(0); + expect(commentRequestOf(bridge).body?.reqBody?.field1?.cellId ?? '').toBe(''); + expect(commentRequestOf(bridge).body?.reqBody?.field1?.field6 ?? 0).toBe(0); }); it('comments a video with the cover location and video media type', async () => { diff --git a/packages/proto-defs/src/oidb-actions/group-album.ts b/packages/proto-defs/src/oidb-actions/group-album.ts index caa7df9e..5f6a760b 100644 --- a/packages/proto-defs/src/oidb-actions/group-album.ts +++ b/packages/proto-defs/src/oidb-actions/group-album.ts @@ -160,8 +160,7 @@ export interface CommentReqPhotoInfo { batchId?: pb<5, uint_64>; } export interface CommentReqBodyHeader { - // Official feed cell_common: type 422, time, short feed id, composite - // 421_1_0 locator, and field 6 = 3. DoQunComment copies this cell. + // FeedWorker encode writes only time and feed id into this cell. type?: pb<1, uint_32>; time?: pb<3, uint_64>; feedId?: pb<4, string>;