fix(feishu): bound quick action launcher expiry · openclaw/openclaw@0563470
steipete
·
2026-05-30
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -88,6 +88,25 @@ describe("feishu quick-action launcher", () => {
|
88 | 88 | expectFirstSentCardUsesFillWidthOnly(sendCardFeishuMock); |
89 | 89 | }); |
90 | 90 | |
| 91 | +it("does not send launcher cards when expiry would exceed a valid Date", async () => { |
| 92 | +const runtime: RuntimeEnv = createRuntimeEnv(); |
| 93 | + |
| 94 | +const handled = await maybeHandleFeishuQuickActionMenu({ |
| 95 | + cfg, |
| 96 | +eventKey: "quick-actions", |
| 97 | +operatorOpenId: "u123", |
| 98 | +accountId: "main", |
| 99 | + runtime, |
| 100 | +now: 8_640_000_000_000_000, |
| 101 | +}); |
| 102 | + |
| 103 | +expect(handled).toBe(false); |
| 104 | +expect(sendCardFeishuMock).not.toHaveBeenCalled(); |
| 105 | +expect(runtime.log).toHaveBeenCalledWith( |
| 106 | +"feishu[main]: failed to open quick-action launcher for u123: invalid expiry clock", |
| 107 | +); |
| 108 | +}); |
| 109 | + |
91 | 110 | it("falls back to legacy menu handling when launcher send fails", async () => { |
92 | 111 | sendCardFeishuMock.mockRejectedValueOnce(new Error("network")); |
93 | 112 | const runtime: RuntimeEnv = createRuntimeEnv(); |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +import { |
| 2 | +asDateTimestampMs, |
| 3 | +resolveExpiresAtMsFromDurationMs, |
| 4 | +} from "openclaw/plugin-sdk/number-runtime"; |
1 | 5 | import { normalizeOptionalLowercaseString } from "openclaw/plugin-sdk/string-coerce-runtime"; |
2 | 6 | import type { ClawdbotConfig, RuntimeEnv } from "../runtime-api.js"; |
3 | 7 | import { createFeishuCardInteractionEnvelope } from "./card-interaction.js"; |
@@ -96,7 +100,17 @@ export async function maybeHandleFeishuQuickActionMenu(params: {
|
96 | 100 | return false; |
97 | 101 | } |
98 | 102 | |
99 | | -const expiresAt = (params.now ?? Date.now()) + FEISHU_QUICK_ACTION_CARD_TTL_MS; |
| 103 | +const now = asDateTimestampMs(params.now ?? Date.now()); |
| 104 | +const expiresAt = |
| 105 | +now === undefined |
| 106 | + ? undefined |
| 107 | + : resolveExpiresAtMsFromDurationMs(FEISHU_QUICK_ACTION_CARD_TTL_MS, { nowMs: now }); |
| 108 | +if (expiresAt === undefined) { |
| 109 | +params.runtime?.log?.( |
| 110 | +`feishu[${params.accountId ?? "default"}]: failed to open quick-action launcher for ${params.operatorOpenId}: invalid expiry clock`, |
| 111 | +); |
| 112 | +return false; |
| 113 | +} |
100 | 114 | try { |
101 | 115 | await sendCardFeishu({ |
102 | 116 | cfg: params.cfg, |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。