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,
GetQunFeedDetailResponse,
GroupAlbumInfo as GroupAlbumInfoWire,
QunFeedCellCommon,
GetMediaListRequest,
GetMediaListResponse,
MediaInfo,
@@ -343,10 +344,7 @@ export class GroupAlbumApi {
groupId: groupId.toString(),
field3: 2,
reqBody: {
field1: {
time: feed.time,
feedId: feed.feedId,
},
field1: commentReqHeader(feed.cellCommon, groupId, albumId, batchId, mediaLloc),
...(ownerUin ? { field2: { field1: { uin: ownerUin } } } : {}),
field5: photoInfo,
},
@@ -399,12 +397,7 @@ export class GroupAlbumApi {
const type = isLike ? 2 : 1;
const status = isLike ? 0 : 1;
let id = '';
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 id = qunFeedCellId(groupId, albumId, batchId, lloc);
const body = protobuf_encode<DoQunLikeRequest>({
field1: 5495,
@@ -558,7 +551,7 @@ export class GroupAlbumApi {
albumId: string,
batchId: bigint,
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 body = protobuf_encode<GetQunFeedDetailRequest>({
seq: 0,
@@ -598,8 +591,7 @@ export class GroupAlbumApi {
throw new Error('comment album media error: empty feed');
}
return {
time: cell?.time ?? 0n,
feedId,
cellCommon: cell ?? { feedId },
ownerUin: feed?.cellUserInfo?.user?.uin ?? '',
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(
feedMedia: CommentReqPhotoInfo | undefined,
fallback: MediaInfo,
@@ -8,6 +8,7 @@ import type {
GetMediaListResponse,
GetQunFeedDetailRequest,
GetQunFeedDetailResponse,
QunFeedCellCommon,
} from '@snowluma/proto-defs/oidb-actions/group-album';
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import { GroupAlbumApi } from '../../src/bridge/apis/group-album';
@@ -586,6 +587,7 @@ describe('apis/group-album', () => {
time = 1700000123n,
extra: {
ownerUin?: string;
cellCommon?: Omit<QunFeedCellCommon, 'time' | 'feedId'>;
cellMedia?: {
medias?: Array<{ type?: number; image?: { lloc?: string }; video?: { cover?: { lloc?: string } } }>;
albumId?: string;
@@ -603,7 +605,7 @@ describe('apis/group-album', () => {
data: {
feed: {
feed: {
cellCommon: { time, feedId },
cellCommon: { time, feedId, ...extra.cellCommon },
...(extra.ownerUin ? { cellUserInfo: { user: { uin: extra.ownerUin } } } : {}),
...(extra.cellMedia ? { cellMedia: extra.cellMedia } : {}),
},
@@ -627,7 +629,14 @@ describe('apis/group-album', () => {
if (override) return override;
if (cmd.endsWith('GetMediaList')) return packPhotoMedia();
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({
data: {
@@ -695,8 +704,11 @@ 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: {
@@ -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 () => {
const bridge = mockBridge();
bridge.sendRawPacket.mockImplementation(commentMocks((cmd) => {
@@ -160,8 +160,13 @@ 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.
type?: pb<1, uint_32>;
time?: pb<3, uint_64>;
feedId?: pb<4, string>;
cellId?: pb<5, string>;
field6?: pb<6, uint_32>;
}
export interface CommentReqBodyUserWrap {
field1?: pb<1, CommentUser>;
@@ -281,8 +286,11 @@ export interface GetQunFeedDetailRequest {
extMap?: pb_repeated<10, ExtMapEntry>;
}
export interface QunFeedCellCommon {
type?: pb<1, uint_32>;
time?: pb<3, uint_64>;
feedId?: pb<4, string>;
cellId?: pb<5, string>;
field6?: pb<6, uint_32>;
}
export interface QunFeedCellUser {
uin?: pb<13, string>;