Description
The invoice.expiring_soon notification requires a scheduler that checks upcoming due dates periodically and triggers delivery 72 hours and 24 hours before expiry. Without a scheduler, time-based notifications cannot work.
Requirements and context
- Query the indexer API (or directly the database) for invoices with
state = Funded and dueDate within 72h or 24h
- Deliver notifications to all subscribers for the invoice's payer, LP, and submitter
- Track delivered reminders to avoid duplicate sends (idempotency key per invoice + threshold)
- Schedule checks every 30 minutes
- Write unit tests including idempotency behaviour
Suggested execution
git checkout -b feat/notifications-scheduler
- Create
notifications/src/services/schedulerService.ts using node-cron
- Implement idempotency via a
delivered_reminders database table
- Write unit tests
Example commit message
feat(notifications): add scheduler service for time-based due-date alerts
Description
The
invoice.expiring_soonnotification requires a scheduler that checks upcoming due dates periodically and triggers delivery 72 hours and 24 hours before expiry. Without a scheduler, time-based notifications cannot work.Requirements and context
state = FundedanddueDatewithin 72h or 24hSuggested execution
notifications/src/services/schedulerService.tsusingnode-crondelivered_remindersdatabase tableExample commit message
feat(notifications): add scheduler service for time-based due-date alerts