diff --git a/app/server.js b/app/server.js index 303ce09..3789e56 100644 --- a/app/server.js +++ b/app/server.js @@ -734,6 +734,22 @@ async function alertWatcherCron() { } catch {} } + // ── Log NWS alerts for the dashboard location regardless of subscribers ─────── + const dashLat = dashAuth?.stationLat; + const dashLon = dashAuth?.stationLon; + if (dashLat != null) { + const dashAlertData = await fetch(`${base}/api/alerts?lat=${dashLat}&lon=${dashLon}`) + .then(r => r.json()).catch(() => ({ features: [] })); + for (const a of dashAlertData.features || []) { + const alertId = a.id || a.properties?.id; + if (alertId && !loggedAlertIds.has(alertId)) { + loggedAlertIds.add(alertId); + const p = a.properties || {}; + recordAlertLog({ type: 'nws', alertId, event: p.event, headline: p.headline, effective: p.effective, expires: p.expires, lat: dashLat, lon: dashLon }); + } + } + } + if (!pushSubscriptions.length) return; for (const sub of [...pushSubscriptions]) {