fix: validate google chat reaction limits · openclaw/openclaw@5990524
steipete
·
2026-05-29
·
via Recent Commits to openclaw:main
File tree
extensions/googlechat/src
| Original file line number | Diff line number | Diff line change |
|---|
@@ -286,4 +286,26 @@ describe("googlechat message actions", () => {
|
286 | 286 | }); |
287 | 287 | expectJsonResult(result, { ok: true, removed: 2 }); |
288 | 288 | }); |
| 289 | + |
| 290 | +it("rejects fractional reaction limits before listing reactions", async () => { |
| 291 | +const account = buildAccount(); |
| 292 | +resolveGoogleChatAccount.mockReturnValue(account); |
| 293 | + |
| 294 | +if (!googlechatMessageActions.handleAction) { |
| 295 | +throw new Error("Expected googlechatMessageActions.handleAction to be defined"); |
| 296 | +} |
| 297 | +await expect( |
| 298 | +googlechatMessageActions.handleAction({ |
| 299 | +action: "reactions", |
| 300 | +params: { |
| 301 | +messageId: "spaces/AAA/messages/msg-1", |
| 302 | +limit: 2.5, |
| 303 | +}, |
| 304 | +cfg: {}, |
| 305 | +accountId: "default", |
| 306 | +} as never), |
| 307 | +).rejects.toThrow("limit must be a positive integer"); |
| 308 | + |
| 309 | +expect(listGoogleChatReactions).not.toHaveBeenCalled(); |
| 310 | +}); |
289 | 311 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import { |
2 | 2 | createActionGate, |
3 | 3 | jsonResult, |
4 | | -readNumberParam, |
| 4 | +readPositiveIntegerParam, |
5 | 5 | readReactionParams, |
6 | 6 | readStringParam, |
7 | 7 | } from "openclaw/plugin-sdk/channel-actions"; |
@@ -213,7 +213,7 @@ export const googlechatMessageActions: ChannelMessageActionAdapter = {
|
213 | 213 | |
214 | 214 | if (action === "reactions") { |
215 | 215 | const messageName = readStringParam(params, "messageId", { required: true }); |
216 | | -const limit = readNumberParam(params, "limit", { integer: true }); |
| 216 | +const limit = readPositiveIntegerParam(params, "limit"); |
217 | 217 | const reactions = await listGoogleChatReactions({ |
218 | 218 | account, |
219 | 219 | messageName, |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。