Benachrichtigungen: ntfy ersetzt durch Discord-Webhooks

User-Wunsch: Discord statt ntfy. notify.ts sendet jetzt einen JSON-Webhook-POST
({username, content} mit fettem Titel + Nachricht, auf Discords 2000-Zeichen-
Limit gekappt) statt ntfy-Headern. Emoji-Status im Titel (OK/Fehler/Ziel-
flagge) ersetzt Priority/Tags. Settings-UI: Label/Placeholder/Hinweis auf
Discord-Webhook umgestellt (Servereinstellungen -> Integrationen -> Webhooks).
Hooks, Dedup und Guards unveraendert. Tests auf das JSON-Format angepasst
(inkl. Discord-204-Antwort und 2000-Zeichen-Cap).
This commit is contained in:
Sucukdeluxe
2026-06-09 21:40:39 +02:00
parent 4684144093
commit 41cf36890b
4 changed files with 33 additions and 41 deletions
+7 -13
View File
@@ -3,30 +3,24 @@ import { logger } from "./logger";
export interface NotifyPayload {
title: string;
message: string;
priority?: "default" | "high";
tags?: string;
}
const NOTIFY_TIMEOUT_MS = 5000;
const WEBHOOK_USERNAME = "Real-Debrid Downloader";
export function isNotifyUrlValid(url: string): boolean {
return /^https?:\/\/\S+$/i.test(String(url || "").trim());
}
export function buildNotifyRequest(url: string, payload: NotifyPayload): { url: string; init: RequestInit } {
const headers: Record<string, string> = {
"Title": payload.title,
"Content-Type": "text/plain; charset=utf-8"
};
if (payload.priority && payload.priority !== "default") {
headers["Priority"] = payload.priority;
}
if (payload.tags) {
headers["Tags"] = payload.tags;
}
const content = `**${payload.title}**\n${payload.message}`.slice(0, 2000);
return {
url: String(url || "").trim(),
init: { method: "POST", headers, body: payload.message }
init: {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ username: WEBHOOK_USERNAME, content })
}
};
}