fix(qzone): route feeds3_html_more through proxy + pin JSONP format

Adversarial review of the get_qzone_feeds slice (verdict NEEDS-FIXES):
- Host: hit ic2.qzone.qq.com directly, bypassing the proxy gateway that
  slice-1/group-album use. The qzone.qq.com cookie jar only authenticates
  against the proxy origin, so the direct call would fail referer/origin.
  Now routed through h5.qzone.qq.com/proxy/domain/ic2.qzone.qq.com/...
- Format: requested format=json but the test fed a JSONP body, so the
  requested format was never pinned. Aligned to slice-1's
  format=jsonp + callback=_preloadCallback; the test now asserts format.
- Pagination: documented honestly that page_num is reliable only for the
  first page (deep paging needs a time cursor, deferred) — in the
  docstring and the action summary/param desc.
- Clarified the key/feedskey fallback is the per-feed handle, not a cursor.
This commit is contained in:
DrSmoothl committed 2026-06-20 01:36:04 +08:00
1 parent 094dc12f0c
commit 5164ba9e39
4 files changed
+35 -14

No files matched your search

+3 -3
View File
@@ -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": {
+2 -2
View File
@@ -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) => {
+24 -8
View File
@@ -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<string, string>,
@@ -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',
},
+6 -1
View File
@@ -161,12 +161,17 @@ describe('qzone / getQzoneFeeds (HTTP layer)', () => {
expect(method).toBe('GET');
expect(body).toBe('');
expect((headers as Record<string, string>).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 () => {