mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-12 20:42:55 +00:00
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();
|
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",
|
||||||
|
|||||||
@@ -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");
|
||||||
|
|||||||
Reference in New Issue
Block a user