fix: resolve Cron + isolated session + Feishu announce message failed

This commit is contained in:
龚文滔0668001436
2026-03-03 15:59:36 +08:00
parent 1443bb9a84
commit e2899ee393

View File

@@ -845,13 +845,30 @@ function resolveFeishuSession(
accountId: params.accountId,
peer,
});
// Normalize the session "to" field so that downstream tooling (including the
// message tool in isolated/cron runs) sees the same Feishu target shapes as
// the main session:
// - DM/user targets -> user:ou_xxx
// - Chat/group targets -> chat:oc_xxx
// This keeps DeliveryContext.To aligned with the Feishu plugin's
// normalizeFeishuTarget/looksLikeFeishuId helpers and avoids
// Unknown target "user" for Feishu / missing-target errors when the
// message tool infers its default target from the session route.
const to =
isGroup || idLower.startsWith("oc_")
? `chat:${trimmed}`
: idLower.startsWith("ou_") || idLower.startsWith("on_")
? `user:${trimmed}`
: trimmed;
return {
sessionKey: baseSessionKey,
baseSessionKey,
peer,
chatType: isGroup ? "group" : "direct",
from: isGroup ? `feishu:group:${trimmed}` : `feishu:${trimmed}`,
to: trimmed,
to,
};
}