Skip to content

Add push notifications for scheduled expenses#675

Open
maraf wants to merge 1 commit into
mainfrom
maraf/scheduled-expense-notifications
Open

Add push notifications for scheduled expenses#675
maraf wants to merge 1 commit into
mainfrom
maraf/scheduled-expense-notifications

Conversation

@maraf

@maraf maraf commented May 20, 2026

Copy link
Copy Markdown
Owner

Summary

Implements Web Push notifications to alert users when scheduled expense templates are due today. Based on the notification pattern from neptuo/Recollections#395.

API Changes

  • NotificationsController — REST endpoints for notification settings and push subscriptions
    • GET /api/notifications — Get current settings
    • PUT /api/notifications — Toggle global notifications
    • PUT /api/notifications/expense-templates — Configure expense template notifications (enable, preferred hour, timezone)
    • POST /api/notifications/subscriptions — Register browser push subscription
    • DELETE /api/notifications/subscriptions — Revoke subscription
  • PushNotificationSender — WebPush/VAPID-based push delivery with auto-revocation of expired endpoints
  • ExpenseTemplateNotificationBackgroundService — Background service that ticks every 15min, checks due templates per user's timezone/preferred hour, deduplicates via dispatch table
  • EF Entities — PushSubscription, UserNotificationSettings, UserNotificationExpenseTemplateSettings, ExpenseTemplateNotificationDispatch (with unique index for dedup)

Blazor Client Changes

  • Service workers — Push event handlers for showing notifications + click-to-navigate
  • JS interopMoney.Notifications module (subscribe, unsubscribe, permission check, timezone detection)
  • PushNotificationInterop — C# wrapper for JS Push API calls
  • Notifications page (/user/notifications) — Settings UI with global toggle, expense template toggle, preferred hour selector, browser subscription management
  • Navigation — Added to user dropdown menu

Architecture

Maintains separation between:

  • Accounts layer — Owns subscriptions, settings, and push delivery
  • Money domain — Owns "due today" logic (recurrence calculation via ReadModelContext)

Setup

To enable push notifications, generate VAPID keys and configure in appsettings.json:

npx web-push generate-vapid-keys

Then set Notifications:PublicKey and Notifications:PrivateKey.

TODO (follow-up)

  • EF migration (needs to be generated in environment with DB access)
  • Badge icon asset for Android

Closes #617
Closes #672
Closes #673

Implement Web Push notification infrastructure to alert users when
scheduled expense templates are due today.

API changes:
- Add NotificationsController with REST endpoints for managing
  notification settings and push subscriptions
- Add PushNotificationSender using WebPush/VAPID for delivery
- Add ExpenseTemplateNotificationBackgroundService that periodically
  checks for due templates based on user timezone and preferred hour
- Add EF entities: PushSubscription, UserNotificationSettings,
  UserNotificationExpenseTemplateSettings, ExpenseTemplateNotificationDispatch
- Add deduplication to prevent re-sending for same template/day

Blazor client changes:
- Add push/notificationclick handlers to service workers
- Add JS Push API interop (subscribe, unsubscribe, permission check)
- Add PushNotificationInterop C# wrapper
- Add /user/notifications settings page with global toggle,
  expense template toggle, preferred hour selector, and
  browser subscription management
- Add navigation entry in user menu

Closes #617
Closes #672
Closes #673

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant