diff --git a/server/index.js b/server/index.js index da52eb9..2974895 100644 --- a/server/index.js +++ b/server/index.js @@ -1567,7 +1567,11 @@ app.post('/api/test-ntfy', async (req, res) => { const base = (ntfy_url || 'https://ntfy.sh').replace(/\/$/, ''); try { await axios.post(`${base}/${ntfy_topic}`, 'This is a test notification from SkyWatch', { - headers: { Title: '🔔 SkyWatch Test', Priority: 'default', Tags: 'white_check_mark' }, + headers: { + Title: encodeURIComponent('SkyWatch Test'), + Priority: 'default', + Tags: 'white_check_mark', + }, }); res.json({ message: 'Test notification sent to ntfy!' }); } catch (error) { diff --git a/server/notificationService.js b/server/notificationService.js index 4e7602e..1a6ece7 100644 --- a/server/notificationService.js +++ b/server/notificationService.js @@ -179,12 +179,16 @@ class NotificationService { const ntfyTopic = this.config.ntfy_topic; if (ntfyTopic) { try { - await axios.post(`${ntfyUrl.replace(/\/$/, '')}/${ntfyTopic}`, - pendingAlerts.map(({ resource, incident }) => - `${incident.type === 'started' ? '🔴' : '🟢'} ${resource.name}` - ).join('\n'), - { headers: { Title: `⚠️ ${pendingAlerts.length} monitors changed`, Priority: 'high', Tags: 'warning' } } - ); + const groupedBody = pendingAlerts.map(({ resource, incident }) => + `${incident.type === 'started' ? '[DOWN]' : '[UP]'} ${resource.name}` + ).join('\n'); + await axios.post(`${ntfyUrl.replace(/\/$/, '')}/${ntfyTopic}`, groupedBody, { + headers: { + Title: encodeURIComponent(`${pendingAlerts.length} monitors changed status`), + Priority: 'high', + Tags: 'warning', + }, + }); } catch (_) {} } } @@ -450,15 +454,15 @@ class NotificationService { const isDown = type === 'started'; const isSlow = type === 'slow'; - const title = isDown ? `🔴 ${resource.name} is DOWN` : isSlow ? `🟡 ${resource.name} is SLOW` : `🟢 ${resource.name} is UP`; + const titleText = isDown ? `${resource.name} is DOWN` : isSlow ? `${resource.name} is SLOW` : `${resource.name} is UP`; const priority = isDown ? 'high' : isSlow ? 'default' : 'low'; const tags = isDown ? 'red_circle,warning' : isSlow ? 'yellow_circle' : 'green_circle,white_check_mark'; - const body = resource.url ? `${resource.url}` : resource.name; + const body = resource.url || resource.name; try { await axios.post(`${ntfyUrl.replace(/\/$/, '')}/${ntfyTopic}`, body, { headers: { - Title: title, + Title: encodeURIComponent(titleText), Priority: priority, Tags: tags, },