fix: default groupPolicy to allowlist
This commit is contained in:
@@ -1281,6 +1281,16 @@ describe("legacy config detection", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("defaults telegram.groupPolicy to allowlist when telegram section exists", async () => {
|
||||
vi.resetModules();
|
||||
const { validateConfigObject } = await import("./config.js");
|
||||
const res = validateConfigObject({ telegram: {} });
|
||||
expect(res.ok).toBe(true);
|
||||
if (res.ok) {
|
||||
expect(res.config.telegram?.groupPolicy).toBe("allowlist");
|
||||
}
|
||||
});
|
||||
|
||||
it("defaults telegram.streamMode to partial when telegram section exists", async () => {
|
||||
vi.resetModules();
|
||||
const { validateConfigObject } = await import("./config.js");
|
||||
@@ -1325,6 +1335,16 @@ describe("legacy config detection", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("defaults whatsapp.groupPolicy to allowlist when whatsapp section exists", async () => {
|
||||
vi.resetModules();
|
||||
const { validateConfigObject } = await import("./config.js");
|
||||
const res = validateConfigObject({ whatsapp: {} });
|
||||
expect(res.ok).toBe(true);
|
||||
if (res.ok) {
|
||||
expect(res.config.whatsapp?.groupPolicy).toBe("allowlist");
|
||||
}
|
||||
});
|
||||
|
||||
it('rejects signal.dmPolicy="open" without allowFrom "*"', async () => {
|
||||
vi.resetModules();
|
||||
const { validateConfigObject } = await import("./config.js");
|
||||
@@ -1359,6 +1379,16 @@ describe("legacy config detection", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("defaults signal.groupPolicy to allowlist when signal section exists", async () => {
|
||||
vi.resetModules();
|
||||
const { validateConfigObject } = await import("./config.js");
|
||||
const res = validateConfigObject({ signal: {} });
|
||||
expect(res.ok).toBe(true);
|
||||
if (res.ok) {
|
||||
expect(res.config.signal?.groupPolicy).toBe("allowlist");
|
||||
}
|
||||
});
|
||||
|
||||
it("accepts historyLimit overrides per provider and account", async () => {
|
||||
vi.resetModules();
|
||||
const { validateConfigObject } = await import("./config.js");
|
||||
@@ -1421,6 +1451,36 @@ describe("legacy config detection", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("defaults imessage.groupPolicy to allowlist when imessage section exists", async () => {
|
||||
vi.resetModules();
|
||||
const { validateConfigObject } = await import("./config.js");
|
||||
const res = validateConfigObject({ imessage: {} });
|
||||
expect(res.ok).toBe(true);
|
||||
if (res.ok) {
|
||||
expect(res.config.imessage?.groupPolicy).toBe("allowlist");
|
||||
}
|
||||
});
|
||||
|
||||
it("defaults discord.groupPolicy to allowlist when discord section exists", async () => {
|
||||
vi.resetModules();
|
||||
const { validateConfigObject } = await import("./config.js");
|
||||
const res = validateConfigObject({ discord: {} });
|
||||
expect(res.ok).toBe(true);
|
||||
if (res.ok) {
|
||||
expect(res.config.discord?.groupPolicy).toBe("allowlist");
|
||||
}
|
||||
});
|
||||
|
||||
it("defaults slack.groupPolicy to allowlist when slack section exists", async () => {
|
||||
vi.resetModules();
|
||||
const { validateConfigObject } = await import("./config.js");
|
||||
const res = validateConfigObject({ slack: {} });
|
||||
expect(res.ok).toBe(true);
|
||||
if (res.ok) {
|
||||
expect(res.config.slack?.groupPolicy).toBe("allowlist");
|
||||
}
|
||||
});
|
||||
|
||||
it("rejects unsafe executable config values", async () => {
|
||||
vi.resetModules();
|
||||
const { validateConfigObject } = await import("./config.js");
|
||||
|
||||
@@ -140,7 +140,7 @@ export type WhatsAppConfig = {
|
||||
groupAllowFrom?: string[];
|
||||
/**
|
||||
* Controls how group messages are handled:
|
||||
* - "open" (default): groups bypass allowFrom, only mention-gating applies
|
||||
* - "open": groups bypass allowFrom, only mention-gating applies
|
||||
* - "disabled": block all group messages entirely
|
||||
* - "allowlist": only allow group messages from senders in groupAllowFrom/allowFrom
|
||||
*/
|
||||
@@ -380,7 +380,7 @@ export type TelegramAccountConfig = {
|
||||
groupAllowFrom?: Array<string | number>;
|
||||
/**
|
||||
* Controls how group messages are handled:
|
||||
* - "open" (default): groups bypass allowFrom, only mention-gating applies
|
||||
* - "open": groups bypass allowFrom, only mention-gating applies
|
||||
* - "disabled": block all group messages entirely
|
||||
* - "allowlist": only allow group messages from senders in groupAllowFrom/allowFrom
|
||||
*/
|
||||
@@ -515,7 +515,7 @@ export type DiscordAccountConfig = {
|
||||
token?: string;
|
||||
/**
|
||||
* Controls how guild channel messages are handled:
|
||||
* - "open" (default): guild channels bypass allowlists; mention-gating applies
|
||||
* - "open": guild channels bypass allowlists; mention-gating applies
|
||||
* - "disabled": block all guild channel messages
|
||||
* - "allowlist": only allow channels present in discord.guilds.*.channels
|
||||
*/
|
||||
@@ -627,7 +627,7 @@ export type SlackAccountConfig = {
|
||||
allowBots?: boolean;
|
||||
/**
|
||||
* Controls how channel messages are handled:
|
||||
* - "open" (default): channels bypass allowlists; mention-gating applies
|
||||
* - "open": channels bypass allowlists; mention-gating applies
|
||||
* - "disabled": block all channel messages
|
||||
* - "allowlist": only allow channels present in slack.channels
|
||||
*/
|
||||
@@ -690,7 +690,7 @@ export type SignalAccountConfig = {
|
||||
groupAllowFrom?: Array<string | number>;
|
||||
/**
|
||||
* Controls how group messages are handled:
|
||||
* - "open" (default): groups bypass allowFrom, no extra gating
|
||||
* - "open": groups bypass allowFrom, no extra gating
|
||||
* - "disabled": block all group messages
|
||||
* - "allowlist": only allow group messages from senders in groupAllowFrom/allowFrom
|
||||
*/
|
||||
@@ -809,7 +809,7 @@ export type IMessageAccountConfig = {
|
||||
groupAllowFrom?: Array<string | number>;
|
||||
/**
|
||||
* Controls how group messages are handled:
|
||||
* - "open" (default): groups bypass allowFrom; mention-gating applies
|
||||
* - "open": groups bypass allowFrom; mention-gating applies
|
||||
* - "disabled": block all group messages entirely
|
||||
* - "allowlist": only allow group messages from senders in groupAllowFrom/allowFrom
|
||||
*/
|
||||
|
||||
@@ -95,9 +95,9 @@ const ReplyToModeSchema = z.union([
|
||||
]);
|
||||
|
||||
// GroupPolicySchema: controls how group messages are handled
|
||||
// Used with .default("open").optional() pattern:
|
||||
// Used with .default("allowlist").optional() pattern:
|
||||
// - .optional() allows field omission in input config
|
||||
// - .default("open") ensures runtime always resolves to "open" if not provided
|
||||
// - .default("allowlist") ensures runtime always resolves to "allowlist" if not provided
|
||||
const GroupPolicySchema = z.enum(["open", "disabled", "allowlist"]);
|
||||
|
||||
const DmPolicySchema = z.enum(["pairing", "allowlist", "open", "disabled"]);
|
||||
@@ -275,7 +275,7 @@ const TelegramAccountSchemaBase = z.object({
|
||||
groups: z.record(z.string(), TelegramGroupSchema.optional()).optional(),
|
||||
allowFrom: z.array(z.union([z.string(), z.number()])).optional(),
|
||||
groupAllowFrom: z.array(z.union([z.string(), z.number()])).optional(),
|
||||
groupPolicy: GroupPolicySchema.optional().default("open"),
|
||||
groupPolicy: GroupPolicySchema.optional().default("allowlist"),
|
||||
historyLimit: z.number().int().min(0).optional(),
|
||||
dmHistoryLimit: z.number().int().min(0).optional(),
|
||||
dms: z.record(z.string(), DmConfigSchema.optional()).optional(),
|
||||
@@ -366,7 +366,7 @@ const DiscordAccountSchema = z.object({
|
||||
capabilities: z.array(z.string()).optional(),
|
||||
enabled: z.boolean().optional(),
|
||||
token: z.string().optional(),
|
||||
groupPolicy: GroupPolicySchema.optional().default("open"),
|
||||
groupPolicy: GroupPolicySchema.optional().default("allowlist"),
|
||||
historyLimit: z.number().int().min(0).optional(),
|
||||
dmHistoryLimit: z.number().int().min(0).optional(),
|
||||
dms: z.record(z.string(), DmConfigSchema.optional()).optional(),
|
||||
@@ -440,7 +440,7 @@ const SlackAccountSchema = z.object({
|
||||
botToken: z.string().optional(),
|
||||
appToken: z.string().optional(),
|
||||
allowBots: z.boolean().optional(),
|
||||
groupPolicy: GroupPolicySchema.optional().default("open"),
|
||||
groupPolicy: GroupPolicySchema.optional().default("allowlist"),
|
||||
historyLimit: z.number().int().min(0).optional(),
|
||||
dmHistoryLimit: z.number().int().min(0).optional(),
|
||||
dms: z.record(z.string(), DmConfigSchema.optional()).optional(),
|
||||
@@ -496,7 +496,7 @@ const SignalAccountSchemaBase = z.object({
|
||||
dmPolicy: DmPolicySchema.optional().default("pairing"),
|
||||
allowFrom: z.array(z.union([z.string(), z.number()])).optional(),
|
||||
groupAllowFrom: z.array(z.union([z.string(), z.number()])).optional(),
|
||||
groupPolicy: GroupPolicySchema.optional().default("open"),
|
||||
groupPolicy: GroupPolicySchema.optional().default("allowlist"),
|
||||
historyLimit: z.number().int().min(0).optional(),
|
||||
dmHistoryLimit: z.number().int().min(0).optional(),
|
||||
dms: z.record(z.string(), DmConfigSchema.optional()).optional(),
|
||||
@@ -546,7 +546,7 @@ const IMessageAccountSchemaBase = z.object({
|
||||
dmPolicy: DmPolicySchema.optional().default("pairing"),
|
||||
allowFrom: z.array(z.union([z.string(), z.number()])).optional(),
|
||||
groupAllowFrom: z.array(z.union([z.string(), z.number()])).optional(),
|
||||
groupPolicy: GroupPolicySchema.optional().default("open"),
|
||||
groupPolicy: GroupPolicySchema.optional().default("allowlist"),
|
||||
historyLimit: z.number().int().min(0).optional(),
|
||||
dmHistoryLimit: z.number().int().min(0).optional(),
|
||||
dms: z.record(z.string(), DmConfigSchema.optional()).optional(),
|
||||
@@ -1394,7 +1394,7 @@ export const ClawdbotSchema = z
|
||||
selfChatMode: z.boolean().optional(),
|
||||
allowFrom: z.array(z.string()).optional(),
|
||||
groupAllowFrom: z.array(z.string()).optional(),
|
||||
groupPolicy: GroupPolicySchema.optional().default("open"),
|
||||
groupPolicy: GroupPolicySchema.optional().default("allowlist"),
|
||||
historyLimit: z.number().int().min(0).optional(),
|
||||
dmHistoryLimit: z.number().int().min(0).optional(),
|
||||
dms: z.record(z.string(), DmConfigSchema.optional()).optional(),
|
||||
@@ -1445,7 +1445,7 @@ export const ClawdbotSchema = z
|
||||
selfChatMode: z.boolean().optional(),
|
||||
allowFrom: z.array(z.string()).optional(),
|
||||
groupAllowFrom: z.array(z.string()).optional(),
|
||||
groupPolicy: GroupPolicySchema.optional().default("open"),
|
||||
groupPolicy: GroupPolicySchema.optional().default("allowlist"),
|
||||
historyLimit: z.number().int().min(0).optional(),
|
||||
dmHistoryLimit: z.number().int().min(0).optional(),
|
||||
dms: z.record(z.string(), DmConfigSchema.optional()).optional(),
|
||||
|
||||
Reference in New Issue
Block a user