fix(group-album): use native QQ album service

Replace the lossy Qzone album-list endpoint with the QQ NT AlbumService protobuf request. Preserve creator nicknames and expose native pagination for get_qun_album_list.
This commit is contained in:
DrSmoothl committed 2026-07-20 13:03:16 +08:00
1 parent 8df62d6486
commit 06c26dee87
8 files changed
+581 -80

No files matched your search

+212 -8
View File
@@ -1,19 +1,101 @@
import type { JsonObject, JsonValue } from '@snowluma/common/json';
import { createLogger } from '@snowluma/common/logger';
import type {
AlbumCreator,
DeleteMediasRequest,
DeleteMediasResponse,
DoQunCommentRequest,
DoQunCommentResponse,
DoQunLikeRequest,
DoQunLikeResponse,
GetAlbumListRequest,
GetAlbumListResponse,
GroupAlbumInfo as GroupAlbumInfoWire,
GetMediaListRequest,
GetMediaListResponse,
MediaInfo,
} from '@snowluma/proto-defs/oidb-actions/group-album';
import { getGroupAlbumList, uploadImageToGroupAlbum } from '@snowluma/protocol/web/group-album';
import { uploadImageToGroupAlbum } from '@snowluma/protocol/web/group-album';
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import type { BridgeContext } from '../bridge-context';
const log = createLogger('Bridge.GroupAlbum');
const GET_ALBUM_LIST_CMD = 'QunAlbum.trpc.qzone.webapp_qun_media.QunMedia.GetAlbumList';
const GET_ALBUM_LIST_SEQ = 3331;
function uint64ToString(value: bigint | undefined): string {
return (value ?? 0n).toString();
}
function uint64ToSafeNumber(value: bigint | undefined, fieldName: string): number {
const normalized = value ?? 0n;
if (normalized > BigInt(Number.MAX_SAFE_INTEGER)) {
throw new Error(`group album ${fieldName} exceeds Number.MAX_SAFE_INTEGER: ${normalized}`);
}
return Number(normalized);
}
function normalizeAlbumCreator(creator: AlbumCreator | undefined): QunAlbumCreator | undefined {
if (!creator) return undefined;
return {
uid: creator.uid ?? '',
nick: creator.nick ?? '',
is_sweet: creator.isSweet ?? false,
is_special: creator.isSpecial ?? false,
is_super_like: creator.isSuperLike ?? false,
custom_id: creator.customId ?? '',
poly_id: creator.polyId ?? '',
portrait: creator.portrait ?? '',
can_follow: creator.canFollow ?? 0,
isfollowed: creator.isFollowed ?? 0,
uin: creator.uin ?? '',
ditto_uin: creator.dittoUin ?? '',
};
}
function normalizeQunAlbum(album: GroupAlbumInfoWire): QunAlbumInfo {
const normalized: QunAlbumInfo = {
album_id: album.albumId ?? '',
owner: album.owner ?? '',
name: album.name ?? '',
desc: album.description ?? '',
create_time: uint64ToString(album.createTime),
modify_time: uint64ToString(album.modifyTime),
last_upload_time: uint64ToString(album.lastUploadTime),
upload_number: uint64ToString(album.uploadNumber),
top_flag: uint64ToString(album.topFlag),
busi_type: album.busiType ?? 0,
status: album.status ?? 0,
allow_share: album.allowShare ?? false,
is_subscribe: album.isSubscribe ?? false,
bitmap: album.bitmap ?? '',
is_share_album: album.isShareAlbum ?? false,
qz_album_type: album.qzAlbumType ?? 0,
cover_type: album.coverType ?? 0,
default_desc: album.defaultDesc ?? '',
sort_type: album.sortType ?? 0,
};
const creator = normalizeAlbumCreator(album.creator);
if (creator) normalized.creator = creator;
return normalized;
}
function toLegacyAlbum(album: GroupAlbumInfoWire): GroupAlbumInfo {
const creator = normalizeAlbumCreator(album.creator);
return {
id: album.albumId ?? '',
name: album.name ?? '',
picNum: uint64ToSafeNumber(album.uploadNumber, 'upload_number'),
createTime: uint64ToSafeNumber(album.createTime, 'create_time'),
desc: album.description ?? '',
owner: album.owner ?? '',
createuin: creator?.uin || album.owner || creator?.uid || '',
// QQ NT's AlbumService returns this as a normal UTF-8 protobuf string.
// Unlike the legacy Qzone HTTP endpoint, it does not rewrite Unicode
// emoji into ambiguous [em]...[/em] tags.
createnickname: creator?.nick ?? '',
};
}
function convertBigIntToString(obj: unknown): JsonValue {
if (obj === null || obj === undefined) return null;
@@ -33,13 +115,73 @@ function convertBigIntToString(obj: unknown): JsonValue {
export class GroupAlbumApi {
constructor(private readonly ctx: BridgeContext) { }
// 列出群相册(基于 qzone.qq.com 的 HTTP Cookie)。
private async fetchAlbumList(groupId: number, attachInfo: string): Promise<GroupAlbumWireResult> {
const traceId = `_${Date.now()}_${Math.floor(Math.random() * 100000)}`;
const body = protobuf_encode<GetAlbumListRequest>({
seq: GET_ALBUM_LIST_SEQ,
field2: new Uint8Array(0),
field3: new Uint8Array(0),
data: {
groupId: groupId.toString(),
attachInfo,
},
traceId,
extMap: [{ key: 'fc-appid', value: '100' }],
});
log.debug(
'get album list request: group=%d cursorChars=%d requestBytes=%d',
groupId,
attachInfo.length,
body.length,
);
const result = await this.ctx.sendRawPacket(GET_ALBUM_LIST_CMD, body, 15000);
if (!result.success || !result.gotResponse || !result.responseData) {
throw new Error(
`get group album list transport failed: ${result.errorMessage || `code ${result.errorCode}`}`,
);
}
const response = protobuf_decode<GetAlbumListResponse>(result.responseData);
const resultCode = response.result ?? 0;
if (resultCode !== 0) {
throw new Error(
`get group album list failed: result=${resultCode}, error=${response.errorText || 'unknown'}`,
);
}
const normalized: GroupAlbumWireResult = {
albumList: response.data?.albumList ?? [],
attachInfo: response.data?.attachInfo ?? '',
hasMore: response.data?.hasMore ?? false,
};
log.debug(
'get album list response: group=%d albums=%d hasMore=%s cursorChars=%d responseBytes=%d',
groupId,
normalized.albumList.length,
String(normalized.hasMore),
normalized.attachInfo.length,
result.responseData.length,
);
return normalized;
}
/** QQ NT AlbumService-backed list, including its pagination cursor. */
async listQun(groupId: number, attachInfo = ''): Promise<QunAlbumListResult> {
const result = await this.fetchAlbumList(groupId, attachInfo);
return {
albumList: result.albumList.map(normalizeQunAlbum),
attachInfo: result.attachInfo,
hasMore: result.hasMore,
};
}
// OneBot compatibility shape used by get_group_album_list.
async list(groupId: number): Promise<GroupAlbumList> {
const groupCode = groupId.toString();
const uin = this.ctx.identity.uin;
const cookieObject = await this.ctx.apis.web.getCookies('qzone.qq.com');
const albumData = await getGroupAlbumList(cookieObject, groupCode, uin);
return albumData?.album || [];
const result = await this.fetchAlbumList(groupId, '');
return result.albumList.map(toLegacyAlbum);
}
// 上传图片到现有相册(HTTP 分片上传)。
@@ -269,7 +411,69 @@ export interface GroupAlbumMediaResult {
nextAttachInfo: string;
}
export type GroupAlbumList = NonNullable<Awaited<ReturnType<typeof getGroupAlbumList>>>['album'];
interface GroupAlbumWireResult {
albumList: GroupAlbumInfoWire[];
attachInfo: string;
hasMore: boolean;
}
export interface GroupAlbumInfo {
id: string;
name: string;
picNum: number;
createTime: number;
desc: string;
owner: string;
createuin: string;
createnickname: string;
[key: string]: JsonValue;
}
export type GroupAlbumList = GroupAlbumInfo[];
export interface QunAlbumCreator {
uid: string;
nick: string;
is_sweet: boolean;
is_special: boolean;
is_super_like: boolean;
custom_id: string;
poly_id: string;
portrait: string;
can_follow: number;
isfollowed: number;
uin: string;
ditto_uin: string;
}
export interface QunAlbumInfo {
album_id: string;
owner: string;
name: string;
desc: string;
create_time: string;
modify_time: string;
last_upload_time: string;
upload_number: string;
creator?: QunAlbumCreator;
top_flag: string;
busi_type: number;
status: number;
allow_share: boolean;
is_subscribe: boolean;
bitmap: string;
is_share_album: boolean;
qz_album_type: number;
cover_type: number;
default_desc: string;
sort_type: number;
}
export interface QunAlbumListResult {
albumList: QunAlbumInfo[];
attachInfo: string;
hasMore: boolean;
}
export interface GroupAlbumCommentResult {
id: string;
@@ -1,4 +1,23 @@
import type { pb } from '@snowluma/proton';
import type { bytes, int_32, pb, pb_repeated } from '@snowluma/proton';
interface GroupAlbumListReqDataWireOracle {
groupId?: pb<1, string>;
cursor?: pb<2, string>;
}
interface GroupAlbumListExtWireOracle {
key?: pb<1, string>;
value?: pb<2, string>;
}
export interface GroupAlbumListRequestWireOracle {
seq?: pb<1, int_32>;
field2?: pb<2, bytes>;
field3?: pb<3, bytes>;
data?: pb<4, GroupAlbumListReqDataWireOracle>;
traceId?: pb<5, string>;
extMap?: pb_repeated<10, GroupAlbumListExtWireOracle>;
}
interface GroupAlbumMediaListReqInfoWireOracle {
reserved?: pb<4, string>;
+122 -2
View File
@@ -1,11 +1,131 @@
import { describe, expect, it } from 'vitest';
import type { GetMediaListResponse } from '@snowluma/proto-defs/oidb-actions/group-album';
import type {
GetAlbumListResponse,
GetMediaListResponse,
} from '@snowluma/proto-defs/oidb-actions/group-album';
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';
import type {
GroupAlbumListRequestWireOracle,
GroupAlbumMediaListRequestWireOracle,
} from './group-album-wire-fixture';
describe('apis/group-album', () => {
it('uses QQ NT AlbumService and puts the pagination cursor in request body field 2', async () => {
const bridge = mockBridge();
const cursor = '{"IndexType":"next"}';
await new GroupAlbumApi(bridge as never).listQun(12345, cursor);
const [serviceCmd, requestBytes, timeoutMs] = bridge.sendRawPacket.mock.calls[0]!;
expect(serviceCmd).toBe('QunAlbum.trpc.qzone.webapp_qun_media.QunMedia.GetAlbumList');
expect(timeoutMs).toBe(15000);
const request = protobuf_decode<GroupAlbumListRequestWireOracle>(requestBytes);
expect(request.seq).toBe(3331);
expect(request.data).toEqual({ groupId: '12345', cursor });
expect(request.extMap).toEqual([{ key: 'fc-appid', value: '100' }]);
// QQ NT's codec writes the two empty common-envelope byte fields rather
// than omitting them: field1=3331, field2="", field3="".
expect(Buffer.from(requestBytes).subarray(0, 7).toString('hex'))
.toBe('08831a12001a00');
});
it('preserves Unicode emoji and literal QQ-em tags in the legacy creator nickname', async () => {
const bridge = mockBridge();
bridge.sendRawPacket.mockResolvedValueOnce({
success: true,
gotResponse: true,
errorCode: 0,
errorMessage: '',
responseData: Buffer.from(protobuf_encode<GetAlbumListResponse>({
seq: 3331,
data: {
albumList: [{
albumId: 'album-id',
owner: '10001',
name: '测试相册',
description: 'desc',
createTime: 1700000000n,
uploadNumber: 5n,
creator: {
uid: 'u_creator',
uin: '10001',
nick: '😂[em]e328514[/em]',
},
}],
},
})),
});
const result = await new GroupAlbumApi(bridge as never).list(12345);
expect(result).toEqual([{
id: 'album-id',
name: '测试相册',
picNum: 5,
createTime: 1700000000,
desc: 'desc',
owner: '10001',
createuin: '10001',
createnickname: '😂[em]e328514[/em]',
}]);
});
it('returns the native AlbumService cursor and creator fields for get_qun_album_list', async () => {
const bridge = mockBridge();
bridge.sendRawPacket.mockResolvedValueOnce({
success: true,
gotResponse: true,
errorCode: 0,
errorMessage: '',
responseData: Buffer.from(protobuf_encode<GetAlbumListResponse>({
data: {
albumList: [{
albumId: 'album-id',
name: '测试相册',
createTime: 1700000000n,
uploadNumber: 5n,
creator: { uin: '10001', nick: '😂' },
}],
attachInfo: 'next-cursor',
hasMore: true,
},
})),
});
const result = await new GroupAlbumApi(bridge as never).listQun(12345);
expect(result.attachInfo).toBe('next-cursor');
expect(result.hasMore).toBe(true);
expect(result.albumList[0]).toMatchObject({
album_id: 'album-id',
name: '测试相册',
create_time: '1700000000',
upload_number: '5',
creator: { uin: '10001', nick: '😂' },
});
});
it('surfaces AlbumService response errors instead of falling back to the lossy web endpoint', async () => {
const bridge = mockBridge();
bridge.sendRawPacket.mockResolvedValueOnce({
success: true,
gotResponse: true,
errorCode: 0,
errorMessage: '',
responseData: Buffer.from(protobuf_encode<GetAlbumListResponse>({
seq: 3331,
result: 1001,
errorText: 'permission denied',
})),
});
await expect(new GroupAlbumApi(bridge as never).list(12345))
.rejects.toThrow('result=1001, error=permission denied');
});
it('encodes the next-page cursor in the page-info field', async () => {
const bridge = mockBridge();
const cursor = '{"IndexType":"next","Loc":{"batch_id":2147483650}}';
+52 -11
View File
@@ -3432,13 +3432,23 @@
"createTime": {
"type": "integer",
"description": "相册创建时间(unix 秒)"
},
"createuin": {
"type": "string",
"description": "相册创建者 QQ 号"
},
"createnickname": {
"type": "string",
"description": "相册创建者昵称(原始 Unicode)"
}
},
"required": [
"id",
"name",
"picNum",
"createTime"
"createTime",
"createuin",
"createnickname"
]
}
},
@@ -5480,7 +5490,7 @@
{
"name": "get_qun_album_list",
"aliases": [],
"returns": "NapCat 风格的相册列表封套:{album_list, attach_info, has_more}(本实现 attach_info 恒为空串、has_more 恒为 false)。",
"returns": "NapCat 风格的相册列表封套:{album_list, attach_info, has_more}。",
"returnsSchema": {
"type": "object",
"properties": {
@@ -5494,34 +5504,52 @@
"type": "string",
"description": "相册 id"
},
"album_name": {
"name": {
"type": "string",
"description": "相册名称"
},
"create_time": {
"type": "integer",
"type": "string",
"description": "相册创建时间(unix 秒)"
},
"pic_num": {
"type": "integer",
"description": "相册内照片数量"
"upload_number": {
"type": "string",
"description": "相册内媒体数量"
},
"creator": {
"type": "object",
"description": "相册创建者信息",
"properties": {
"uin": {
"type": "string",
"description": "创建者 QQ 号"
},
"uid": {
"type": "string",
"description": "创建者 UID"
},
"nick": {
"type": "string",
"description": "创建者原始 Unicode 昵称"
}
}
}
},
"required": [
"album_id",
"album_name",
"name",
"create_time",
"pic_num"
"upload_number"
]
}
},
"attach_info": {
"type": "string",
"description": "分页游标(本 web 实现一次取满,恒为空串)"
"description": "下一页分页游标"
},
"has_more": {
"type": "boolean",
"description": "是否还有更多(本 web 实现恒为 false)"
"description": "是否还有更多"
}
},
"required": [
@@ -5542,6 +5570,15 @@
"minimum": 1
},
"desc": "群号"
},
{
"name": "attach_info",
"type": "string",
"required": false,
"schema": {
"type": "string"
},
"default": ""
}
],
"invariants": [],
@@ -5553,6 +5590,10 @@
"minimum": 1,
"description": "群号",
"x-role": "group_id"
},
"attach_info": {
"type": "string",
"default": ""
}
},
"required": [
+52 -11
View File
@@ -3435,13 +3435,23 @@ export const ACTIONS: CatalogAction[] = [
"createTime": {
"type": "integer",
"description": "相册创建时间(unix 秒)"
},
"createuin": {
"type": "string",
"description": "相册创建者 QQ 号"
},
"createnickname": {
"type": "string",
"description": "相册创建者昵称(原始 Unicode)"
}
},
"required": [
"id",
"name",
"picNum",
"createTime"
"createTime",
"createuin",
"createnickname"
]
}
},
@@ -5483,7 +5493,7 @@ export const ACTIONS: CatalogAction[] = [
{
"name": "get_qun_album_list",
"aliases": [],
"returns": "NapCat 风格的相册列表封套:{album_list, attach_info, has_more}(本实现 attach_info 恒为空串、has_more 恒为 false)。",
"returns": "NapCat 风格的相册列表封套:{album_list, attach_info, has_more}。",
"returnsSchema": {
"type": "object",
"properties": {
@@ -5497,34 +5507,52 @@ export const ACTIONS: CatalogAction[] = [
"type": "string",
"description": "相册 id"
},
"album_name": {
"name": {
"type": "string",
"description": "相册名称"
},
"create_time": {
"type": "integer",
"type": "string",
"description": "相册创建时间(unix 秒)"
},
"pic_num": {
"type": "integer",
"description": "相册内照片数量"
"upload_number": {
"type": "string",
"description": "相册内媒体数量"
},
"creator": {
"type": "object",
"description": "相册创建者信息",
"properties": {
"uin": {
"type": "string",
"description": "创建者 QQ 号"
},
"uid": {
"type": "string",
"description": "创建者 UID"
},
"nick": {
"type": "string",
"description": "创建者原始 Unicode 昵称"
}
}
}
},
"required": [
"album_id",
"album_name",
"name",
"create_time",
"pic_num"
"upload_number"
]
}
},
"attach_info": {
"type": "string",
"description": "分页游标(本 web 实现一次取满,恒为空串)"
"description": "下一页分页游标"
},
"has_more": {
"type": "boolean",
"description": "是否还有更多(本 web 实现恒为 false)"
"description": "是否还有更多"
}
},
"required": [
@@ -5545,6 +5573,15 @@ export const ACTIONS: CatalogAction[] = [
"minimum": 1
},
"desc": "群号"
},
{
"name": "attach_info",
"type": "string",
"required": false,
"schema": {
"type": "string"
},
"default": ""
}
],
"invariants": [],
@@ -5556,6 +5593,10 @@ export const ACTIONS: CatalogAction[] = [
"minimum": 1,
"description": "群号",
"x-role": "group_id"
},
"attach_info": {
"type": "string",
"default": ""
}
},
"required": [
+28 -26
View File
@@ -17,8 +17,10 @@ export const actions = [
name: { type: 'string', description: '相册名称' },
picNum: { type: 'integer', description: '相册内照片数量' },
createTime: { type: 'integer', description: '相册创建时间(unix 秒)' },
createuin: { type: 'string', description: '相册创建者 QQ 号' },
createnickname: { type: 'string', description: '相册创建者昵称(原始 Unicode)' },
},
required: ['id', 'name', 'picNum', 'createTime'],
required: ['id', 'name', 'picNum', 'createTime', 'createuin', 'createnickname'],
},
},
run: async (p, ctx) => {
@@ -27,17 +29,11 @@ export const actions = [
},
}),
// get_qun_album_list — NapCat-named/shaped variant of get_group_album_list.
// NapCat's own impl calls the kernel AlbumService (trpc, not statically
// recoverable); we instead reuse the qun_list_album_v2 web API (the same one
// get_group_album_list uses) and reshape into NapCat's
// {album_list, attach_info, has_more} envelope. The web endpoint fetches up
// to 1000 albums in one shot, so attach_info/has_more are ''/false (no cursor
// pagination); cover_url isn't returned by this endpoint.
// get_qun_album_list — NapCat-compatible view of QQ NT's AlbumService.
groupAction({
name: 'get_qun_album_list',
readOnly: true,
returns: 'NapCat 风格的相册列表封套:{album_list, attach_info, has_more}(本实现 attach_info 恒为空串、has_more 恒为 false)。',
returns: 'NapCat 风格的相册列表封套:{album_list, attach_info, has_more}。',
returnsSchema: {
type: 'object',
properties: {
@@ -48,30 +44,37 @@ export const actions = [
type: 'object',
properties: {
album_id: { type: 'string', description: '相册 id' },
album_name: { type: 'string', description: '相册名称' },
create_time: { type: 'integer', description: '相册创建时间(unix 秒)' },
pic_num: { type: 'integer', description: '相册内照片数量' },
name: { type: 'string', description: '相册名称' },
create_time: { type: 'string', description: '相册创建时间(unix 秒)' },
upload_number: { type: 'string', description: '相册内媒体数量' },
creator: {
type: 'object',
description: '相册创建者信息',
properties: {
uin: { type: 'string', description: '创建者 QQ 号' },
uid: { type: 'string', description: '创建者 UID' },
nick: { type: 'string', description: '创建者原始 Unicode 昵称' },
},
},
},
required: ['album_id', 'album_name', 'create_time', 'pic_num'],
required: ['album_id', 'name', 'create_time', 'upload_number'],
},
},
attach_info: { type: 'string', description: '分页游标(本 web 实现一次取满,恒为空串)' },
has_more: { type: 'boolean', description: '是否还有更多(本 web 实现恒为 false)' },
attach_info: { type: 'string', description: '下一页分页游标' },
has_more: { type: 'boolean', description: '是否还有更多' },
},
required: ['album_list', 'attach_info', 'has_more'],
},
params: {
attach_info: f.string().default(''),
},
run: async (p, ctx) => {
const albumList = await ctx.bridge.apis.groupAlbum.list(p.group_id);
const result = await ctx.bridge.apis.groupAlbum.listQun(p.group_id, p.attach_info);
return okResponse({
album_list: albumList.map((a) => ({
album_id: a.id,
album_name: a.name,
create_time: a.createTime,
pic_num: a.picNum,
})),
attach_info: '',
has_more: false,
});
album_list: result.albumList,
attach_info: result.attachInfo,
has_more: result.hasMore,
} as unknown as JsonValue);
},
}),
@@ -166,4 +169,3 @@ export const actions = [
},
}),
];
+27 -20
View File
@@ -1269,31 +1269,38 @@ describe('extended-actions / TierB ③ share + doubt + robot-option', () => {
});
});
// ─── napcat-parity: get_qun_album_list (NapCat-shaped envelope over existing web API) ───
// SnowLuma already exposes the qun_list_album_v2 web API as get_group_album_list
// (raw array). NapCat's get_qun_album_list wraps it as {album_list, attach_info,
// has_more} with {album_id, album_name, create_time, ...} items. We add the
// NapCat-named/shaped action reusing the same bridge call.
// ─── napcat-parity: get_qun_album_list (QQ NT AlbumService) ───
describe('extended-actions / get_qun_album_list', () => {
it('maps the album list into the napcat {album_list, attach_info, has_more} envelope', async () => {
const list = vi.fn(async () => [
{ id: 'a1', name: '相册一', picNum: 5, createTime: 1700000000 },
{ id: 'a2', name: '相册二', picNum: 0, createTime: 1700000100 },
]);
const bridge = fakeBridge({ apis: { groupAlbum: { list } } });
const res = await makeHandler(fakeCtx(bridge)).handle('get_qun_album_list', { group_id: 12345 });
expect(list).toHaveBeenCalledWith(12345);
it('forwards the pagination cursor and returns the native AlbumService envelope', async () => {
const albumList = [{
album_id: 'a1',
name: '相册一',
create_time: '1700000000',
upload_number: '5',
creator: { uin: '10001', nick: '😂[em]e328514[/em]' },
}];
const listQun = vi.fn(async () => ({
albumList,
attachInfo: 'next-cursor',
hasMore: true,
}));
const bridge = fakeBridge({ apis: { groupAlbum: { listQun } } });
const res = await makeHandler(fakeCtx(bridge)).handle('get_qun_album_list', {
group_id: 12345,
attach_info: 'current-cursor',
});
expect(listQun).toHaveBeenCalledWith(12345, 'current-cursor');
expect(res.status).toBe('ok');
expect(res.data).toMatchObject({ attach_info: '', has_more: false });
expect((res.data as any).album_list).toEqual([
{ album_id: 'a1', album_name: '相册一', create_time: 1700000000, pic_num: 5 },
{ album_id: 'a2', album_name: '相册二', create_time: 1700000100, pic_num: 0 },
]);
expect(res.data).toEqual({
album_list: albumList,
attach_info: 'next-cursor',
has_more: true,
});
});
it('surfaces failure as a failed response', async () => {
const list = vi.fn(async () => { throw new Error('no pskey'); });
const bridge = fakeBridge({ apis: { groupAlbum: { list } } });
const listQun = vi.fn(async () => { throw new Error('album service unavailable'); });
const bridge = fakeBridge({ apis: { groupAlbum: { listQun } } });
const res = await makeHandler(fakeCtx(bridge)).handle('get_qun_album_list', { group_id: 1 });
expect(res.status).toBe('failed');
});
@@ -1,9 +1,76 @@
import type { pb, pb_repeated, int_32, uint_32, uint_64, bool, bytes } from '@snowluma/proton';
import type { pb, pb_optional, pb_repeated, int_32, uint_32, uint_64, bool, bytes } from '@snowluma/proton';
export interface ExtMapEntry {
key?: pb<1, string>;
value?: pb<2, string>;
}
// QunAlbum.trpc.qzone.webapp_qun_media.QunMedia.GetAlbumList
//
// Recovered from QQ NT's AlbumService codec. The service uses the same
// common request/response envelope as the other QunAlbum methods in this
// file; the operation-specific request body only contains the group id and
// the pagination cursor.
export interface GetAlbumListReqData {
groupId?: pb<1, string>;
attachInfo?: pb_optional<2, string>;
}
export interface GetAlbumListRequest {
seq?: pb<1, int_32>;
field2?: pb_optional<2, bytes>;
field3?: pb_optional<3, bytes>;
data?: pb<4, GetAlbumListReqData>;
traceId?: pb<5, string>;
extMap?: pb_repeated<10, ExtMapEntry>;
}
export interface AlbumCreator {
uid?: pb<1, string>;
nick?: pb<2, string>;
isSweet?: pb<5, bool>;
isSpecial?: pb<6, bool>;
isSuperLike?: pb<7, bool>;
customId?: pb<8, string>;
polyId?: pb<9, string>;
portrait?: pb<10, string>;
canFollow?: pb<11, int_32>;
isFollowed?: pb<12, int_32>;
uin?: pb<13, string>;
dittoUin?: pb<14, string>;
}
export interface GroupAlbumInfo {
albumId?: pb<1, string>;
owner?: pb<2, string>;
name?: pb<3, string>;
description?: pb<4, string>;
createTime?: pb<5, uint_64>;
modifyTime?: pb<6, uint_64>;
lastUploadTime?: pb<7, uint_64>;
uploadNumber?: pb<8, uint_64>;
creator?: pb<10, AlbumCreator>;
topFlag?: pb<11, uint_64>;
busiType?: pb<12, int_32>;
status?: pb<13, int_32>;
allowShare?: pb<15, bool>;
isSubscribe?: pb<16, bool>;
bitmap?: pb<17, string>;
isShareAlbum?: pb<18, bool>;
qzAlbumType?: pb<20, int_32>;
coverType?: pb<23, int_32>;
defaultDesc?: pb<26, string>;
sortType?: pb<30, int_32>;
}
export interface GetAlbumListRspData {
albumList?: pb_repeated<1, GroupAlbumInfo>;
attachInfo?: pb<2, string>;
hasMore?: pb<3, bool>;
}
export interface GetAlbumListResponse {
seq?: pb<1, int_32>;
result?: pb<2, int_32>;
errorText?: pb<3, string>;
data?: pb<4, GetAlbumListRspData>;
}
export interface ReqInfo {
groupId?: pb<1, string>;
albumId?: pb<2, string>;