feishu extension: tighten reply target fallback semantics

This commit is contained in:
bmendonca3
2026-03-03 16:03:50 -07:00
parent c129a691fc
commit f85ec610f2
2 changed files with 34 additions and 3 deletions

View File

@@ -155,6 +155,26 @@ describe("feishuOutbound.sendText local-image auto-convert", () => {
}), }),
); );
}); });
it("falls back to threadId when replyToId is empty on sendText", async () => {
await sendText({
cfg: {} as any,
to: "chat_1",
text: "hello",
replyToId: " ",
threadId: "om_thread_2",
accountId: "main",
} as any);
expect(sendMessageFeishuMock).toHaveBeenCalledWith(
expect.objectContaining({
to: "chat_1",
text: "hello",
replyToMessageId: "om_thread_2",
accountId: "main",
}),
);
});
}); });
describe("feishuOutbound.sendMedia renderMode", () => { describe("feishuOutbound.sendMedia renderMode", () => {
@@ -216,5 +236,13 @@ describe("feishuOutbound.sendMedia renderMode", () => {
accountId: "main", accountId: "main",
}), }),
); );
expect(sendMessageFeishuMock).toHaveBeenCalledWith(
expect.objectContaining({
to: "chat_1",
text: "caption",
replyToMessageId: "om_thread_1",
accountId: "main",
}),
);
}); });
}); });

View File

@@ -47,11 +47,14 @@ function resolveReplyToMessageId(params: {
replyToId?: string | null; replyToId?: string | null;
threadId?: string | number | null; threadId?: string | number | null;
}): string | undefined { }): string | undefined {
const replyTarget = params.replyToId ?? params.threadId; const replyToId = params.replyToId?.trim();
if (replyTarget == null) { if (replyToId) {
return replyToId;
}
if (params.threadId == null) {
return undefined; return undefined;
} }
const trimmed = String(replyTarget).trim(); const trimmed = String(params.threadId).trim();
return trimmed || undefined; return trimmed || undefined;
} }