The bell polls the unread count every 30 s while the tab is visible. Opening it loads the newest 10 and marks the unread ones read; items link only to paths on this site. /notifications lists all with paging and Mark all read. Titles and bodies render from message codes, in English and Chinese. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
2.9 KiB
2.9 KiB
Tasks: add-lead-notifications
Design: design.md and docs/superpowers/specs/2026-12-02-lead-notifications-design.md. Every task is TDD. Work is serial in the main session, with a self-review per task. Porting source: babyboo's add-admin-internal-notifications.
1. Store and API
- 1.1 SQL:
sql/01-notification-columns.sql(columns, index,utf8mb4),sql/99-rollback.sql; mirror 01 intolocal/seed/. - 1.2 services-system: the extended
Notification; create (withcollapse_key), list mine (paged), unread count, mark one read (own rows only), mark all read.- Verify:
mvn -T 1C -B -pl solvway-services-system -am verify
- Verify:
- 1.3 mobile-api:
/api/admin/notifications,/unread-count,/{id}/read,/read-all, user and company from the session.- Verify:
mvn -T 1C -B -pl solvway-mobile-api -am verify
- Verify:
2. Triggers
- 2.1 services-counter
StaffNotifier(after commit, 2 s timeout, never throws, ids-only logs).- Lead assigned at capture and on update, not on self-assignment or clearing.
- Web sign-up to the salesperson, else the event's sales team; one notification when assigned at capture.
- 2.2 services-counter daily follow-up summary job (08:00 Asia/Kuala_Lumpur, cron property), one per salesperson with open leads due today or overdue.
- Verify (2.1, 2.2):
mvn -T 1C -B -pl solvway-services-counter -am verify
- Verify (2.1, 2.2):
- 2.3 services-whatsapp: notify the chat owner after an inbound message is recorded, collapse key
WA:<conversation uuid>; no owner, no notification.- Verify:
mvn -T 1C -B -pl solvway-services-whatsapp -am verify
- Verify:
3. Portal
- 3.1 BFF routes
app/api/notifications/**andapp/lib/services/notifications.ts. - 3.2
NotificationsBellin the header (30 s polling while visible, newest 10, opening marks read, click opens the link) and the/notificationspage with "Mark all read". - 3.3 Labels in
defaultMessages.tswith Chinese inzh_CN.seed.json, thennpm run i18n:sql.sql/02-notification-labels.sqlholds only the new labels.- Verify (3.1 to 3.3):
cd solvway-admin-portal && npx vitest run; echo VITEST=$? && npx tsc --noEmit && npm run lint
- Verify (3.1 to 3.3):
4. Release
- 4.1
docs/deployment.md: the SQL rows and the follow-up job's cron property. - 4.2 Live Playwright check on the local stack, signed in as two users of different companies:
- assigning a lead notifies the salesperson and not the other company;
- a landing-page sign-up notifies the event's sales team;
- a WhatsApp message (mock) on an owned chat shows one notification per chat;
- the follow-up job (run by setting its cron for the test) gives the summary;
- the bell, the page and "Mark all read" work in English and Chinese, at 1280 and 360 px.
- 4.3 Whole-branch self-review (security: recipient scoping, own-rows-only read endpoints, no personal data in logs or parameters), then the PR to main and the merge.