Skip to content

Commit 0628827

Browse files
committed
fix(feishu): omit command guidance when URL overrides fallback command text
1 parent 2e85a83 commit 0628827

2 files changed

Lines changed: 40 additions & 3 deletions

File tree

extensions/feishu/src/outbound.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,37 @@ describe("feishuOutbound.sendPayload native cards", () => {
861861
);
862862
expectFeishuResult(result, "reply_msg");
863863
});
864+
865+
it("omits command guidance when all command buttons have URLs overriding the fallback text", async () => {
866+
const result = await feishuOutbound.sendPayload?.({
867+
cfg: emptyConfig,
868+
to: "comment:docx:doxcn123:7623358762119646411",
869+
text: "Review this",
870+
accountId: "main",
871+
payload: {
872+
text: "Review this",
873+
interactive: {
874+
blocks: [
875+
{
876+
type: "buttons",
877+
buttons: [
878+
{
879+
label: "Open URL",
880+
url: "https://example.com/action",
881+
action: { type: "command", command: "/approve req_1" },
882+
},
883+
],
884+
},
885+
],
886+
},
887+
},
888+
});
889+
890+
expect(commentThreadParams()?.content).toBe(
891+
"Review this\n\n- Open URL: https://example.com/action",
892+
);
893+
expectFeishuResult(result, "reply_msg");
894+
});
864895
});
865896

866897
describe("feishuOutbound comment-thread routing", () => {

extensions/feishu/src/outbound.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -515,13 +515,19 @@ export const feishuOutbound: ChannelOutboundAdapter = {
515515
text: ctx.payload.text,
516516
presentation: normalizedPresentation,
517517
});
518-
const hasCommandAction =
518+
const hasRenderedCommandAction =
519519
normalizedPresentation?.blocks.some(
520520
(block) =>
521521
block.type === "buttons" &&
522-
block.buttons.some((button) => button.action?.type === "command"),
522+
block.buttons.some(
523+
(button) =>
524+
button.action?.type === "command" &&
525+
!button.url &&
526+
!button.webApp?.url &&
527+
!button.web_app?.url,
528+
),
523529
) ?? false;
524-
const text = hasCommandAction
530+
const text = hasRenderedCommandAction
525531
? `${presentationFallbackText}\n\n> Interactive buttons are unavailable in Feishu document comments. You can type the command shown above manually.`
526532
: presentationFallbackText;
527533

0 commit comments

Comments
 (0)