fix(synology-chat): read cfg from outbound context so incomingUrl resolves
This commit is contained in:
committed by
Peter Steinberger
parent
b645654923
commit
e513714103
@@ -268,18 +268,10 @@ describe("createSynologyChatPlugin", () => {
|
||||
const plugin = createSynologyChatPlugin();
|
||||
await expect(
|
||||
plugin.outbound.sendText({
|
||||
account: {
|
||||
accountId: "default",
|
||||
enabled: true,
|
||||
token: "t",
|
||||
incomingUrl: "",
|
||||
nasHost: "h",
|
||||
webhookPath: "/w",
|
||||
dmPolicy: "open",
|
||||
allowedUserIds: [],
|
||||
rateLimitPerMinute: 30,
|
||||
botName: "Bot",
|
||||
allowInsecureSsl: true,
|
||||
cfg: {
|
||||
channels: {
|
||||
"synology-chat": { enabled: true, token: "t", incomingUrl: "" },
|
||||
},
|
||||
},
|
||||
text: "hello",
|
||||
to: "user1",
|
||||
@@ -290,18 +282,15 @@ describe("createSynologyChatPlugin", () => {
|
||||
it("sendText returns OutboundDeliveryResult on success", async () => {
|
||||
const plugin = createSynologyChatPlugin();
|
||||
const result = await plugin.outbound.sendText({
|
||||
account: {
|
||||
accountId: "default",
|
||||
enabled: true,
|
||||
token: "t",
|
||||
incomingUrl: "https://nas/incoming",
|
||||
nasHost: "h",
|
||||
webhookPath: "/w",
|
||||
dmPolicy: "open",
|
||||
allowedUserIds: [],
|
||||
rateLimitPerMinute: 30,
|
||||
botName: "Bot",
|
||||
allowInsecureSsl: true,
|
||||
cfg: {
|
||||
channels: {
|
||||
"synology-chat": {
|
||||
enabled: true,
|
||||
token: "t",
|
||||
incomingUrl: "https://nas/incoming",
|
||||
allowInsecureSsl: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
text: "hello",
|
||||
to: "user1",
|
||||
@@ -315,18 +304,10 @@ describe("createSynologyChatPlugin", () => {
|
||||
const plugin = createSynologyChatPlugin();
|
||||
await expect(
|
||||
plugin.outbound.sendMedia({
|
||||
account: {
|
||||
accountId: "default",
|
||||
enabled: true,
|
||||
token: "t",
|
||||
incomingUrl: "",
|
||||
nasHost: "h",
|
||||
webhookPath: "/w",
|
||||
dmPolicy: "open",
|
||||
allowedUserIds: [],
|
||||
rateLimitPerMinute: 30,
|
||||
botName: "Bot",
|
||||
allowInsecureSsl: true,
|
||||
cfg: {
|
||||
channels: {
|
||||
"synology-chat": { enabled: true, token: "t", incomingUrl: "" },
|
||||
},
|
||||
},
|
||||
mediaUrl: "https://example.com/img.png",
|
||||
to: "user1",
|
||||
|
||||
@@ -178,8 +178,8 @@ export function createSynologyChatPlugin() {
|
||||
deliveryMode: "gateway" as const,
|
||||
textChunkLimit: 2000,
|
||||
|
||||
sendText: async ({ to, text, accountId, account: ctxAccount }: any) => {
|
||||
const account: ResolvedSynologyChatAccount = ctxAccount ?? resolveAccount({}, accountId);
|
||||
sendText: async ({ to, text, accountId, cfg }: any) => {
|
||||
const account: ResolvedSynologyChatAccount = resolveAccount(cfg ?? {}, accountId);
|
||||
|
||||
if (!account.incomingUrl) {
|
||||
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 };
|
||||
},
|
||||
|
||||
sendMedia: async ({ to, mediaUrl, accountId, account: ctxAccount }: any) => {
|
||||
const account: ResolvedSynologyChatAccount = ctxAccount ?? resolveAccount({}, accountId);
|
||||
sendMedia: async ({ to, mediaUrl, accountId, cfg }: any) => {
|
||||
const account: ResolvedSynologyChatAccount = resolveAccount(cfg ?? {}, accountId);
|
||||
|
||||
if (!account.incomingUrl) {
|
||||
throw new Error("Synology Chat incoming URL not configured");
|
||||
|
||||
Reference in New Issue
Block a user