fix: keep message-tool buttons optional for Telegram and Mattermost (#52589) (thanks @tylerliu612)

This commit is contained in:
Ayaan Zaidi
2026-03-23 14:38:56 +05:30
parent bf12835995
commit 8f8b79496f
3 changed files with 24 additions and 1 deletions

View File

@@ -1,3 +1,4 @@
import { Type } from "@sinclair/typebox";
import { beforeEach, describe, expect, it, vi } from "vitest";
import type { OpenClawConfig } from "../runtime-api.js";
import { createChannelReplyPipeline } from "../runtime-api.js";
@@ -181,6 +182,26 @@ describe("mattermostPlugin", () => {
expect(actions).toEqual([]);
});
it("keeps buttons optional in message tool schema", () => {
const cfg: OpenClawConfig = {
channels: {
mattermost: {
enabled: true,
botToken: "test-token",
baseUrl: "https://chat.example.com",
},
},
};
const discovery = mattermostPlugin.actions?.describeMessageTool?.({ cfg });
const schema = discovery?.schema;
if (!schema || Array.isArray(schema)) {
throw new Error("expected mattermost message-tool schema");
}
expect(Type.Object(schema.properties).required).toBeUndefined();
});
it("hides react when actions.reactions is false", () => {
const cfg: OpenClawConfig = {
channels: {

View File

@@ -1,3 +1,4 @@
import { Type } from "@sinclair/typebox";
import { describeAccountSnapshot } from "openclaw/plugin-sdk/account-helpers";
import { formatNormalizedAllowFromEntries } from "openclaw/plugin-sdk/allow-from";
import { createMessageToolButtonsSchema } from "openclaw/plugin-sdk/channel-actions";
@@ -97,7 +98,7 @@ function describeMattermostMessageTool({
enabledAccounts.length > 0
? {
properties: {
buttons: createMessageToolButtonsSchema(),
buttons: Type.Optional(createMessageToolButtonsSchema()),
},
}
: null,