Added notifications for actual news
Some checks failed
Code Analysis and Production Deploy / analyze (push) Failing after 5m59s
Code Analysis and Production Deploy / deploy-production (push) Has been skipped
Code Analysis and Production Deploy / deploy-test (push) Has been skipped

This commit is contained in:
Torsten Schulz (local)
2026-06-11 09:02:58 +02:00
parent c7a306e8fa
commit da1efa5a74
7 changed files with 497 additions and 18 deletions

View File

@@ -0,0 +1,38 @@
import { runNotificationSchedulerTick } from '../utils/notification-scheduler.js'
import { info as loggerInfo, error as loggerError } from '../utils/logger.js'
const INTERVAL_MS = 60_000
let timer = null
let running = false
async function tick(reason = 'interval') {
if (running) return
running = true
try {
const result = await runNotificationSchedulerTick()
if (result?.dueUsers) {
loggerInfo('[notification-scheduler] Tick', { reason, ...result })
}
} catch (error) {
loggerError('[notification-scheduler] Tick fehlgeschlagen:', { error })
} finally {
running = false
}
}
export default defineNitroPlugin((nitroApp) => {
if (process.env.NOTIFICATION_SCHEDULER_DISABLED === 'true') {
loggerInfo('[notification-scheduler] Deaktiviert')
return
}
loggerInfo('[notification-scheduler] Gestartet')
timer = setInterval(() => tick(), INTERVAL_MS)
timer.unref?.()
tick('start')
nitroApp.hooks.hookOnce('close', () => {
if (timer) clearInterval(timer)
timer = null
})
})