From 34815476f2458f6b41fde25d0de4b982c2edb675 Mon Sep 17 00:00:00 2001 From: Vaica <94612053+zqlit@users.noreply.github.com> Date: Wed, 24 Jun 2026 14:25:47 +0800 Subject: [PATCH] Update notify.ts --- write-server/src/lib/bot/notify.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/write-server/src/lib/bot/notify.ts b/write-server/src/lib/bot/notify.ts index cee06443..867fad81 100644 --- a/write-server/src/lib/bot/notify.ts +++ b/write-server/src/lib/bot/notify.ts @@ -86,6 +86,7 @@ async function fetchLatestComments(): Promise { // 使用管理员 API 获取所有评论 const url = `${ARTALK_SERVER}/api/v2/admin/comments?site_name=${encodeURIComponent(ARTALK_SITE)}&limit=5&sort_by=date&sort_order=desc`; console.log("[comment-notify] fetching comments with admin API..."); + console.log("[comment-notify] URL:", url); const res = await fetch(url, { headers: { @@ -94,13 +95,16 @@ async function fetchLatestComments(): Promise { }, }); + console.log("[comment-notify] response status:", res.status, res.statusText); + if (!res.ok) { const errorText = await res.text().catch(() => "Unable to read response"); console.error("[comment-notify] fetch failed:", res.status, res.statusText); - console.error("[comment-notify] response:", errorText); + console.error("[comment-notify] response body:", errorText); // 如果是认证失败,清除 token 以便下次重试 if (res.status === 401 || res.status === 403) { + console.error("[comment-notify] authentication failed, clearing token"); authToken = null; tokenExpiry = 0; } @@ -113,6 +117,9 @@ async function fetchLatestComments(): Promise { return data.comments || []; } catch (e) { console.error("[comment-notify] fetch error:", e instanceof Error ? e.message : String(e)); + if (e instanceof Error && e.stack) { + console.error("[comment-notify] error stack:", e.stack.split('\n').slice(0, 5).join('\n')); + } return []; } }