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:
4 files changed
+32
-9
No files matched your search
@@ -61,8 +61,8 @@ export class GroupAlbumApi {
|
||||
groupId: groupId.toString(),
|
||||
albumId,
|
||||
field3: 0,
|
||||
attachInfo,
|
||||
field5: '',
|
||||
field4: '',
|
||||
pageInfo: attachInfo,
|
||||
},
|
||||
traceId,
|
||||
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 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 { mockBridge } from './_helpers';
|
||||
import type { GroupAlbumMediaListRequestWireOracle } from './group-album-wire-fixture';
|
||||
|
||||
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 () => {
|
||||
const bridge = mockBridge();
|
||||
bridge.sendRawPacket.mockResolvedValueOnce({
|
||||
|
||||
@@ -5,11 +5,11 @@ export interface ExtMapEntry {
|
||||
value?: pb<2, string>;
|
||||
}
|
||||
export interface ReqInfo {
|
||||
groupId?: pb<1, string>;
|
||||
albumId?: pb<2, string>;
|
||||
field3?: pb<3, int_32>;
|
||||
attachInfo?: pb<4, string>;
|
||||
field5?: pb<5, string>;
|
||||
groupId?: pb<1, string>;
|
||||
albumId?: pb<2, string>;
|
||||
field3?: pb<3, int_32>;
|
||||
field4?: pb<4, string>;
|
||||
pageInfo?: pb<5, string>;
|
||||
}
|
||||
export interface GetMediaListRequest {
|
||||
field1?: pb<1, int_32>;
|
||||
@@ -213,4 +213,4 @@ export interface DeleteMediasResponse {
|
||||
field1?: pb<1, int_32>;
|
||||
field2?: pb<2, int_32>;
|
||||
field3?: pb<3, string>;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user