mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-03 01:20:22 +00:00
fix: sync built-in channel enablement across config paths
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { normalizeChatChannelId } from "../channels/registry.js";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import { ensurePluginAllowlisted } from "../config/plugins-allowlist.js";
|
||||
import { setPluginEnabledInConfig } from "./toggle-config.js";
|
||||
|
||||
export type PluginEnableResult = {
|
||||
config: OpenClawConfig;
|
||||
@@ -17,41 +18,7 @@ export function enablePluginInConfig(cfg: OpenClawConfig, pluginId: string): Plu
|
||||
if (cfg.plugins?.deny?.includes(pluginId) || cfg.plugins?.deny?.includes(resolvedId)) {
|
||||
return { config: cfg, enabled: false, reason: "blocked by denylist" };
|
||||
}
|
||||
if (builtInChannelId) {
|
||||
const channels = cfg.channels as Record<string, unknown> | undefined;
|
||||
const existing = channels?.[builtInChannelId];
|
||||
const existingRecord =
|
||||
existing && typeof existing === "object" && !Array.isArray(existing)
|
||||
? (existing as Record<string, unknown>)
|
||||
: {};
|
||||
let next: OpenClawConfig = {
|
||||
...cfg,
|
||||
channels: {
|
||||
...cfg.channels,
|
||||
[builtInChannelId]: {
|
||||
...existingRecord,
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
next = ensurePluginAllowlisted(next, resolvedId);
|
||||
return { config: next, enabled: true };
|
||||
}
|
||||
|
||||
const entries = {
|
||||
...cfg.plugins?.entries,
|
||||
[resolvedId]: {
|
||||
...(cfg.plugins?.entries?.[resolvedId] as Record<string, unknown> | undefined),
|
||||
enabled: true,
|
||||
},
|
||||
};
|
||||
let next: OpenClawConfig = {
|
||||
...cfg,
|
||||
plugins: {
|
||||
...cfg.plugins,
|
||||
entries,
|
||||
},
|
||||
};
|
||||
let next = setPluginEnabledInConfig(cfg, resolvedId, true);
|
||||
next = ensurePluginAllowlisted(next, resolvedId);
|
||||
return { config: next, enabled: true };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user