fix(signal): validate reaction message ids · openclaw/openclaw@af3e354
steipete
·
2026-05-29
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -180,6 +180,16 @@ describe("signalMessageActions", () => {
|
180 | 180 | }), |
181 | 181 | ).rejects.toThrow(/messageId.*required/); |
182 | 182 | |
| 183 | +await expect( |
| 184 | +signalMessageActions.handleAction?.({ |
| 185 | +channel: "signal", |
| 186 | +action: "react", |
| 187 | +params: { to: "+15559999999", messageId: "123abc", emoji: "✅" }, |
| 188 | + cfg, |
| 189 | +}), |
| 190 | +).rejects.toThrow(/Invalid messageId/); |
| 191 | +expect(sendReactionSignalMock).not.toHaveBeenCalled(); |
| 192 | + |
183 | 193 | await expect( |
184 | 194 | signalMessageActions.handleAction?.({ |
185 | 195 | channel: "signal", |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -4,6 +4,7 @@ import type {
|
4 | 4 | ChannelMessageActionAdapter, |
5 | 5 | ChannelMessageActionName, |
6 | 6 | } from "openclaw/plugin-sdk/channel-contract"; |
| 7 | +import { parseStrictNonNegativeInteger } from "openclaw/plugin-sdk/number-runtime"; |
7 | 8 | import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime"; |
8 | 9 | import { removeReactionSignal, sendReactionSignal } from "../reaction-runtime-api.js"; |
9 | 10 | import { listEnabledSignalAccounts, resolveSignalAccount } from "./accounts.js"; |
@@ -146,8 +147,8 @@ export const signalMessageActions: ChannelMessageActionAdapter = {
|
146 | 147 | const emoji = readStringParam(params, "emoji", { allowEmpty: true }); |
147 | 148 | const remove = typeof params.remove === "boolean" ? params.remove : undefined; |
148 | 149 | |
149 | | -const timestamp = Number.parseInt(messageId, 10); |
150 | | -if (!Number.isFinite(timestamp)) { |
| 150 | +const timestamp = parseStrictNonNegativeInteger(messageId); |
| 151 | +if (timestamp === undefined) { |
151 | 152 | throw new Error(`Invalid messageId: ${messageId}. Expected numeric timestamp.`); |
152 | 153 | } |
153 | 154 | |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。