diff --git a/packages/mcp/src/generated/catalog.ts b/packages/mcp/src/generated/catalog.ts index 89890b4c..4d596b60 100644 --- a/packages/mcp/src/generated/catalog.ts +++ b/packages/mcp/src/generated/catalog.ts @@ -3003,7 +3003,7 @@ export const ACTIONS: CatalogAction[] = [ { "name": "get_qzone_feeds", "aliases": [], - "summary": "获取 QQ 空间好友动态(feed)", + "summary": "获取 QQ 空间好友动态(feed);page_num 仅首页可靠,深翻页需时间游标(暂未实现)", "readOnly": true, "params": [ { @@ -3014,7 +3014,7 @@ export const ACTIONS: CatalogAction[] = [ "type": "integer", "minimum": 1 }, - "desc": "页码(1 起)", + "desc": "页码(1 起;仅首页可靠)", "default": 1 }, { @@ -3037,7 +3037,7 @@ export const ACTIONS: CatalogAction[] = [ "page_num": { "type": "integer", "minimum": 1, - "description": "页码(1 起)", + "description": "页码(1 起;仅首页可靠)", "default": 1 }, "count": { diff --git a/packages/onebot/src/actions/qzone.ts b/packages/onebot/src/actions/qzone.ts index 6b9be3e8..33b2faf0 100644 --- a/packages/onebot/src/actions/qzone.ts +++ b/packages/onebot/src/actions/qzone.ts @@ -32,9 +32,9 @@ export const actions = [ defineAction({ name: 'get_qzone_feeds', readOnly: true, - summary: '获取 QQ 空间好友动态(feed)', + summary: '获取 QQ 空间好友动态(feed);page_num 仅首页可靠,深翻页需时间游标(暂未实现)', params: { - page_num: f.int({ min: 1 }).describe('页码(1 起)').default(1), + page_num: f.int({ min: 1 }).describe('页码(1 起;仅首页可靠)').default(1), count: f.int({ min: 1, max: 50 }).describe('本页数量').default(10), }, run: async (p, ctx) => { diff --git a/packages/protocol/src/web/qzone.ts b/packages/protocol/src/web/qzone.ts index 976b74e9..b15b5ec2 100644 --- a/packages/protocol/src/web/qzone.ts +++ b/packages/protocol/src/web/qzone.ts @@ -220,6 +220,9 @@ export function mapFeeds(data: RawFeedsResponse): QzoneFeedsResult { nickname: f.nickname ?? '', time: Number(f.abstime ?? 0), appid: Number(f.appid ?? 0), + // `key` is the per-feed handle; `feedskey` is its older alias on some + // feed types. They name the same per-feed identifier here (NOT the + // list-level next-page cursor, which lives on data.* not the item). key: String(f.key ?? f.feedskey ?? ''), html: f.html ?? '', })), @@ -228,12 +231,24 @@ export function mapFeeds(data: RawFeedsResponse): QzoneFeedsResult { } /** - * Fetch the 好友动态 (friend-feed) list via ic2.qzone.qq.com's - * feeds3_html_more CGI. `pageNum` is 1-based; `count` is the page size. - * Same cookie/g_tk plumbing and throw-on-auth-failure contract as - * {@link getQzoneMsgList}: a missing `data.data` array means the cookie/ - * auth failed and throws, whereas a genuinely empty feed (`data.data: []`) - * maps to an empty list. + * Fetch the 好友动态 (friend-feed) list via the feeds3_html_more CGI on + * ic2.qzone.qq.com, routed through the h5.qzone.qq.com proxy gateway — the + * same gateway {@link getQzoneMsgList} and group-album use, because the + * qzone.qq.com cookie jar only authenticates against the proxy origin + * (hitting ic2 directly fails the referer/same-origin check). Body is + * requested as JSONP (`format=jsonp` + a callback) and parsed with the + * shared tolerant parser, matching slice-1's contract exactly. + * + * `pageNum` is 1-based; `count` is the page size. PAGINATION CAVEAT: this + * CGI's reliable deep-pagination is driven by a time cursor + * (begintime/externparam/usertime carried forward from the previous page), + * which we do not yet thread — so `pageNum` is dependable for the first + * page and `has_more` only signals whether more exist, not a stable + * page-2 fetch. Cursor pagination is deferred until a live capture. + * + * Same throw-on-auth-failure contract as {@link getQzoneMsgList}: a missing + * `data.data` array means the cookie/auth failed and throws, whereas a + * genuinely empty feed (`data.data: []`) maps to an empty list. */ export async function getQzoneFeeds( cookieObject: Record, @@ -246,7 +261,7 @@ export async function getQzoneFeeds( } const bkn = getBknFromCookie(cookieObject); - const url = `https://ic2.qzone.qq.com/cgi-bin/feeds/feeds3_html_more?${new URLSearchParams( + const url = `https://h5.qzone.qq.com/proxy/domain/ic2.qzone.qq.com/cgi-bin/feeds/feeds3_html_more?${new URLSearchParams( { uin: selfUin, scope: '0', @@ -260,8 +275,9 @@ export async function getQzoneFeeds( aisortOffset: '0', aisortBeginTime: '0', begintime: '0', - format: 'json', g_tk: bkn, + callback: '_preloadCallback', + format: 'jsonp', useutf8: '1', outputhtmlfeed: '1', }, diff --git a/packages/protocol/tests/web/qzone.test.ts b/packages/protocol/tests/web/qzone.test.ts index 7e17d58e..20d724a9 100644 --- a/packages/protocol/tests/web/qzone.test.ts +++ b/packages/protocol/tests/web/qzone.test.ts @@ -161,12 +161,17 @@ describe('qzone / getQzoneFeeds (HTTP layer)', () => { expect(method).toBe('GET'); expect(body).toBe(''); expect((headers as Record).Cookie).toContain('p_skey=PSK'); - expect(url).toContain('https://ic2.qzone.qq.com/cgi-bin/feeds/feeds3_html_more?'); + // Routed through the h5.qzone proxy gateway (NOT ic2 directly), because + // the qzone.qq.com cookie jar only authenticates against the proxy origin. + expect(url).toContain('https://h5.qzone.qq.com/proxy/domain/ic2.qzone.qq.com/cgi-bin/feeds/feeds3_html_more?'); const q = new URLSearchParams((url as string).split('?')[1]); expect(q.get('uin')).toBe('10000'); expect(q.get('pagenum')).toBe('2'); expect(q.get('count')).toBe('10'); expect(q.get('g_tk')).toBe(expectedGtk); + // The request asks for JSONP — pin it so the JSONP-bodied response above + // actually exercises the requested format (not just the tolerant parser). + expect(q.get('format')).toBe('jsonp'); }); it('returns an empty list (not a throw) for a genuinely empty feed', async () => {