diff --git a/app/server/modules/notifications/__tests__/notification-builders.test.ts b/app/server/modules/notifications/__tests__/notification-builders.test.ts index 13fac313..532065df 100644 --- a/app/server/modules/notifications/__tests__/notification-builders.test.ts +++ b/app/server/modules/notifications/__tests__/notification-builders.test.ts @@ -182,19 +182,19 @@ describe("notification shoutrrr URL builders", () => { expect( buildTelegramShoutrrrUrl({ type: "telegram", - botToken: "bot-token", + botToken: "123456:ABCdef", chatId: "chat-id", }), - ).toBe("telegram://bot-token@telegram?channels=chat-id"); + ).toBe("telegram://123456:ABCdef@telegram?channels=chat-id"); expect( buildTelegramShoutrrrUrl({ type: "telegram", - botToken: "bot-token", + botToken: "123456:ABCdef", chatId: "chat-id", threadId: "thread-id", }), - ).toBe("telegram://bot-token@telegram?channels=chat-id%3Athread-id"); + ).toBe("telegram://123456:ABCdef@telegram?channels=chat-id:thread-id"); }); test("builds generic URLs with reserved params, transport flags, and headers", () => { diff --git a/app/server/modules/notifications/builders/telegram.ts b/app/server/modules/notifications/builders/telegram.ts index a350282c..60435ba3 100644 --- a/app/server/modules/notifications/builders/telegram.ts +++ b/app/server/modules/notifications/builders/telegram.ts @@ -1,8 +1,9 @@ import type { NotificationConfig } from "~/schemas/notifications"; export const buildTelegramShoutrrrUrl = (config: Extract) => { - const shoutrrrUrl = new URL("telegram://telegram"); - shoutrrrUrl.username = config.botToken; - shoutrrrUrl.searchParams.set("channels", `${config.chatId}${config.threadId ? `:${config.threadId}` : ""}`); - return shoutrrrUrl.toString().replace("/?", "?"); + let shoutrrrUrl = `telegram://${config.botToken}@telegram?channels=${config.chatId}`; + if (config.threadId) { + shoutrrrUrl += `:${config.threadId}`; + } + return shoutrrrUrl; };