


























@@ -3,6 +3,13 @@ import { expect, vi } from "vitest";
33import type { OpenClawConfig, PluginRuntime } from "../runtime-api.js";
44import type { ResolvedZaloAccount } from "../types.js";
556+function resolveLifecycleAllowFrom(params: {
7+dmPolicy: "open" | "pairing";
8+allowFrom?: string[];
9+}): string[] | undefined {
10+return params.allowFrom ?? (params.dmPolicy === "open" ? ["*"] : undefined);
11+}
12+613export function createLifecycleConfig(params: {
714accountId: string;
815dmPolicy: "open" | "pairing";
@@ -12,6 +19,7 @@ export function createLifecycleConfig(params: {
1219}): OpenClawConfig {
1320const webhookUrl = params.webhookUrl ?? "https://example.com/hooks/zalo";
1421const webhookSecret = params.webhookSecret ?? "supersecret";
22+const allowFrom = resolveLifecycleAllowFrom(params);
1523return {
1624channels: {
1725zalo: {
@@ -22,7 +30,7 @@ export function createLifecycleConfig(params: {
2230 webhookUrl,
2331 webhookSecret, // pragma: allowlist secret
2432dmPolicy: params.dmPolicy,
25- ...(params.allowFrom ? { allowFrom: params.allowFrom } : {}),
33+ ...(allowFrom ? { allowFrom } : {}),
2634},
2735},
2836},
@@ -39,6 +47,7 @@ export function createLifecycleAccount(params: {
3947}): ResolvedZaloAccount {
4048const webhookUrl = params.webhookUrl ?? "https://example.com/hooks/zalo";
4149const webhookSecret = params.webhookSecret ?? "supersecret";
50+const allowFrom = resolveLifecycleAllowFrom(params);
4251return {
4352accountId: params.accountId,
4453enabled: true,
@@ -48,7 +57,7 @@ export function createLifecycleAccount(params: {
4857 webhookUrl,
4958 webhookSecret, // pragma: allowlist secret
5059dmPolicy: params.dmPolicy,
51- ...(params.allowFrom ? { allowFrom: params.allowFrom } : {}),
60+ ...(allowFrom ? { allowFrom } : {}),
5261},
5362} as ResolvedZaloAccount;
5463}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。