From 36e6543abd0e6c740baf03946b3df96cef889995 Mon Sep 17 00:00:00 2001 From: Meik Date: Sun, 9 Nov 2025 20:31:27 +0100 Subject: [PATCH] fix: join ntfy topic prefix with hyphen --- server.js | 1 - services/notificationService.js | 6 +++-- src/App.js | 46 +++++++++++++++++++++++++-------- 3 files changed, 39 insertions(+), 14 deletions(-) diff --git a/server.js b/server.js index b7e16c5..0e46032 100644 --- a/server.js +++ b/server.js @@ -351,7 +351,6 @@ app.post('/api/auth/logout', requireAuth, (req, res) => { cachedStoreSnapshots.set(req.session.profile.id, req.session.storesCache); } sessionStore.delete(req.session.id); - credentialStore.remove(req.session.profile.id); storeRefreshJobs.delete(req.session.id); res.json({ success: true }); }); diff --git a/services/notificationService.js b/services/notificationService.js index 22ab7cf..bcbdb8c 100644 --- a/services/notificationService.js +++ b/services/notificationService.js @@ -26,8 +26,10 @@ async function sendNtfyNotification(adminNtfy, userNtfy, payload) { return; } const server = (userNtfy.serverUrl || adminNtfy.serverUrl || 'https://ntfy.sh').replace(/\/+$/, ''); - const topicPrefix = adminNtfy.topicPrefix ? `${adminNtfy.topicPrefix.replace(/\/+$/, '')}/` : ''; - const topic = `${topicPrefix}${userNtfy.topic.replace(/^\//, '')}`; + const sanitizedPrefix = (adminNtfy.topicPrefix || '').replace(/^-+|-+$/g, ''); + const sanitizedTopic = (userNtfy.topic || '').replace(/^-+|-+$/g, ''); + const separator = sanitizedPrefix && sanitizedTopic ? '-' : ''; + const topic = `${sanitizedPrefix}${separator}${sanitizedTopic}` || sanitizedPrefix || sanitizedTopic; const url = `${server}/${topic}`; const headers = { Title: payload.title, diff --git a/src/App.js b/src/App.js index 9b88217..4005acd 100644 --- a/src/App.js +++ b/src/App.js @@ -100,6 +100,7 @@ function App() { const [notificationSaving, setNotificationSaving] = useState(false); const [notificationMessage, setNotificationMessage] = useState(''); const [notificationError, setNotificationError] = useState(''); + const [notificationPanelOpen, setNotificationPanelOpen] = useState(false); const minSelectableDate = useMemo(() => startOfDay(new Date()), []); const weekdays = ['Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag', 'Sonntag']; @@ -1037,6 +1038,9 @@ function App() { }; const handleNotificationFieldChange = (channel, field, value) => { + if (channel === 'ntfy' && field === 'serverUrl') { + return; + } setNotificationSettings((prev) => { const nextChannel = { ...prev[channel], @@ -1433,14 +1437,27 @@ function App() {
-
-

Benachrichtigungen

-

- Erhalte Hinweise über ntfy oder Telegram, sobald Slots gefunden oder gebucht wurden. -

-
- {notificationLoading && Lade Einstellungen…} -
+
+
+

Benachrichtigungen

+

+ Erhalte Hinweise über ntfy oder Telegram, sobald Slots gefunden oder gebucht wurden. +

+
+ +
+ {notificationLoading && Lade Einstellungen…} +
{notificationError && (
{notificationError} @@ -1570,6 +1587,13 @@ function App() {
+ {!notificationPanelOpen && ( +
+ Benachrichtigungen sind aktuell {notificationSettings.ntfy.enabled || notificationSettings.telegram.enabled ? 'aktiviert' : 'deaktiviert'}. Klicke auf das Zahnrad, um Details anzuzeigen. +
+ )} + } +