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
+4 -8
View File
@@ -10496,10 +10496,8 @@ export class DownloadManager extends EventEmitter {
}
this.notifiedPackages.add(pkg.id);
void sendNotification(url, {
title: kind === "completed" ? "Paket fertig" : "Paket fehlgeschlagen",
message: `${pkg.name}\n${detail}`,
priority: kind === "failed" ? "high" : "default",
tags: kind === "completed" ? "white_check_mark" : "x"
title: kind === "completed" ? "Paket fertig" : "Paket fehlgeschlagen",
message: `${pkg.name}\n${detail}`
});
}
@@ -12122,10 +12120,8 @@ export class DownloadManager extends EventEmitter {
this.session.summaryText = `Summary: Dauer ${duration}s, Ø Speed ${humanSize(avgSpeed)}/s, Erfolg ${success}/${total}`;
if (this.settings.notifyOnRunFinished && total > 0) {
void sendNotification(this.settings.notifyUrl, {
title: "Durchlauf beendet",
message: `${success}/${total} erfolgreich, ${failed} fehlgeschlagen, ${cancelled} abgebrochen\nDauer ${duration}s, Durchschnitt ${humanSize(avgSpeed)}/s`,
priority: failed > 0 ? "high" : "default",
tags: failed > 0 ? "warning" : "checkered_flag"
title: failed > 0 ? "⚠️ Durchlauf beendet" : "🏁 Durchlauf beendet",
message: `${success}/${total} erfolgreich, ${failed} fehlgeschlagen, ${cancelled} abgebrochen\nDauer ${duration}s, Durchschnitt ${humanSize(avgSpeed)}/s`
});
}
this.runItemIds.clear();
+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 })
}
};
}