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:
4 files changed
+35
-14
No files matched your search
@@ -3003,7 +3003,7 @@ export const ACTIONS: CatalogAction[] = [
|
|||||||
{
|
{
|
||||||
"name": "get_qzone_feeds",
|
"name": "get_qzone_feeds",
|
||||||
"aliases": [],
|
"aliases": [],
|
||||||
"summary": "获取 QQ 空间好友动态(feed)",
|
"summary": "获取 QQ 空间好友动态(feed);page_num 仅首页可靠,深翻页需时间游标(暂未实现)",
|
||||||
"readOnly": true,
|
"readOnly": true,
|
||||||
"params": [
|
"params": [
|
||||||
{
|
{
|
||||||
@@ -3014,7 +3014,7 @@ export const ACTIONS: CatalogAction[] = [
|
|||||||
"type": "integer",
|
"type": "integer",
|
||||||
"minimum": 1
|
"minimum": 1
|
||||||
},
|
},
|
||||||
"desc": "页码(1 起)",
|
"desc": "页码(1 起;仅首页可靠)",
|
||||||
"default": 1
|
"default": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -3037,7 +3037,7 @@ export const ACTIONS: CatalogAction[] = [
|
|||||||
"page_num": {
|
"page_num": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"minimum": 1,
|
"minimum": 1,
|
||||||
"description": "页码(1 起)",
|
"description": "页码(1 起;仅首页可靠)",
|
||||||
"default": 1
|
"default": 1
|
||||||
},
|
},
|
||||||
"count": {
|
"count": {
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ export const actions = [
|
|||||||
defineAction({
|
defineAction({
|
||||||
name: 'get_qzone_feeds',
|
name: 'get_qzone_feeds',
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
summary: '获取 QQ 空间好友动态(feed)',
|
summary: '获取 QQ 空间好友动态(feed);page_num 仅首页可靠,深翻页需时间游标(暂未实现)',
|
||||||
params: {
|
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),
|
count: f.int({ min: 1, max: 50 }).describe('本页数量').default(10),
|
||||||
},
|
},
|
||||||
run: async (p, ctx) => {
|
run: async (p, ctx) => {
|
||||||
|
|||||||
@@ -220,6 +220,9 @@ export function mapFeeds(data: RawFeedsResponse): QzoneFeedsResult {
|
|||||||
nickname: f.nickname ?? '',
|
nickname: f.nickname ?? '',
|
||||||
time: Number(f.abstime ?? 0),
|
time: Number(f.abstime ?? 0),
|
||||||
appid: Number(f.appid ?? 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 ?? ''),
|
key: String(f.key ?? f.feedskey ?? ''),
|
||||||
html: f.html ?? '',
|
html: f.html ?? '',
|
||||||
})),
|
})),
|
||||||
@@ -228,12 +231,24 @@ export function mapFeeds(data: RawFeedsResponse): QzoneFeedsResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch the 好友动态 (friend-feed) list via ic2.qzone.qq.com's
|
* Fetch the 好友动态 (friend-feed) list via the feeds3_html_more CGI on
|
||||||
* feeds3_html_more CGI. `pageNum` is 1-based; `count` is the page size.
|
* ic2.qzone.qq.com, routed through the h5.qzone.qq.com proxy gateway — the
|
||||||
* Same cookie/g_tk plumbing and throw-on-auth-failure contract as
|
* same gateway {@link getQzoneMsgList} and group-album use, because the
|
||||||
* {@link getQzoneMsgList}: a missing `data.data` array means the cookie/
|
* qzone.qq.com cookie jar only authenticates against the proxy origin
|
||||||
* auth failed and throws, whereas a genuinely empty feed (`data.data: []`)
|
* (hitting ic2 directly fails the referer/same-origin check). Body is
|
||||||
* maps to an empty list.
|
* 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(
|
export async function getQzoneFeeds(
|
||||||
cookieObject: Record<string, string>,
|
cookieObject: Record<string, string>,
|
||||||
@@ -246,7 +261,7 @@ export async function getQzoneFeeds(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const bkn = getBknFromCookie(cookieObject);
|
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,
|
uin: selfUin,
|
||||||
scope: '0',
|
scope: '0',
|
||||||
@@ -260,8 +275,9 @@ export async function getQzoneFeeds(
|
|||||||
aisortOffset: '0',
|
aisortOffset: '0',
|
||||||
aisortBeginTime: '0',
|
aisortBeginTime: '0',
|
||||||
begintime: '0',
|
begintime: '0',
|
||||||
format: 'json',
|
|
||||||
g_tk: bkn,
|
g_tk: bkn,
|
||||||
|
callback: '_preloadCallback',
|
||||||
|
format: 'jsonp',
|
||||||
useutf8: '1',
|
useutf8: '1',
|
||||||
outputhtmlfeed: '1',
|
outputhtmlfeed: '1',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -161,12 +161,17 @@ describe('qzone / getQzoneFeeds (HTTP layer)', () => {
|
|||||||
expect(method).toBe('GET');
|
expect(method).toBe('GET');
|
||||||
expect(body).toBe('');
|
expect(body).toBe('');
|
||||||
expect((headers as Record<string, string>).Cookie).toContain('p_skey=PSK');
|
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]);
|
const q = new URLSearchParams((url as string).split('?')[1]);
|
||||||
expect(q.get('uin')).toBe('10000');
|
expect(q.get('uin')).toBe('10000');
|
||||||
expect(q.get('pagenum')).toBe('2');
|
expect(q.get('pagenum')).toBe('2');
|
||||||
expect(q.get('count')).toBe('10');
|
expect(q.get('count')).toBe('10');
|
||||||
expect(q.get('g_tk')).toBe(expectedGtk);
|
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 () => {
|
it('returns an empty list (not a throw) for a genuinely empty feed', async () => {
|
||||||
|
|||||||
Reference in new issue
Block a user