From 8d4e5d2d4e87ea9cbdb14fc037c4ac5d7be19f2c Mon Sep 17 00:00:00 2001 From: Nicolas Meienberger Date: Sun, 23 Nov 2025 20:49:44 +0100 Subject: [PATCH] fix(ntfy): wrong usage of token --- app/schemas/notifications.ts | 3 ++- .../modules/notifications/builders/ntfy.ts | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/schemas/notifications.ts b/app/schemas/notifications.ts index 998675c..f85f3c4 100644 --- a/app/schemas/notifications.ts +++ b/app/schemas/notifications.ts @@ -49,8 +49,9 @@ export const ntfyNotificationConfigSchema = type({ type: "'ntfy'", serverUrl: "string?", topic: "string", - token: "string?", priority: "'max' | 'high' | 'default' | 'low' | 'min'", + username: "string?", + password: "string?", }); export const pushoverNotificationConfigSchema = type({ diff --git a/app/server/modules/notifications/builders/ntfy.ts b/app/server/modules/notifications/builders/ntfy.ts index b233e2a..c3477ff 100644 --- a/app/server/modules/notifications/builders/ntfy.ts +++ b/app/server/modules/notifications/builders/ntfy.ts @@ -3,19 +3,26 @@ import type { NotificationConfig } from "~/schemas/notifications"; export function buildNtfyShoutrrrUrl(config: Extract): string { let shoutrrrUrl: string; + const params = new URLSearchParams(); + + const auth = + config.username && config.password + ? `${encodeURIComponent(config.username)}:${encodeURIComponent(config.password)}@` + : ""; + if (config.serverUrl) { const url = new URL(config.serverUrl); const hostname = url.hostname; const port = url.port ? `:${url.port}` : ""; - shoutrrrUrl = `ntfy://${hostname}${port}/${config.topic}`; + const scheme = url.protocol === "https:" ? "https" : "http"; + + params.append("scheme", scheme); + + shoutrrrUrl = `ntfy://${auth}${hostname}${port}/${config.topic}`; } else { - shoutrrrUrl = `ntfy://ntfy.sh/${config.topic}`; + shoutrrrUrl = `ntfy://${auth}ntfy.sh/${config.topic}`; } - const params = new URLSearchParams(); - if (config.token) { - params.append("token", config.token); - } if (config.priority) { params.append("priority", config.priority); }