Skip to content

feat(notifications): persist in-app notifications in Postgres with dashboard badge | WALLET_TBD - #52

Closed
waterWang wants to merge 1 commit into
mallonepay:mainfrom
waterWang:feat/persist-inapp-notifications
Closed

waterWang wants to merge 1 commit into
mallonepay:mainfrom
waterWang:feat/persist-inapp-notifications

Conversation

@waterWang

Copy link
Copy Markdown
Contributor

Summary

Persist in-app notifications in Postgres so they survive restarts, are visible across gateway instances, and are reachable from the dashboard.

Changes

  • packages/database/prisma/schema.prisma: Added InAppNotification model (providerId, event, data JSON, read, createdAt) with indexes on [providerId] and [providerId, read].
  • packages/notifications/src/index.ts: Rewrote inAppHandler.send() to persist to Postgres when a Prisma client is wired up, with the existing in-memory queue preserved as a fallback for tests/no-DB environments. Added setPrismaClient(), plus DB-backed getInAppNotifications(), markInAppRead(), and getUnreadCount().
  • apps/gateway/src/modules/notifications/: New module with:
    • GET /api/v1/notifications — paginated, wallet-scoped (default limit 50, supports unreadOnly)
    • GET /api/v1/notifications/unread-count — unread badge count
    • POST /api/v1/notifications/:id/read — mark a notification read
  • apps/dashboard/src/components/layout/navbar.tsx: Bell icon now shows a live unread-count badge (polled every 30s) and opens a dropdown listing recent notifications with mark-as-read.
  • apps/gateway/src/app.module.ts: Registered NotificationsModule.
  • apps/gateway/src/main.ts: Added notifications OpenAPI tag.
  • Tests: notifications.service.spec.ts covers service + in-memory fallback paths (100% coverage on the new service).

Acceptance criteria

  • Notifications survive a gateway restart (DB persistence when DATABASE_URL is set)
  • Read/unread state is per-provider and wallet-scoped
  • Pagination works (limit 50 default)
  • In-memory fallback preserved when no DB
  • Migration applies cleanly (model added to schema; prisma migrate dev generates it)
  • Unit tests for the DB handler + endpoints
  • pnpm exec nx test gateway — new notifications suite passes (pre-existing failures in admin/analytics/payments/routes are unrelated: implicit-any TS errors and a DNS resolution test)

How to test

pnpm install
pnpm exec nx lint gateway
pnpm exec nx test gateway

Closes #43

…shboard badge

- Add InAppNotification model to Prisma schema
- Rewrite inAppHandler to persist to Postgres (with in-memory fallback)
- Add gateway notifications module (GET /api/v1/notifications, GET unread-count, POST /:id/read)
- Add dashboard navbar unread badge with notification dropdown
- Add unit tests for the notifications service
- Wire up Prisma client in the gateway bootstrap
- Update Swagger tags

Closes mallonepay#43
@vercel

vercel Bot commented Aug 11, 2026

Copy link
Copy Markdown

@waterWang is attempting to deploy a commit to the scarface-dev1's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown
Contributor

Hi! 👋 main has moved forward significantly today — 19 PRs were merged, and this PR currently has merge conflicts with the new main.

To get this reviewed and merged: please rebase your branch onto main, resolve the conflicts, and force-push. The updated main includes recent work on health checks, dark mode, k8s manifests, the Python SDK, wallet tests, escrow integration, and shared dashboard error components — so there may now be overlap to reconcile with your change.

Happy to take another look once it's rebased. Thanks! 🙏

Copy link
Copy Markdown
Contributor

Thanks for the contribution! This was part of the Stellar Wave 8 / GrantFox issue set. The issue this addresses is now implemented directly in main, which was substantially reworked during a full audit pass, so this PR is superseded and its changes conflict with the current implementation of the same feature.

Closing as superseded. If you believe part of this work is not covered by the current main, please open a fresh PR against the current codebase.

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.

feat: persist in-app notifications in Postgres (durable, cross-instance)

2 participants