fix(core): copy album feed locator into comment header

DoQunComment still came back 10016 after the owner-uin fix because the
write header only sent time + short feed id. Official cell_common also
carries the 421 locator; copy that cell, and synthesize it if omitted.

Fixes #436
This commit is contained in:
DrSmoothl committed 2026-09-17 23:56:07 +08:00
1 parent 23ebee7f20
commit 2a515c165c
3 files changed
+93 -15

No files matched your search

+29 -13
View File
@@ -15,6 +15,7 @@ import type {
GetQunFeedDetailRequest, GetQunFeedDetailRequest,
GetQunFeedDetailResponse, GetQunFeedDetailResponse,
GroupAlbumInfo as GroupAlbumInfoWire, GroupAlbumInfo as GroupAlbumInfoWire,
QunFeedCellCommon,
GetMediaListRequest, GetMediaListRequest,
GetMediaListResponse, GetMediaListResponse,
MediaInfo, MediaInfo,
@@ -343,10 +344,7 @@ export class GroupAlbumApi {
groupId: groupId.toString(), groupId: groupId.toString(),
field3: 2, field3: 2,
reqBody: { reqBody: {
field1: { field1: commentReqHeader(feed.cellCommon, groupId, albumId, batchId, mediaLloc),
time: feed.time,
feedId: feed.feedId,
},
...(ownerUin ? { field2: { field1: { uin: ownerUin } } } : {}), ...(ownerUin ? { field2: { field1: { uin: ownerUin } } } : {}),
field5: photoInfo, field5: photoInfo,
}, },
@@ -399,12 +397,7 @@ export class GroupAlbumApi {
const type = isLike ? 2 : 1; const type = isLike ? 2 : 1;
const status = isLike ? 0 : 1; const status = isLike ? 0 : 1;
let id = ''; const id = qunFeedCellId(groupId, albumId, batchId, lloc);
if (lloc) {
id = `421_1_0_${groupId}|${albumId}|${batchId}^||^421_1_0_${groupId}|${albumId}|${lloc}^||^0`;
} else {
id = `421_1_0_${groupId}|${albumId}|${batchId}`;
}
const body = protobuf_encode<DoQunLikeRequest>({ const body = protobuf_encode<DoQunLikeRequest>({
field1: 5495, field1: 5495,
@@ -558,7 +551,7 @@ export class GroupAlbumApi {
albumId: string, albumId: string,
batchId: bigint, batchId: bigint,
lloc: string, lloc: string,
): Promise<{ time: bigint; feedId: string; ownerUin: string; media?: CommentReqPhotoInfo }> { ): Promise<{ cellCommon: QunFeedCellCommon; ownerUin: string; media?: CommentReqPhotoInfo }> {
const traceId = `_${Date.now()}_${Math.floor(Math.random() * 100000)}`; const traceId = `_${Date.now()}_${Math.floor(Math.random() * 100000)}`;
const body = protobuf_encode<GetQunFeedDetailRequest>({ const body = protobuf_encode<GetQunFeedDetailRequest>({
seq: 0, seq: 0,
@@ -598,8 +591,7 @@ export class GroupAlbumApi {
throw new Error('comment album media error: empty feed'); throw new Error('comment album media error: empty feed');
} }
return { return {
time: cell?.time ?? 0n, cellCommon: cell ?? { feedId },
feedId,
ownerUin: feed?.cellUserInfo?.user?.uin ?? '', ownerUin: feed?.cellUserInfo?.user?.uin ?? '',
media: feed?.cellMedia, media: feed?.cellMedia,
}; };
@@ -690,6 +682,30 @@ function mediaInfoForComment(item: AlbumCommentMediaItem | undefined, lloc: stri
}; };
} }
function qunFeedCellId(
groupId: number,
albumId: string,
batchId: string | number | bigint,
lloc?: string,
): string {
const head = `421_1_0_${groupId}|${albumId}|${batchId}`;
if (!lloc) return head;
return `${head}^||^421_1_0_${groupId}|${albumId}|${lloc}^||^0`;
}
function commentReqHeader(
cell: QunFeedCellCommon,
groupId: number,
albumId: string,
batchId: bigint,
lloc: string,
): QunFeedCellCommon {
return {
...cell,
cellId: cell.cellId || qunFeedCellId(groupId, albumId, batchId, lloc),
};
}
function commentPhotoInfo( function commentPhotoInfo(
feedMedia: CommentReqPhotoInfo | undefined, feedMedia: CommentReqPhotoInfo | undefined,
fallback: MediaInfo, fallback: MediaInfo,
@@ -8,6 +8,7 @@ import type {
GetMediaListResponse, GetMediaListResponse,
GetQunFeedDetailRequest, GetQunFeedDetailRequest,
GetQunFeedDetailResponse, GetQunFeedDetailResponse,
QunFeedCellCommon,
} from '@snowluma/proto-defs/oidb-actions/group-album'; } from '@snowluma/proto-defs/oidb-actions/group-album';
import { protobuf_decode, protobuf_encode } from '@snowluma/proton'; import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import { GroupAlbumApi } from '../../src/bridge/apis/group-album'; import { GroupAlbumApi } from '../../src/bridge/apis/group-album';
@@ -586,6 +587,7 @@ describe('apis/group-album', () => {
time = 1700000123n, time = 1700000123n,
extra: { extra: {
ownerUin?: string; ownerUin?: string;
cellCommon?: Omit<QunFeedCellCommon, 'time' | 'feedId'>;
cellMedia?: { cellMedia?: {
medias?: Array<{ type?: number; image?: { lloc?: string }; video?: { cover?: { lloc?: string } } }>; medias?: Array<{ type?: number; image?: { lloc?: string }; video?: { cover?: { lloc?: string } } }>;
albumId?: string; albumId?: string;
@@ -603,7 +605,7 @@ describe('apis/group-album', () => {
data: { data: {
feed: { feed: {
feed: { feed: {
cellCommon: { time, feedId }, cellCommon: { time, feedId, ...extra.cellCommon },
...(extra.ownerUin ? { cellUserInfo: { user: { uin: extra.ownerUin } } } : {}), ...(extra.ownerUin ? { cellUserInfo: { user: { uin: extra.ownerUin } } } : {}),
...(extra.cellMedia ? { cellMedia: extra.cellMedia } : {}), ...(extra.cellMedia ? { cellMedia: extra.cellMedia } : {}),
}, },
@@ -627,7 +629,14 @@ describe('apis/group-album', () => {
if (override) return override; if (override) return override;
if (cmd.endsWith('GetMediaList')) return packPhotoMedia(); if (cmd.endsWith('GetMediaList')) return packPhotoMedia();
if (cmd.endsWith('GetQunFeedDetail')) { if (cmd.endsWith('GetQunFeedDetail')) {
return packFeedDetail('official-feed-id', 1700000123n, { ownerUin: '3119936551' }); return packFeedDetail('official-feed-id', 1700000123n, {
ownerUin: '3119936551',
cellCommon: {
type: 422,
cellId: '421_1_0_12345|album-id|77^||^421_1_0_12345|album-id|photo-lloc^||^0',
field6: 3,
},
});
} }
return packCommentOk({ return packCommentOk({
data: { data: {
@@ -695,8 +704,11 @@ describe('apis/group-album', () => {
field3: 2, field3: 2,
reqBody: { reqBody: {
field1: { field1: {
type: 422,
time: 1700000123n, time: 1700000123n,
feedId: 'official-feed-id', 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' } }, field2: { field1: { uin: '3119936551' } },
field5: { field5: {
@@ -765,6 +777,48 @@ describe('apis/group-album', () => {
}); });
}); });
it('copies the official feed cell_common locator into the comment header', 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) => {
if (cmd.endsWith('GetQunFeedDetail')) {
return packFeedDetail('422_0_2147483665', 1789315793n, {
ownerUin: '3119936551',
cellCommon: { type: 422, cellId, field6: 3 },
});
}
return undefined;
}));
await new GroupAlbumApi(bridge as never).comment(964445447, 'album-id', 'photo-lloc', 'hello');
expect(commentRequestOf(bridge).body?.reqBody?.field1).toEqual({
type: 422,
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',
});
});
it('comments a video with the cover location and video media type', async () => { it('comments a video with the cover location and video media type', async () => {
const bridge = mockBridge(); const bridge = mockBridge();
bridge.sendRawPacket.mockImplementation(commentMocks((cmd) => { bridge.sendRawPacket.mockImplementation(commentMocks((cmd) => {
@@ -160,8 +160,13 @@ export interface CommentReqPhotoInfo {
batchId?: pb<5, uint_64>; batchId?: pb<5, uint_64>;
} }
export interface CommentReqBodyHeader { 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.
type?: pb<1, uint_32>;
time?: pb<3, uint_64>; time?: pb<3, uint_64>;
feedId?: pb<4, string>; feedId?: pb<4, string>;
cellId?: pb<5, string>;
field6?: pb<6, uint_32>;
} }
export interface CommentReqBodyUserWrap { export interface CommentReqBodyUserWrap {
field1?: pb<1, CommentUser>; field1?: pb<1, CommentUser>;
@@ -281,8 +286,11 @@ export interface GetQunFeedDetailRequest {
extMap?: pb_repeated<10, ExtMapEntry>; extMap?: pb_repeated<10, ExtMapEntry>;
} }
export interface QunFeedCellCommon { export interface QunFeedCellCommon {
type?: pb<1, uint_32>;
time?: pb<3, uint_64>; time?: pb<3, uint_64>;
feedId?: pb<4, string>; feedId?: pb<4, string>;
cellId?: pb<5, string>;
field6?: pb<6, uint_32>;
} }
export interface QunFeedCellUser { export interface QunFeedCellUser {
uin?: pb<13, string>; uin?: pb<13, string>;