Compare commits
3 Commits
main
...
vincentkoc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2bc62c67e7 | ||
|
|
9f6b531839 | ||
|
|
c52cccdc40 |
@ -22,6 +22,7 @@ Docs: https://docs.openclaw.ai
|
|||||||
- Configure/startup: move outbound send-deps resolution into a lightweight helper so `openclaw configure` no longer stalls after the banner while eagerly loading channel plugins. (#46301) thanks @scoootscooob.
|
- Configure/startup: move outbound send-deps resolution into a lightweight helper so `openclaw configure` no longer stalls after the banner while eagerly loading channel plugins. (#46301) thanks @scoootscooob.
|
||||||
- Zalo Personal/group gating: stop reapplying `dmPolicy.allowFrom` as a sender gate for already-allowlisted groups when `groupAllowFrom` is unset, so any member of an allowed group can trigger replies while DMs stay restricted. (#40146)
|
- Zalo Personal/group gating: stop reapplying `dmPolicy.allowFrom` as a sender gate for already-allowlisted groups when `groupAllowFrom` is unset, so any member of an allowed group can trigger replies while DMs stay restricted. (#40146)
|
||||||
- Plugins/install precedence: keep bundled plugins ahead of auto-discovered globals by default, but let an explicitly installed plugin record win its own duplicate-id tie so installed channel plugins load from `~/.openclaw/extensions` after `openclaw plugins install`.
|
- Plugins/install precedence: keep bundled plugins ahead of auto-discovered globals by default, but let an explicitly installed plugin record win its own duplicate-id tie so installed channel plugins load from `~/.openclaw/extensions` after `openclaw plugins install`.
|
||||||
|
- Synology Chat/webhooks: refuse to register when multiple enabled accounts resolve to the same webhook path, instead of silently replacing the active route owner. Thanks @vincentkoc.
|
||||||
|
|
||||||
### Fixes
|
### Fixes
|
||||||
|
|
||||||
|
|||||||
@ -94,3 +94,23 @@ export function resolveAccount(cfg: any, accountId?: string | null): ResolvedSyn
|
|||||||
allowInsecureSsl: accountOverride.allowInsecureSsl ?? channelCfg.allowInsecureSsl ?? false,
|
allowInsecureSsl: accountOverride.allowInsecureSsl ?? channelCfg.allowInsecureSsl ?? false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function findConflictingWebhookPathAccountIds(cfg: any, accountId: string): string[] {
|
||||||
|
const current = resolveAccount(cfg, accountId);
|
||||||
|
const currentPath = current.webhookPath.trim();
|
||||||
|
if (!current.enabled || !current.token.trim() || !current.incomingUrl.trim() || !currentPath) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return listAccountIds(cfg)
|
||||||
|
.filter((candidateId) => candidateId !== accountId)
|
||||||
|
.map((candidateId) => resolveAccount(cfg, candidateId))
|
||||||
|
.filter(
|
||||||
|
(candidate) =>
|
||||||
|
candidate.enabled &&
|
||||||
|
candidate.token.trim() &&
|
||||||
|
candidate.incomingUrl.trim() &&
|
||||||
|
candidate.webhookPath.trim() === currentPath,
|
||||||
|
)
|
||||||
|
.map((candidate) => candidate.accountId);
|
||||||
|
}
|
||||||
|
|||||||
@ -334,5 +334,87 @@ describe("createSynologyChatPlugin", () => {
|
|||||||
abortSecond.abort();
|
abortSecond.abort();
|
||||||
await Promise.allSettled([firstPromise, secondPromise]);
|
await Promise.allSettled([firstPromise, secondPromise]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("refuses to register when another enabled account resolves to the same webhook path", async () => {
|
||||||
|
const registerMock = registerPluginHttpRouteMock;
|
||||||
|
registerMock.mockClear();
|
||||||
|
const plugin = createSynologyChatPlugin();
|
||||||
|
const abortController = new AbortController();
|
||||||
|
const log = { info: vi.fn(), warn: vi.fn(), error: vi.fn() };
|
||||||
|
|
||||||
|
const result = plugin.gateway.startAccount({
|
||||||
|
cfg: {
|
||||||
|
channels: {
|
||||||
|
"synology-chat": {
|
||||||
|
enabled: true,
|
||||||
|
token: "base-token",
|
||||||
|
incomingUrl: "https://nas/incoming",
|
||||||
|
webhookPath: "/webhook/synology/shared",
|
||||||
|
dmPolicy: "allowlist",
|
||||||
|
allowedUserIds: ["owner-a"],
|
||||||
|
accounts: {
|
||||||
|
alerts: {
|
||||||
|
enabled: true,
|
||||||
|
token: "alerts-token",
|
||||||
|
incomingUrl: "https://nas/incoming-alerts",
|
||||||
|
webhookPath: "/webhook/synology/shared",
|
||||||
|
dmPolicy: "open",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
accountId: "default",
|
||||||
|
log,
|
||||||
|
abortSignal: abortController.signal,
|
||||||
|
});
|
||||||
|
|
||||||
|
await expectPendingStartAccountPromise(result, abortController);
|
||||||
|
expect(registerMock).not.toHaveBeenCalled();
|
||||||
|
expect(log.error).toHaveBeenCalledWith(
|
||||||
|
expect.stringContaining("Each enabled account must use a unique webhookPath."),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("ignores accounts with a shared path when they are missing incomingUrl", async () => {
|
||||||
|
const registerMock = registerPluginHttpRouteMock;
|
||||||
|
registerMock.mockClear();
|
||||||
|
const plugin = createSynologyChatPlugin();
|
||||||
|
const abortController = new AbortController();
|
||||||
|
const log = { info: vi.fn(), warn: vi.fn(), error: vi.fn() };
|
||||||
|
|
||||||
|
const result = plugin.gateway.startAccount({
|
||||||
|
cfg: {
|
||||||
|
channels: {
|
||||||
|
"synology-chat": {
|
||||||
|
enabled: true,
|
||||||
|
token: "base-token",
|
||||||
|
incomingUrl: "https://nas/incoming",
|
||||||
|
webhookPath: "/webhook/synology/shared",
|
||||||
|
dmPolicy: "allowlist",
|
||||||
|
allowedUserIds: ["owner-a"],
|
||||||
|
accounts: {
|
||||||
|
alerts: {
|
||||||
|
enabled: true,
|
||||||
|
token: "alerts-token",
|
||||||
|
incomingUrl: "",
|
||||||
|
webhookPath: "/webhook/synology/shared",
|
||||||
|
dmPolicy: "open",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
accountId: "default",
|
||||||
|
log,
|
||||||
|
abortSignal: abortController.signal,
|
||||||
|
});
|
||||||
|
|
||||||
|
await expectPendingStartAccountPromise(result, abortController);
|
||||||
|
expect(registerMock).toHaveBeenCalledTimes(1);
|
||||||
|
expect(log.error).not.toHaveBeenCalledWith(
|
||||||
|
expect.stringContaining("Each enabled account must use a unique webhookPath."),
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -11,7 +11,11 @@ import {
|
|||||||
buildChannelConfigSchema,
|
buildChannelConfigSchema,
|
||||||
} from "openclaw/plugin-sdk/synology-chat";
|
} from "openclaw/plugin-sdk/synology-chat";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { listAccountIds, resolveAccount } from "./accounts.js";
|
import {
|
||||||
|
findConflictingWebhookPathAccountIds,
|
||||||
|
listAccountIds,
|
||||||
|
resolveAccount,
|
||||||
|
} from "./accounts.js";
|
||||||
import { sendMessage, sendFileUrl } from "./client.js";
|
import { sendMessage, sendFileUrl } from "./client.js";
|
||||||
import { getSynologyRuntime } from "./runtime.js";
|
import { getSynologyRuntime } from "./runtime.js";
|
||||||
import type { ResolvedSynologyChatAccount } from "./types.js";
|
import type { ResolvedSynologyChatAccount } from "./types.js";
|
||||||
@ -249,6 +253,19 @@ export function createSynologyChatPlugin() {
|
|||||||
);
|
);
|
||||||
return waitUntilAbort(ctx.abortSignal);
|
return waitUntilAbort(ctx.abortSignal);
|
||||||
}
|
}
|
||||||
|
const conflictingAccounts = findConflictingWebhookPathAccountIds(
|
||||||
|
ctx.cfg,
|
||||||
|
account.accountId,
|
||||||
|
);
|
||||||
|
if (conflictingAccounts.length > 0) {
|
||||||
|
log?.error?.(
|
||||||
|
`Conflicting webhookPath ${account.webhookPath} for Synology Chat accounts: ${[
|
||||||
|
account.accountId,
|
||||||
|
...conflictingAccounts,
|
||||||
|
].join(", ")}. Each enabled account must use a unique webhookPath.`,
|
||||||
|
);
|
||||||
|
return waitUntilAbort(ctx.abortSignal);
|
||||||
|
}
|
||||||
|
|
||||||
log?.info?.(
|
log?.info?.(
|
||||||
`Starting Synology Chat channel (account: ${accountId}, path: ${account.webhookPath})`,
|
`Starting Synology Chat channel (account: ${accountId}, path: ${account.webhookPath})`,
|
||||||
@ -325,7 +342,6 @@ export function createSynologyChatPlugin() {
|
|||||||
const unregister = registerPluginHttpRoute({
|
const unregister = registerPluginHttpRoute({
|
||||||
path: account.webhookPath,
|
path: account.webhookPath,
|
||||||
auth: "plugin",
|
auth: "plugin",
|
||||||
replaceExisting: true,
|
|
||||||
pluginId: CHANNEL_ID,
|
pluginId: CHANNEL_ID,
|
||||||
accountId: account.accountId,
|
accountId: account.accountId,
|
||||||
log: (msg: string) => log?.info?.(msg),
|
log: (msg: string) => log?.info?.(msg),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user