mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 07:40:44 +00:00
test(zalo): align open dm lifecycle fixtures
This commit is contained in:
@@ -559,6 +559,7 @@ describe("handleZaloWebhookRequest", () => {
|
||||
...DEFAULT_ACCOUNT,
|
||||
config: {
|
||||
dmPolicy: "open",
|
||||
allowFrom: ["*"],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -3,6 +3,13 @@ import { expect, vi } from "vitest";
|
||||
import type { OpenClawConfig, PluginRuntime } from "../runtime-api.js";
|
||||
import type { ResolvedZaloAccount } from "../types.js";
|
||||
|
||||
function resolveLifecycleAllowFrom(params: {
|
||||
dmPolicy: "open" | "pairing";
|
||||
allowFrom?: string[];
|
||||
}): string[] | undefined {
|
||||
return params.allowFrom ?? (params.dmPolicy === "open" ? ["*"] : undefined);
|
||||
}
|
||||
|
||||
export function createLifecycleConfig(params: {
|
||||
accountId: string;
|
||||
dmPolicy: "open" | "pairing";
|
||||
@@ -12,6 +19,7 @@ export function createLifecycleConfig(params: {
|
||||
}): OpenClawConfig {
|
||||
const webhookUrl = params.webhookUrl ?? "https://example.com/hooks/zalo";
|
||||
const webhookSecret = params.webhookSecret ?? "supersecret";
|
||||
const allowFrom = resolveLifecycleAllowFrom(params);
|
||||
return {
|
||||
channels: {
|
||||
zalo: {
|
||||
@@ -22,7 +30,7 @@ export function createLifecycleConfig(params: {
|
||||
webhookUrl,
|
||||
webhookSecret, // pragma: allowlist secret
|
||||
dmPolicy: params.dmPolicy,
|
||||
...(params.allowFrom ? { allowFrom: params.allowFrom } : {}),
|
||||
...(allowFrom ? { allowFrom } : {}),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -39,6 +47,7 @@ export function createLifecycleAccount(params: {
|
||||
}): ResolvedZaloAccount {
|
||||
const webhookUrl = params.webhookUrl ?? "https://example.com/hooks/zalo";
|
||||
const webhookSecret = params.webhookSecret ?? "supersecret";
|
||||
const allowFrom = resolveLifecycleAllowFrom(params);
|
||||
return {
|
||||
accountId: params.accountId,
|
||||
enabled: true,
|
||||
@@ -48,7 +57,7 @@ export function createLifecycleAccount(params: {
|
||||
webhookUrl,
|
||||
webhookSecret, // pragma: allowlist secret
|
||||
dmPolicy: params.dmPolicy,
|
||||
...(params.allowFrom ? { allowFrom: params.allowFrom } : {}),
|
||||
...(allowFrom ? { allowFrom } : {}),
|
||||
},
|
||||
} as ResolvedZaloAccount;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user