feat(wangyihao): record public article URL on publish and back-fill responses

Build https://www.163.com/dy/article/<docId>.html when wangyihao tasks finish, and normalize publish-record responses + monitoring alias inputs to surface the same public URL when the doc id is known.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-30 20:55:53 +08:00
parent add918ff4c
commit cdd63db7f1
8 changed files with 208 additions and 64 deletions
@@ -0,0 +1,6 @@
const WANGYI_PUBLIC_ARTICLE_URL_PREFIX = "https://www.163.com/dy/article";
export function wangyihaoPublicArticleUrl(articleId: string): string | null {
const normalized = articleId.trim();
return normalized ? `${WANGYI_PUBLIC_ARTICLE_URL_PREFIX}/${encodeURIComponent(normalized)}.html` : null;
}
@@ -1,6 +1,7 @@
import { describe, expect, it } from "vitest";
import { prepareWangyihaoArticleHtml } from "./wangyihao-content";
import { wangyihaoPublicArticleUrl } from "./wangyihao-links";
describe("wangyihao article content", () => {
it("downgrades markdown tables to paragraph rows before saving drafts", () => {
@@ -24,3 +25,15 @@ describe("wangyihao article content", () => {
expect(html).toContain("<p>下一段中文说明</p>");
});
});
describe("wangyihao publish result", () => {
it("builds the public article URL from the NetEase doc id", () => {
expect(wangyihaoPublicArticleUrl(" IK5K461I05561G2M ")).toBe(
"https://www.163.com/dy/article/IK5K461I05561G2M.html",
);
});
it("does not build an external URL without a doc id", () => {
expect(wangyihaoPublicArticleUrl(" ")).toBeNull();
});
});
@@ -10,6 +10,7 @@ import {
import { fetchImageAssetBlob } from "./media-image";
import type { PublishAdapter, PublishAdapterContext } from "./base";
import { prepareWangyihaoArticleHtml } from "./wangyihao-content";
import { wangyihaoPublicArticleUrl } from "./wangyihao-links";
import {
WANGYIHAO_DRAFT_SAVE_PARAMETER_MESSAGE,
WANGYIHAO_PUBLISH_CLICK_MESSAGE,
@@ -820,7 +821,7 @@ function buildResultPayload(articleId: string, mediaName: string): Record<string
media_name: mediaName,
external_article_id: articleId,
external_manage_url: WANGYI_MANAGE_URL,
external_article_url: null,
external_article_url: wangyihaoPublicArticleUrl(articleId),
publish_type: "publish",
};
}
@@ -950,7 +951,7 @@ export const wangyihaoAdapter: PublishAdapter = {
return {
status: "succeeded",
summary: "网易号发布成功。",
summary: "网易号发布成功,已记录公开链接。",
payload: buildResultPayload(draftId, account.name),
};
} catch (error) {