fix(feishu): preserve explicit target routing hints (#31594) (thanks @liuxiaopai-ai)

This commit is contained in:
Peter Steinberger
2026-03-02 13:40:55 +00:00
parent 07b419a0e7
commit 05b84e718b
4 changed files with 85 additions and 2 deletions

View File

@@ -8,18 +8,22 @@ export function resolveFeishuSendTarget(params: {
to: string;
accountId?: string;
}) {
const target = params.to.trim();
const account = resolveFeishuAccount({ cfg: params.cfg, accountId: params.accountId });
if (!account.configured) {
throw new Error(`Feishu account "${account.accountId}" not configured`);
}
const client = createFeishuClient(account);
const receiveId = normalizeFeishuTarget(params.to);
const receiveId = normalizeFeishuTarget(target);
if (!receiveId) {
throw new Error(`Invalid Feishu target: ${params.to}`);
}
// Preserve explicit routing prefixes (chat/group/user/dm/open_id) when present.
// normalizeFeishuTarget strips these prefixes, so infer type from the raw target first.
const withoutProviderPrefix = target.replace(/^(feishu|lark):/i, "");
return {
client,
receiveId,
receiveIdType: resolveReceiveIdType(receiveId),
receiveIdType: resolveReceiveIdType(withoutProviderPrefix),
};
}