fix(core): write album comments as the feed owner
DoQunComment still returned 10016 after the feed lookup because we stamped the bot onto StFeed.cellUserInfo. Official FeedWorker copies the feed owner's uin there and only puts the bot on StComment. Fixes #436
This commit is contained in:
3 files changed
+120
-18
No files matched your search
@@ -584,6 +584,14 @@ describe('apis/group-album', () => {
|
||||
function packFeedDetail(
|
||||
feedId = 'official-feed-id',
|
||||
time = 1700000123n,
|
||||
extra: {
|
||||
ownerUin?: string;
|
||||
cellMedia?: {
|
||||
medias?: Array<{ type?: number; image?: { lloc?: string }; video?: { cover?: { lloc?: string } } }>;
|
||||
albumId?: string;
|
||||
batchId?: bigint;
|
||||
};
|
||||
} = {},
|
||||
): ReturnType<typeof packDeleteOk> {
|
||||
return {
|
||||
success: true,
|
||||
@@ -596,6 +604,8 @@ describe('apis/group-album', () => {
|
||||
feed: {
|
||||
feed: {
|
||||
cellCommon: { time, feedId },
|
||||
...(extra.ownerUin ? { cellUserInfo: { user: { uin: extra.ownerUin } } } : {}),
|
||||
...(extra.cellMedia ? { cellMedia: extra.cellMedia } : {}),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -616,7 +626,9 @@ describe('apis/group-album', () => {
|
||||
const override = extra(cmd);
|
||||
if (override) return override;
|
||||
if (cmd.endsWith('GetMediaList')) return packPhotoMedia();
|
||||
if (cmd.endsWith('GetQunFeedDetail')) return packFeedDetail();
|
||||
if (cmd.endsWith('GetQunFeedDetail')) {
|
||||
return packFeedDetail('official-feed-id', 1700000123n, { ownerUin: '3119936551' });
|
||||
}
|
||||
return packCommentOk({
|
||||
data: {
|
||||
id: 'cmt-1',
|
||||
@@ -629,14 +641,18 @@ describe('apis/group-album', () => {
|
||||
};
|
||||
}
|
||||
|
||||
function commentRequestOf(bridge: ReturnType<typeof mockBridge>): DoQunCommentRequest {
|
||||
function commentCallBytes(bridge: ReturnType<typeof mockBridge>): Uint8Array {
|
||||
const commentCall = bridge.sendRawPacket.mock.calls.find((call) =>
|
||||
String(call[0]).endsWith('DoQunComment'),
|
||||
);
|
||||
expect(commentCall?.[0]).toBe(
|
||||
'QunAlbum.trpc.qzone.webapp_qun_operation.FeedsWriter.DoQunComment',
|
||||
);
|
||||
return protobuf_decode<DoQunCommentRequest>(commentCall![1] as Uint8Array);
|
||||
return commentCall![1] as Uint8Array;
|
||||
}
|
||||
|
||||
function commentRequestOf(bridge: ReturnType<typeof mockBridge>): DoQunCommentRequest {
|
||||
return protobuf_decode<DoQunCommentRequest>(commentCallBytes(bridge));
|
||||
}
|
||||
|
||||
function feedDetailRequestOf(bridge: ReturnType<typeof mockBridge>): GetQunFeedDetailRequest {
|
||||
@@ -682,7 +698,7 @@ describe('apis/group-album', () => {
|
||||
time: 1700000123n,
|
||||
feedId: 'official-feed-id',
|
||||
},
|
||||
field2: { field1: { uin: '10001' } },
|
||||
field2: { field1: { uin: '3119936551' } },
|
||||
field5: {
|
||||
albumId: 'album-id',
|
||||
batchId: 77n,
|
||||
@@ -697,6 +713,56 @@ describe('apis/group-album', () => {
|
||||
},
|
||||
});
|
||||
expect(request.body?.reqBody?.field5?.medias?.[0]?.type ?? 0).toBe(0);
|
||||
expect(Buffer.from(commentCallBytes(bridge)).subarray(0, 7).toString('hex'))
|
||||
.toBe('08cf4212001a00');
|
||||
});
|
||||
|
||||
it('falls back to the media uploader when the official feed has no owner cell', async () => {
|
||||
const bridge = mockBridge();
|
||||
bridge.sendRawPacket.mockImplementation(commentMocks((cmd) => {
|
||||
if (cmd.endsWith('GetMediaList')) {
|
||||
return packMediaList({
|
||||
mediaList: [{ type: 1, image: { lloc: 'photo-lloc' }, batchId: 77n, uploader: '3119936551' }],
|
||||
});
|
||||
}
|
||||
if (cmd.endsWith('GetQunFeedDetail')) return packFeedDetail();
|
||||
return undefined;
|
||||
}));
|
||||
|
||||
await new GroupAlbumApi(bridge as never).comment(12345, 'album-id', 'photo-lloc', 'hello');
|
||||
|
||||
expect(commentRequestOf(bridge).body?.reqBody?.field2?.field1?.uin).toBe('3119936551');
|
||||
expect(commentRequestOf(bridge).body?.field5?.user?.uin).toBe('10001');
|
||||
});
|
||||
|
||||
it('copies the official feed media cell instead of a reconstructed lloc-only cell', async () => {
|
||||
const bridge = mockBridge();
|
||||
bridge.sendRawPacket.mockImplementation(commentMocks((cmd) => {
|
||||
if (cmd.endsWith('GetQunFeedDetail')) {
|
||||
return packFeedDetail('official-feed-id', 1700000123n, {
|
||||
ownerUin: '3119936551',
|
||||
cellMedia: {
|
||||
albumId: 'feed-album',
|
||||
batchId: 88n,
|
||||
medias: [{
|
||||
type: 0,
|
||||
image: { lloc: 'feed-lloc' },
|
||||
}],
|
||||
},
|
||||
});
|
||||
}
|
||||
return undefined;
|
||||
}));
|
||||
|
||||
await new GroupAlbumApi(bridge as never).comment(12345, 'album-id', 'photo-lloc', 'hello');
|
||||
|
||||
expect(commentRequestOf(bridge).body?.reqBody?.field5).toMatchObject({
|
||||
albumId: 'feed-album',
|
||||
batchId: 88n,
|
||||
medias: [{
|
||||
image: { lloc: 'feed-lloc' },
|
||||
}],
|
||||
});
|
||||
});
|
||||
|
||||
it('comments a video with the cover location and video media type', async () => {
|
||||
|
||||
Reference in new issue
Block a user