From 25f226db4348b33054605bb6c0ba3c76b4b8ead8 Mon Sep 17 00:00:00 2001 From: Sucukdeluxe Date: Tue, 9 Jun 2026 23:42:15 +0200 Subject: [PATCH] Feature: Testen-Button neben der Webhook-URL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Schickt sofort eine Test-Nachricht (inkl. Discord-Ping falls gesetzt) an die EINGETRAGENEN Entwurfs-Werte — funktioniert also schon vor dem Speichern der Einstellungen. Toast meldet Erfolg bzw. verweist bei Fehlschlag auf Hilfe -> Letzte Fehler (dort steht der HTTP-Status/Fehlertext aus notify.ts). Neuer IPC TEST_NOTIFY (main.ts ruft sendNotification direkt), Button im input-row-Muster, deaktiviert solange die URL leer ist. --- src/main/main.ts | 10 ++++++++++ src/preload/preload.ts | 1 + src/renderer/App.tsx | 12 +++++++++++- src/shared/ipc.ts | 1 + src/shared/preload-api.ts | 1 + 5 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/main/main.ts b/src/main/main.ts index bb71dc2..65aaf1f 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -6,6 +6,7 @@ import { AppController } from "./app-controller"; import { IPC_CHANNELS } from "../shared/ipc"; import { getLogFilePath, logger } from "./logger"; import { getRecentErrors } from "./error-ring"; +import { sendNotification } from "./notify"; import { APP_NAME } from "./constants"; import { extractHttpLinksFromText } from "./utils"; import { cleanupStaleSubstDrives, shutdownDaemon } from "./extractor"; @@ -629,6 +630,15 @@ function registerIpcHandlers(): void { ipcMain.handle(IPC_CHANNELS.GET_RECENT_ERRORS, async () => getRecentErrors()); + ipcMain.handle(IPC_CHANNELS.TEST_NOTIFY, async (_event: IpcMainInvokeEvent, url: string, mention: string) => { + validateString(url, "url"); + return sendNotification(url, { + title: "🔔 Test-Benachrichtigung", + message: "Webhook funktioniert — Benachrichtigungen kommen hier an.", + mention: typeof mention === "string" ? mention : "" + }); + }); + ipcMain.handle(IPC_CHANNELS.GET_TRACE_CONFIG, async () => controller.getTraceConfig()); ipcMain.handle(IPC_CHANNELS.SET_TRACE_ENABLED, async (_event: IpcMainInvokeEvent, enabled: boolean, note?: string, durationMinutes?: number) => { diff --git a/src/preload/preload.ts b/src/preload/preload.ts index caf1483..6a12c28 100644 --- a/src/preload/preload.ts +++ b/src/preload/preload.ts @@ -70,6 +70,7 @@ const api: ElectronApi = { openItemLog: (itemId: string): Promise => ipcRenderer.invoke(IPC_CHANNELS.OPEN_ITEM_LOG, itemId), getDebugSetupCheck: () => ipcRenderer.invoke(IPC_CHANNELS.GET_DEBUG_SETUP_CHECK), getRecentErrors: () => ipcRenderer.invoke(IPC_CHANNELS.GET_RECENT_ERRORS), + testNotification: (url: string, mention: string) => ipcRenderer.invoke(IPC_CHANNELS.TEST_NOTIFY, url, mention), getTraceConfig: () => ipcRenderer.invoke(IPC_CHANNELS.GET_TRACE_CONFIG), setTraceEnabled: (enabled: boolean, note?: string, durationMinutes?: number) => ipcRenderer.invoke(IPC_CHANNELS.SET_TRACE_ENABLED, enabled, note, durationMinutes), rotateDebugToken: (): Promise<{ path: string }> => ipcRenderer.invoke(IPC_CHANNELS.ROTATE_DEBUG_TOKEN), diff --git a/src/renderer/App.tsx b/src/renderer/App.tsx index 7525a68..799d55a 100644 --- a/src/renderer/App.tsx +++ b/src/renderer/App.tsx @@ -4958,7 +4958,17 @@ export function App(): ReactElement { - setText("notifyUrl", e.target.value)} /> +
+ setText("notifyUrl", e.target.value)} /> + +
In Discord: Servereinstellungen → Integrationen → Webhooks → Neuer Webhook → URL kopieren und hier eintragen. Die gewählten Ereignisse landen als Nachricht im Kanal.
setText("notifyMention", e.target.value)} /> diff --git a/src/shared/ipc.ts b/src/shared/ipc.ts index 70a401a..1063043 100644 --- a/src/shared/ipc.ts +++ b/src/shared/ipc.ts @@ -48,6 +48,7 @@ export const IPC_CHANNELS = { OPEN_ITEM_LOG: "app:open-item-log", GET_DEBUG_SETUP_CHECK: "app:get-debug-setup-check", GET_RECENT_ERRORS: "app:get-recent-errors", + TEST_NOTIFY: "app:test-notify", GET_TRACE_CONFIG: "app:get-trace-config", SET_TRACE_ENABLED: "app:set-trace-enabled", ROTATE_DEBUG_TOKEN: "app:rotate-debug-token", diff --git a/src/shared/preload-api.ts b/src/shared/preload-api.ts index 97ca17f..cae76b4 100644 --- a/src/shared/preload-api.ts +++ b/src/shared/preload-api.ts @@ -67,6 +67,7 @@ export interface ElectronApi { openItemLog: (itemId: string) => Promise; getDebugSetupCheck: () => Promise; getRecentErrors: () => Promise>; + testNotification: (url: string, mention: string) => Promise; getTraceConfig: () => Promise; setTraceEnabled: (enabled: boolean, note?: string, durationMinutes?: number) => Promise; rotateDebugToken: () => Promise<{ path: string }>;