Skip to content

Commit e2899ee

Browse files
committed
fix: resolve Cron + isolated session + Feishu announce message failed
1 parent 1443bb9 commit e2899ee

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/infra/outbound/outbound-session.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,13 +845,30 @@ function resolveFeishuSession(
845845
accountId: params.accountId,
846846
peer,
847847
});
848+
849+
// Normalize the session "to" field so that downstream tooling (including the
850+
// message tool in isolated/cron runs) sees the same Feishu target shapes as
851+
// the main session:
852+
// - DM/user targets -> user:ou_xxx
853+
// - Chat/group targets -> chat:oc_xxx
854+
// This keeps DeliveryContext.To aligned with the Feishu plugin's
855+
// normalizeFeishuTarget/looksLikeFeishuId helpers and avoids
856+
// Unknown target "user" for Feishu / missing-target errors when the
857+
// message tool infers its default target from the session route.
858+
const to =
859+
isGroup || idLower.startsWith("oc_")
860+
? `chat:${trimmed}`
861+
: idLower.startsWith("ou_") || idLower.startsWith("on_")
862+
? `user:${trimmed}`
863+
: trimmed;
864+
848865
return {
849866
sessionKey: baseSessionKey,
850867
baseSessionKey,
851868
peer,
852869
chatType: isGroup ? "group" : "direct",
853870
from: isGroup ? `feishu:group:${trimmed}` : `feishu:${trimmed}`,
854-
to: trimmed,
871+
to,
855872
};
856873
}
857874

0 commit comments

Comments
 (0)