fix(qzone): thread abstime into like, flag unlike endpoint as unverified

Adversarial review (NEEDS-FIXES) of the like/unlike slice:
- Missing abstime: every real dolike impl (QLiker.py, CSDN) sends the
  target feed's post time. Threaded abstime through setQzoneLike →
  QzoneApi.like → like_qzone/unlike_qzone actions (optional, default 0;
  pass the feed's real time for reliability). Test asserts it.
- internal_unlike_app is the conventional paired CGI but NO public bot
  impl exercises unlike, so it's best-guess. Labeled UNVERIFIED/pending a
  live capture in the helper comment, the unlike action summary, and the
  unlike test — instead of pinning it as confirmed truth (avoiding the
  re-codify-a-wrong-constant trap the last 3 slices hit).
- Documented the success-signal (code/subcode) as extrapolated from
  sibling CGIs (dolike may use a succ/fail token instead).

The confirmed mechanics (dolike CGI, opuin=liker, unikey/curkey mood
shape, appid=311, fid=tid) are noted as such.
This commit is contained in:
DrSmoothl committed 2026-06-20 02:02:25 +08:00
1 parent d497f1e6c7
commit 870504ae3a
6 files changed
+87 -24

No files matched your search

+23 -9
View File
@@ -463,12 +463,22 @@ export async function deleteQzoneMsg(
}
// ─────────────── 点赞/取消赞 (like/unlike) — internal_dolike_app ───────────────
// Likes or unlikes a 说说 (mood, appid 311) on `targetUin`'s space. like →
// internal_dolike_app, unlike → internal_unlike_app, same form body keyed by
// the feed's unikey/curkey (`http://user.qzone.qq.com/<uin>/mood/<tid>`) and
// `fid` (= tid). WRITE OP — rate-limit (likes are an active action,风控'd
// like sending messages). Scope is 说说 only; other feed types use a
// different unikey shape and are out of scope for this slice.
// Likes or unlikes a 说说 (mood, appid 311) on `targetUin`'s space, keyed by
// the feed's unikey/curkey (`http://user.qzone.qq.com/<uin>/mood/<tid>`,
// identical, http not https) and `fid` (= tid). The like CGI
// (internal_dolike_app), opuin=liker, unikey/curkey shape, and appid=311 are
// CONFIRMED against community impls (QLiker.py, CSDN 点赞协议). Two things are
// NOT live-verified and follow this file's "extrapolated, pending a live
// capture" posture:
// • the UNLIKE endpoint `internal_unlike_app` — it's the conventional
// paired CGI but no public bot impl exercises unlike, so it's best-guess.
// • the success SIGNAL — we throw on a non-zero code/subcode (extrapolated
// from sibling CGIs); the dolike response may instead carry a succ/fail
// token, so a clean parse is treated as success.
// `abstime` (the target feed's post time) is threaded through because every
// real dolike impl sends it; 0 is a tolerated fallback when unknown.
// WRITE OP — rate-limit (likes are an active action,风控'd like messages).
// Scope is 说说 only; other feed types use a different unikey shape.
interface RawLikeResponse {
code?: number;
@@ -478,9 +488,11 @@ interface RawLikeResponse {
/**
* Like or unlike a 说说 by `tid` on `targetUin`'s space, as the bot
* (`opUin`). Resolves on success; THROWS on a transport failure or a
* non-zero Qzone `code`/`subcode` (e.g. an unknown tid, no permission, or
* an auth failure). `like=false` hits the unlike CGI.
* (`opUin`). `abstime` is the target feed's post time (unix seconds) — pass
* the real value (from get_qzone_feeds/msglist) for reliability; 0 is a
* tolerated fallback. Resolves on success; THROWS on a transport failure or
* a non-zero Qzone `code`/`subcode`. `like=false` hits the (unverified)
* unlike CGI.
*/
export async function setQzoneLike(
cookieObject: Record<string, string>,
@@ -488,6 +500,7 @@ export async function setQzoneLike(
targetUin: string,
tid: string,
like: boolean,
abstime = 0,
): Promise<void> {
if (!cookieObject || typeof cookieObject !== 'object') {
throw new Error('cookieObject is required');
@@ -508,6 +521,7 @@ export async function setQzoneLike(
curkey: unikey,
appid: '311',
typeid: '0',
abstime: String(abstime),
fid: tid,
from: '1',
active: '0',
+13 -3
View File
@@ -296,13 +296,14 @@ describe('qzone / deleteQzoneMsg (HTTP layer)', () => {
describe('qzone / setQzoneLike (HTTP layer)', () => {
afterEach(() => vi.restoreAllMocks());
it('POSTs to internal_dolike_app with the mood unikey/curkey/fid when liking', async () => {
it('POSTs to internal_dolike_app with the mood unikey/curkey/fid/abstime when liking', async () => {
const spy = vi.spyOn(RequestUtil, 'HttpGetText').mockResolvedValue('{"code":0,"subcode":0}');
await expect(setQzoneLike(cookies, '10000', '20002', 'TIDX', true)).resolves.toBeUndefined();
await expect(setQzoneLike(cookies, '10000', '20002', 'TIDX', true, 1700000000)).resolves.toBeUndefined();
const [url, method, body, headers] = spy.mock.calls[0]!;
expect(method).toBe('POST');
// like CGI + unikey/curkey shape + opuin + appid CONFIRMED (QLiker.py, CSDN)
expect(url).toBe(
`https://h5.qzone.qq.com/proxy/domain/w.qzone.qq.com/cgi-bin/likes/internal_dolike_app?g_tk=${expectedGtk}`,
);
@@ -316,9 +317,18 @@ describe('qzone / setQzoneLike (HTTP layer)', () => {
expect(form.get('fid')).toBe('TIDX');
expect(form.get('opuin')).toBe('10000');
expect(form.get('appid')).toBe('311');
// abstime threaded through (every real dolike impl sends it)
expect(form.get('abstime')).toBe('1700000000');
});
it('hits internal_unlike_app when unliking', async () => {
it('defaults abstime to 0 when not supplied', async () => {
const spy = vi.spyOn(RequestUtil, 'HttpGetText').mockResolvedValue('{"code":0}');
await setQzoneLike(cookies, '10000', '20002', 'TIDX', true);
const form = new URLSearchParams(spy.mock.calls[0]![2] as string);
expect(form.get('abstime')).toBe('0');
});
it('hits internal_unlike_app when unliking (NB: unlike endpoint UNVERIFIED, pending a live capture)', async () => {
const spy = vi.spyOn(RequestUtil, 'HttpGetText').mockResolvedValue('{"code":0}');
await setQzoneLike(cookies, '10000', '10000', 'TIDX', false);
const [url] = spy.mock.calls[0]!;