fix(core): send group album pagination cursors

Encode the opaque media-list cursor in the protobuf page-info field while leaving the reserved field empty. This restores subsequent-page requests without changing the OneBot action or response shape.

Add an independent wire oracle so future protocol definition drift cannot make the encoder regression test pass against itself.

Fixes #245
This commit is contained in:
DrSmoothl committed 2026-07-19 16:28:01 +08:00
1 parent 613b2b1e68
commit 78101b3512
4 files changed
+31 -8

No files matched your search

+2 -2
View File
@@ -61,8 +61,8 @@ export class GroupAlbumApi {
groupId: groupId.toString(), groupId: groupId.toString(),
albumId, albumId,
field3: 0, field3: 0,
attachInfo, field4: '',
field5: '', pageInfo: attachInfo,
}, },
traceId, traceId,
extMap: [{ key: 'fc-appid', value: '100' }], extMap: [{ key: 'fc-appid', value: '100' }],
@@ -0,0 +1,10 @@
import type { pb } from '@snowluma/proton';
interface GroupAlbumMediaListReqInfoWireOracle {
reserved?: pb<4, string>;
pageInfo?: pb<5, string>;
}
export interface GroupAlbumMediaListRequestWireOracle {
reqInfo?: pb<4, GroupAlbumMediaListReqInfoWireOracle>;
}
@@ -1,10 +1,23 @@
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import type { GetMediaListResponse } from '@snowluma/proto-defs/oidb-actions/group-album'; import type { GetMediaListResponse } from '@snowluma/proto-defs/oidb-actions/group-album';
import { 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';
import { mockBridge } from './_helpers'; import { mockBridge } from './_helpers';
import type { GroupAlbumMediaListRequestWireOracle } from './group-album-wire-fixture';
describe('apis/group-album', () => { describe('apis/group-album', () => {
it('encodes the next-page cursor in the page-info field', async () => {
const bridge = mockBridge();
const cursor = '{"IndexType":"next","Loc":{"batch_id":2147483650}}';
await new GroupAlbumApi(bridge as never).getMediaList(12345, 'album-id', cursor);
const [, requestBytes] = bridge.sendRawPacket.mock.calls[0]!;
const request = protobuf_decode<GroupAlbumMediaListRequestWireOracle>(requestBytes);
expect(request.reqInfo?.pageInfo).toBe(cursor);
expect(request.reqInfo?.reserved).toBeNull();
});
it('accepts a successful media-list response with an omitted zero retCode', async () => { it('accepts a successful media-list response with an omitted zero retCode', async () => {
const bridge = mockBridge(); const bridge = mockBridge();
bridge.sendRawPacket.mockResolvedValueOnce({ bridge.sendRawPacket.mockResolvedValueOnce({
@@ -5,11 +5,11 @@ export interface ExtMapEntry {
value?: pb<2, string>; value?: pb<2, string>;
} }
export interface ReqInfo { export interface ReqInfo {
groupId?: pb<1, string>; groupId?: pb<1, string>;
albumId?: pb<2, string>; albumId?: pb<2, string>;
field3?: pb<3, int_32>; field3?: pb<3, int_32>;
attachInfo?: pb<4, string>; field4?: pb<4, string>;
field5?: pb<5, string>; pageInfo?: pb<5, string>;
} }
export interface GetMediaListRequest { export interface GetMediaListRequest {
field1?: pb<1, int_32>; field1?: pb<1, int_32>;