Skip to content

feat(push): fix notification delivery and add detailed messages with auto-subscribe #1

Merged
hechi merged 4 commits intomainfrom
fix/push-notification-delivery
Mar 26, 2026
Merged

feat(push): fix notification delivery and add detailed messages with auto-subscribe #1
hechi merged 4 commits intomainfrom
fix/push-notification-delivery

Conversation

@hechi
Copy link
Copy Markdown
Owner

@hechi hechi commented Mar 26, 2026

Summary

  • Fix push notifications not being delivered due to Base64 encoding mismatch (standard vs URL-safe) and CORS-blocked X-Device-Id header
    (now passed as query param)
    • Replace generic "List updated" notifications with action-specific messages: item added (✚), checked (✓), unchecked (↩), edited (✎),
      deleted (✕), and completed items cleared
    • Auto-subscribe users to push notifications when opening a list, with per-list opt-out toggle persisted in localStorage

Changes

Backend

  • PushNotificationService: Rewrite buildPayload() with typed change actions (ITEM_ADDED, ITEM_CHECKED, ITEM_UNCHECKED, ITEM_UPDATED,
    ITEM_DELETED, ITEMS_CLEARED) and descriptive notification titles/bodies
  • ListRoutes: Distinguish check/uncheck from text edit in update endpoint; fetch item text before deletion for notification context;
    read deviceId from query param instead of header

Frontend

  • PushNotificationContext: Add autoSubscribe(), setOptedOut(), isOptedOut() to context; opt-out state stored per list in localStorage (
    shoppimo_push_optout_{listId})
  • NotificationBell: Auto-subscribe on mount with useRef guard; click toggles opt-out flag before subscribe/unsubscribe; unsubscribed
    state shows gray styling
  • Base64 fix: Convert btoa() output to URL-safe Base64 (+→-, /→_, strip =) to match backend's Base64.getUrlDecoder()

hechi added 4 commits March 26, 2026 20:05
The interaso/webpush library decodes p256dh/auth keys with URL-safe Base64
(Base64.getUrlDecoder) but the frontend encoded them with btoa() which
produces standard Base64. Keys containing + or / caused silent decode
failures, preventing all push notifications from being delivered.

Also pass deviceId as a query parameter on mutation requests instead of
the X-Device-Id header (which was removed earlier due to CORS preflight
failures), so the backend can exclude the originating device from
self-notifications.
…h opt-out

Replace generic 'List updated' notifications with action-specific messages
(added, checked, unchecked, edited, deleted, cleared). Auto-subscribe users
on list open with per-list opt-out stored in localStorage.
@hechi hechi merged commit a339d00 into main Mar 26, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant