Improve logging on resovelBody
This commit is contained in:
committed by
pullfrog[bot]
parent
7621d6f0e5
commit
5d4f81a007
@@ -157786,10 +157786,26 @@ function hasImages(body) {
|
||||
}
|
||||
async function resolveBody(ctx) {
|
||||
const body = ctx.event.body;
|
||||
if (!hasImages(body)) return body ?? null;
|
||||
log.info(`[resolveBody] trigger: ${ctx.event.trigger}`);
|
||||
log.info(`[resolveBody] original body (first 200 chars): ${body?.substring(0, 200)}`);
|
||||
log.info(`[resolveBody] hasImages: ${hasImages(body)}`);
|
||||
if (!hasImages(body)) {
|
||||
log.info("[resolveBody] no images detected, returning original body");
|
||||
return body ?? null;
|
||||
}
|
||||
log.info("[resolveBody] images detected, fetching body_html from GitHub API...");
|
||||
const bodyHtml = await fetchBodyHtml(ctx);
|
||||
if (!bodyHtml) return body ?? null;
|
||||
return turndown.turndown(bodyHtml);
|
||||
log.info(`[resolveBody] bodyHtml received: ${bodyHtml ? "yes" : "no"}`);
|
||||
if (bodyHtml) {
|
||||
log.info(`[resolveBody] bodyHtml (first 500 chars): ${bodyHtml.substring(0, 500)}`);
|
||||
}
|
||||
if (!bodyHtml) {
|
||||
log.info("[resolveBody] no bodyHtml returned, returning original body");
|
||||
return body ?? null;
|
||||
}
|
||||
const resolved = turndown.turndown(bodyHtml);
|
||||
log.info(`[resolveBody] resolved markdown (first 500 chars): ${resolved.substring(0, 500)}`);
|
||||
return resolved;
|
||||
}
|
||||
async function fetchBodyHtml(ctx) {
|
||||
const event = ctx.event;
|
||||
|
||||
Reference in New Issue
Block a user