mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-04 09:00:22 +00:00
fix(config): align whatsapp enabled schema with auto-enable
This commit is contained in:
@@ -63,6 +63,18 @@ describe("config schema regressions", () => {
|
||||
expect(res.ok).toBe(true);
|
||||
});
|
||||
|
||||
it("accepts channels.whatsapp.enabled", () => {
|
||||
const res = validateConfigObject({
|
||||
channels: {
|
||||
whatsapp: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(res.ok).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects unsafe iMessage remoteHost", () => {
|
||||
const res = validateConfigObject({
|
||||
channels: {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { validateConfigObject } from "./config.js";
|
||||
import { applyPluginAutoEnable } from "./plugin-auto-enable.js";
|
||||
|
||||
describe("applyPluginAutoEnable", () => {
|
||||
@@ -48,6 +49,23 @@ describe("applyPluginAutoEnable", () => {
|
||||
expect(result.changes).toEqual([]);
|
||||
});
|
||||
|
||||
it("keeps auto-enabled WhatsApp config schema-valid", () => {
|
||||
const result = applyPluginAutoEnable({
|
||||
config: {
|
||||
channels: {
|
||||
whatsapp: {
|
||||
allowFrom: ["+15555550123"],
|
||||
},
|
||||
},
|
||||
},
|
||||
env: {},
|
||||
});
|
||||
|
||||
expect(result.config.channels?.whatsapp?.enabled).toBe(true);
|
||||
const validated = validateConfigObject(result.config);
|
||||
expect(validated.ok).toBe(true);
|
||||
});
|
||||
|
||||
it("respects explicit disable", () => {
|
||||
const result = applyPluginAutoEnable({
|
||||
config: {
|
||||
|
||||
@@ -36,6 +36,8 @@ export type WhatsAppAckReactionConfig = {
|
||||
};
|
||||
|
||||
type WhatsAppSharedConfig = {
|
||||
/** Whether the WhatsApp channel is enabled. */
|
||||
enabled?: boolean;
|
||||
/** Direct message access policy (default: pairing). */
|
||||
dmPolicy?: DmPolicy;
|
||||
/** Same-phone setup (bot uses your personal WhatsApp number). */
|
||||
|
||||
@@ -32,6 +32,7 @@ const WhatsAppAckReactionSchema = z
|
||||
.optional();
|
||||
|
||||
const WhatsAppSharedSchema = z.object({
|
||||
enabled: z.boolean().optional(),
|
||||
capabilities: z.array(z.string()).optional(),
|
||||
markdown: MarkdownConfigSchema,
|
||||
configWrites: z.boolean().optional(),
|
||||
|
||||
Reference in New Issue
Block a user