Skip to content

Communication center, chat, interactive map, distance pricing & demo trips - #8

Merged
llfzzz merged 1 commit into
mainfrom
claude/message-center-login-codes-a0ffd5
Jul 21, 2026
Merged

Communication center, chat, interactive map, distance pricing & demo trips#8
llfzzz merged 1 commit into
mainfrom
claude/message-center-login-codes-a0ffd5

Conversation

@llfzzz

@llfzzz llfzzz commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Summary

Removes login verification codes from the Message Center and turns it into a real user communication center, adds passenger–driver chat, an interactive map with a working geolocation flow, distance-based pricing, and demo virtual-trip generation — while preserving every existing security/architecture invariant (gateway-only access, server-authoritative prices/roles/state, demo isolation, idempotency, replay protection, audit logging).

1. Login codes out of the Message Center

  • Demo login code now lives only on the login page via a challenge-bound DemoLoginCodeStore in auth-service. POST /api/auth/sms-code returns an opaque challengeId; POST /api/auth/sms-code/demo-peek {phone, challengeId} returns the code only on an exact match. Plaintext is deleted on successful login, on lockout, and by TTL; never logged, never an inbox/notification record.
  • Secure code lifecycle kept: hashed single-use storage, TTL, per-phone issue + peek rate limits, verify-attempt lockout, replay rejection.
  • notification-service V2 purges historical AUTH_SMS_CODE deliveries; notify rejects the category (CATEGORY_NOT_INBOXABLE); inbox queries exclude it defensively.

2. Production Message Center (/api/inbox)

  • Pagination (keyset), unread count, mark one / mark all read, category filter, timestamps, empty states, deep links to order/trip/payment/conversation, masked preview + explicit owner/TTL-scoped audited reveal. Mobile + desktop. Demo inbox removed.
  • Fan-out from domain events: transactional notification outbox in order-service (relayed with event_id as the receiver dedupe key) at every state transition; best-effort driver-verification notices; trip-service departure-reminder @Scheduled scan. Shared NotificationCategory enum.

3. Passenger–driver chat

  • Conversation bound to a legitimate order, hosted inside notification-service (no 15th JVM). Participants derived server-side from order + trip records; non-participants get 404 on every endpoint (discovery-proof). Idempotent send via clientMsgId, per-participant read cursors, send/create rate limits, 1–500 char validation, 5s polling. Mobile + desktop chat window and conversation list; "联系司机/乘客" entries on order cards.

4–5. Interactive map + geolocation

  • Shared zustand route-selection state across both shells + thumbnail + expanded map; zoom/pan/touch, locate + accuracy circle, draggable markers, click-to-pick, POI search, swap/clear, route + price confirmation. AMap for tiles/interaction only; all resolution/routing/pricing stays server-side. Geolocation gains secure-context + permission preflight and a poor-accuracy correction flow; no IP fallback.

6. Distance-based pricing

  • fare = max(minFare, baseFare + max(0, distanceKm − includedKm) × extraPerKm), BigDecimal only, documented rounding. Components stored per trip so the displayed breakdown always matches the stored price. New POST /api/trips/route-preview returns {route, PriceBreakdown} (single pricing authority); rendered verbatim in booking UIs.

7. Demo virtual trips

  • Demo-gated (app.demo.virtual-trips-enabled, fenced by DemoModeGuard), deterministic seeded generation, strictly formula-derived prices, synthetic non-authenticatable drivers, source='DEMO' label, delete-then-insert cap + expiry cleanup, random route via an unrouted map-service demo-places endpoint.

Migrations

  • notification: V2 purge, V3 inbox links/dedupe, V4 chat tables
  • order: V5 notification outbox
  • trip: V6 departure reminder, V7 pricing breakdown, V8 source

Verification

  • ./scripts/verify.sh green — backend BUILD SUCCESS (all 15 modules), frontend typecheck + build (user-h5 + admin-console)
  • Playwright 15 passed (13 existing + 2 new expanded-map specs)
  • Not yet run in this environment: full-stack scripts/demo-smoke.sh (needs the local Docker stack) and staging SSE load test.

🤖 Generated with Claude Code

…demo trips

Message Center / login codes (S46):
- Login verification codes no longer become inbox messages. The demo code lives
  only in a challenge-bound, login-page-only DemoLoginCodeStore in auth-service
  (POST /api/auth/sms-code returns an opaque challengeId; POST /sms-code/demo-peek
  requires it). Plaintext is deleted on login/lockout/TTL, never logged, never an
  inbox record. notification V2 purges AUTH_SMS_CODE rows; notify rejects the
  category; inbox queries exclude it defensively.
- Production Message Center at /api/inbox (pagination, unread count, mark one/all
  read, category filter, deep links, masked+explicit reveal). Demo inbox removed.
- Domain-event fan-out via transactional notification outbox in order-service
  (relayed with event_id as dedupe key), best-effort driver verification notices,
  and a trip-service departure-reminder scan. Shared NotificationCategory enum.

Chat (feature 3):
- Passenger-driver conversations bound to a legitimate order, hosted in
  notification-service (no new JVM). Participants derived server-side from order
  + trip records; non-participants get 404 on every endpoint. Idempotent send by
  clientMsgId, per-participant read cursors, rate limits, content validation,
  5s polling. Mobile + desktop chat windows and conversation list.

Pricing (feature 6):
- fare = max(minFare, baseFare + max(0, km - includedKm) x extraPerKm), BigDecimal
  only, documented rounding. Components stored per trip; PriceBreakdown returned by
  POST /api/trips/route-preview and rendered verbatim in booking UIs.

Map + geolocation (features 4-5) and demo virtual trips (feature 7):
- Shared route-selection store, expanded interactive map, geolocation preflight +
  accuracy warning; demo-gated deterministic virtual-trip generation with cleanup.

Preserves gateway-only access, server-authoritative prices/roles/state, demo
isolation, idempotency, replay protection, audit logging. Full verify.sh green:
backend BUILD SUCCESS, frontend typecheck/build, Playwright 15 passed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 21, 2026 12:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@llfzzz
llfzzz merged commit a290e6e into main Jul 21, 2026
1 check passed
@llfzzz
llfzzz deleted the claude/message-center-login-codes-a0ffd5 branch July 21, 2026 12:41
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.

2 participants