mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 16:30:57 +00:00
fix: clone setup channels for owned ids
This commit is contained in:
@@ -216,6 +216,40 @@ describe("listReadOnlyChannelPluginsForConfig", () => {
|
||||
expect(fs.existsSync(fullMarker)).toBe(false);
|
||||
});
|
||||
|
||||
it("clones setup-only plugins for every configured owned channel when setup id matches one channel", () => {
|
||||
const { pluginDir, fullMarker, setupMarker } = writeExternalSetupChannelPlugin({
|
||||
pluginId: "external-chat-plugin",
|
||||
channelId: "alpha-chat",
|
||||
manifestChannelIds: ["alpha-chat", "beta-chat"],
|
||||
setupChannelId: "alpha-chat",
|
||||
});
|
||||
const plugins = listReadOnlyChannelPluginsForConfig(
|
||||
{
|
||||
channels: {
|
||||
"alpha-chat": { token: "configured" },
|
||||
"beta-chat": { token: "configured" },
|
||||
},
|
||||
plugins: {
|
||||
load: { paths: [pluginDir] },
|
||||
allow: ["external-chat-plugin"],
|
||||
},
|
||||
} as never,
|
||||
{
|
||||
env: { ...process.env },
|
||||
includePersistedAuthState: false,
|
||||
},
|
||||
);
|
||||
|
||||
const alphaPlugin = plugins.find((entry) => entry.id === "alpha-chat");
|
||||
const betaPlugin = plugins.find((entry) => entry.id === "beta-chat");
|
||||
expect(alphaPlugin?.meta.id).toBe("alpha-chat");
|
||||
expect(betaPlugin?.meta.id).toBe("beta-chat");
|
||||
expect(alphaPlugin?.meta.blurb).toBe("setup entry");
|
||||
expect(betaPlugin?.meta.blurb).toBe("setup entry");
|
||||
expect(fs.existsSync(setupMarker)).toBe(true);
|
||||
expect(fs.existsSync(fullMarker)).toBe(false);
|
||||
});
|
||||
|
||||
it("keeps configured external channels visible when no setup entry exists", () => {
|
||||
const { pluginDir, fullMarker, setupMarker } = writeExternalSetupChannelPlugin({
|
||||
setupEntry: false,
|
||||
|
||||
@@ -101,6 +101,16 @@ function addSetupChannelPlugins(
|
||||
onlyIds: new Set(ownedMissingChannelIds),
|
||||
allowOverwrite: false,
|
||||
});
|
||||
addChannelPlugins(
|
||||
byId,
|
||||
ownedMissingChannelIds
|
||||
.filter((channelId) => channelId !== setup.plugin.id)
|
||||
.map((channelId) => cloneChannelPluginForChannelId(setup.plugin, channelId)),
|
||||
{
|
||||
onlyIds: new Set(ownedMissingChannelIds),
|
||||
allowOverwrite: false,
|
||||
},
|
||||
);
|
||||
continue;
|
||||
}
|
||||
if (setup.plugin.id !== setup.pluginId) {
|
||||
|
||||
Reference in New Issue
Block a user