fix(synology-chat): read cfg from outbound context so incomingUrl resolves

This commit is contained in:
white-rm
2026-02-25 14:33:27 +08:00
committed by Peter Steinberger
parent b645654923
commit e513714103
2 changed files with 21 additions and 40 deletions

View File

@@ -268,18 +268,10 @@ describe("createSynologyChatPlugin", () => {
const plugin = createSynologyChatPlugin(); const plugin = createSynologyChatPlugin();
await expect( await expect(
plugin.outbound.sendText({ plugin.outbound.sendText({
account: { cfg: {
accountId: "default", channels: {
enabled: true, "synology-chat": { enabled: true, token: "t", incomingUrl: "" },
token: "t", },
incomingUrl: "",
nasHost: "h",
webhookPath: "/w",
dmPolicy: "open",
allowedUserIds: [],
rateLimitPerMinute: 30,
botName: "Bot",
allowInsecureSsl: true,
}, },
text: "hello", text: "hello",
to: "user1", to: "user1",
@@ -290,18 +282,15 @@ describe("createSynologyChatPlugin", () => {
it("sendText returns OutboundDeliveryResult on success", async () => { it("sendText returns OutboundDeliveryResult on success", async () => {
const plugin = createSynologyChatPlugin(); const plugin = createSynologyChatPlugin();
const result = await plugin.outbound.sendText({ const result = await plugin.outbound.sendText({
account: { cfg: {
accountId: "default", channels: {
enabled: true, "synology-chat": {
token: "t", enabled: true,
incomingUrl: "https://nas/incoming", token: "t",
nasHost: "h", incomingUrl: "https://nas/incoming",
webhookPath: "/w", allowInsecureSsl: true,
dmPolicy: "open", },
allowedUserIds: [], },
rateLimitPerMinute: 30,
botName: "Bot",
allowInsecureSsl: true,
}, },
text: "hello", text: "hello",
to: "user1", to: "user1",
@@ -315,18 +304,10 @@ describe("createSynologyChatPlugin", () => {
const plugin = createSynologyChatPlugin(); const plugin = createSynologyChatPlugin();
await expect( await expect(
plugin.outbound.sendMedia({ plugin.outbound.sendMedia({
account: { cfg: {
accountId: "default", channels: {
enabled: true, "synology-chat": { enabled: true, token: "t", incomingUrl: "" },
token: "t", },
incomingUrl: "",
nasHost: "h",
webhookPath: "/w",
dmPolicy: "open",
allowedUserIds: [],
rateLimitPerMinute: 30,
botName: "Bot",
allowInsecureSsl: true,
}, },
mediaUrl: "https://example.com/img.png", mediaUrl: "https://example.com/img.png",
to: "user1", to: "user1",

View File

@@ -178,8 +178,8 @@ export function createSynologyChatPlugin() {
deliveryMode: "gateway" as const, deliveryMode: "gateway" as const,
textChunkLimit: 2000, textChunkLimit: 2000,
sendText: async ({ to, text, accountId, account: ctxAccount }: any) => { sendText: async ({ to, text, accountId, cfg }: any) => {
const account: ResolvedSynologyChatAccount = ctxAccount ?? resolveAccount({}, accountId); const account: ResolvedSynologyChatAccount = resolveAccount(cfg ?? {}, accountId);
if (!account.incomingUrl) { if (!account.incomingUrl) {
throw new Error("Synology Chat incoming URL not configured"); throw new Error("Synology Chat incoming URL not configured");
@@ -192,8 +192,8 @@ export function createSynologyChatPlugin() {
return { channel: CHANNEL_ID, messageId: `sc-${Date.now()}`, chatId: to }; return { channel: CHANNEL_ID, messageId: `sc-${Date.now()}`, chatId: to };
}, },
sendMedia: async ({ to, mediaUrl, accountId, account: ctxAccount }: any) => { sendMedia: async ({ to, mediaUrl, accountId, cfg }: any) => {
const account: ResolvedSynologyChatAccount = ctxAccount ?? resolveAccount({}, accountId); const account: ResolvedSynologyChatAccount = resolveAccount(cfg ?? {}, accountId);
if (!account.incomingUrl) { if (!account.incomingUrl) {
throw new Error("Synology Chat incoming URL not configured"); throw new Error("Synology Chat incoming URL not configured");