Skip to content

feat(campaigns): moderated donor wishes wall, heart reactions & staff wish-report queue (#320) - #328

Merged
JOY (JOY) merged 1 commit into
devfrom
antigravity/give-320-donor-wishes
Nov 22, 2026
Merged

JOY (JOY) merged 1 commit into
devfrom
antigravity/give-320-donor-wishes

Conversation

@JOY

@JOY JOY (JOY) commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Refs #320

Summary

Phase 2 (App) for Give v2 Sprint 5 Wave C (Gói 5b) — Moderated Donor Wishes Wall ("Tường lời chúc") and heart reactions, built on Phase 1 DB migration DOS/DOS.Me#1888 (20261202140000_give_donor_wishes_and_hearts.sql, live on Supabase Beta oyajkbadsykigtfrpdpg at 161495457b430a9a497ba4d7e36d8cf76394c66b).

Key Changes

  1. Domain & Error Handling (apps/web/src/lib/donor-wishes.ts, apps/web/src/lib/errors.ts):
    • Typed RPC readers (listCampaignWishes, listHiddenCampaignWishes, listReportedContributionMessages), Zod validation schemas (reportWishSchema, moderateWishSchema), anonymous donor masking ("Người ủng hộ ẩn danh"), pagination & filter parsers.
    • Mapped all new GIVE_* error codes (GIVE_WISH_NOT_FOUND, GIVE_STAFF_HIDE_LOCKED, WISH_HEART_MESSAGES, WISH_REPORT_MESSAGES, WISH_MODERATION_MESSAGES, wishDbErrorMessage) with zero raw Postgres error leaks.
  2. "Tường lời chúc" on /campaigns/[slug] (DonorWishesWall.tsx, WishHeartButton.tsx, wish-actions.ts, page.tsx):
    • Strictly gated on isPublicLiveOrEnded (never queried or rendered on publicPrelaunch or preview).
    • Uses dbAs(session.accessToken) for signed-in callers (with PGRST30* fallback to dbAs()) and dbAs() for guests — zero dbService() usage.
    • Renders wish text strictly as plain-text React children (zero HTML/XSS), masks anonymous donors, shows verified amount (tabular-nums), timestamp, heart count, and interactive heart toggle (toggle_contribution_heart; plain <a> login link for guests).
    • Signed-in visitors can report wishes (report_contribution_message); campaign owners, accepted co-organizer editors (#264), and non-self moderators can hide wishes and view/restore hidden wishes via list_hidden_campaign_wishes respecting can_restore (staff hides cannot be overridden by owner/editor).
  3. Moderator Reported Wishes Queue (/admin/reports/wishes + nav tabs on /admin/reports & /admin/reports/comments):
    • Strictly under dbAs(session.accessToken) (zero dbService()), supporting open | resolved | dismissed | all filters and hide / restore / dismiss_reports with explicit notice that restoring an open-reported wish keeps open reports open until dismissed.
  4. Donate & Pledge Forms (DonateForm.tsx, pledge/PledgeForm.tsx):
    • Clarified existing optional message textarea label & helper text as a public wish displayed after bank-statement matching (zero money-flow regression).

Verification

  • pnpm format:check: PASS
  • pnpm lint: PASS
  • pnpm typecheck: PASS
  • pnpm test: PASS (211/211 test files, 2,889/2,889 tests including new unit/component/action/page suites)
  • pnpm build: PASS (Next.js production build including /admin/reports/wishes)
  • Fresh-context verification subagent review: CLEAN_PASS

📌 TL;DR

This PR introduces a public "Donor Wishes Wall" on campaign pages and a corresponding admin moderation queue (/admin/reports/wishes) for managing reported wishes. It implements strict security controls, including XSS-safe plain-text rendering, anonymous donor masking, and role-based access for hiding/restoring content.

🎯 Type of Change

  • 🚀 New feature
  • 🐛 Bugfix
  • 🧹 Refactor
  • ⚡ Performance
  • 📚 Documentation
  • ⚙️ CI / Configuration

🔍 Changes Walkthrough

File Summary of Changes
apps/web/src/app/admin/reports/comments/page.tsx Added a navigation tab link to the new "Báo cáo lời chúc" (Wish Reports) page.
apps/web/src/app/admin/reports/page.tsx Added a navigation tab link to the new "Báo cáo lời chúc" (Wish Reports) page.
apps/web/src/app/admin/reports/wishes/actions.ts New. Server action moderateReportedWish that handles hiding, restoring, or dismissing reports on wishes. Validates input, calls the moderate_contribution_message RPC via dbAs, and revalidates relevant paths.
apps/web/src/app/admin/reports/wishes/actions.test.ts New. Unit tests for the moderation server action, covering success states, validation failures, and specific database error mappings.
apps/web/src/app/admin/reports/wishes/page.tsx New. Admin page component for the wish reports queue. Displays reported wishes with status filters, donor info, and moderation controls (hide/restore/dismiss).
apps/web/src/app/admin/reports/wishes/page.test.ts New. Component tests for the admin wish reports page, verifying metadata, access control, XSS safety, and UI rendering.
apps/web/src/app/campaigns/[slug]/DonateForm.tsx Updated the donation message field label and hint to clarify that messages appear on the public "Wishes Wall" after reconciliation.
apps/web/src/app/campaigns/[slug]/DonorWishesWall.tsx New. Public component rendering the "Tường lời chúc" (Wishes Wall). Includes pagination, heart buttons, report forms, and a hidden-wishes drawer for authorized users.
apps/web/src/app/campaigns/[slug]/DonorWishesWall.test.ts New. Component tests for the public wishes wall, verifying XSS safety, anonymous masking, guest vs. signed-in states, and hidden-wish restore gating.
apps/web/src/app/campaigns/[slug]/page.tsx Integrated the DonorWishesWall into the campaign page. Added logic to fetch public wishes and hidden wishes (for authorized users) only when the campaign is live/ended.
apps/web/src/app/campaigns/[slug]/page.test.ts Added tests to ensure the Wishes Wall renders on live campaigns and is strictly excluded from pre-launch or draft previews.

📊 Architectural Flow

sequenceDiagram
    participant User as User (Browser)
    participant CampaignPage as Campaign Page (Server)
    participant AdminPage as Admin Reports Page (Server)
    participant DB as Database (Supabase)

    Note over User, CampaignPage: Public View (Live Campaign)
    User->>CampaignPage: Request /campaigns/[slug]
    CampaignPage->>DB: Fetch public wishes (dbAs)
    DB-->>CampaignPage: Wish data
    CampaignPage-->>User: Render DonorWishesWall (XSS-safe)

    opt Signed-in User with Role
        User->>CampaignPage: Request with show_hidden_wishes=1
        CampaignPage->>DB: Check role & fetch hidden wishes
        DB-->>CampaignPage: Hidden wish data
        CampaignPage-->>User: Render Hidden Wishes Drawer
    end

    Note over User, AdminPage: Moderation Flow
    User->>AdminPage: Request /admin/reports/wishes
    AdminPage->>DB: Verify staff role (dbAs)
    DB-->>AdminPage: Access granted
    AdminPage->>DB: Fetch reported wishes
    DB-->>AdminPage: Report data
    AdminPage-->>User: Render Moderation Queue

    User->>AdminPage: Submit Moderation Action (Hide/Restore)
    AdminPage->>DB: Call moderate_contribution_message RPC
    DB-->>AdminPage: Success & resolved count
    AdminPage->>AdminPage: Revalidate paths
    AdminPage-->>User: Success message
Loading

@JOY JOY (JOY) added line:campaigns Product line: campaigns po:agy Owned by Antigravity PO (mutual-exclusion parallel PO label) labels Nov 22, 2026

@claude claude Bot 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.

⚠️ Code review skipped — your organization has no extra usage available to pay for this review.

If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.

Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.

@vercel

vercel Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
give Ready Ready Preview Nov 22, 2026 5:01pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 22, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 474b807d-4335-4c41-8944-c02bcbf8e2c2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@JOY

Copy link
Copy Markdown
Contributor Author

PO acceptance: merge at 7ac2a1d

Independent PO flagship review (794384e5-b927-49e9-81d7-4bc68e641ecf): APPROVE (0 P0/P1/P2 findings).

  • Verified zero dbService() usage, strict isPublicLiveOrEnded gating (no prelaunch/preview leak), exact 6-RPC parity with 20261202140000_give_donor_wishes_and_hearts.sql, /admin/reports/wishes moderation boundary & can_restore enforcement, plain-text XSS safety, zero money-flow regression, and 2,889 passing tests + green CI.
  • 3 minor P3 polish nits logged (non-blocking).

@JOY
JOY (JOY) merged commit 9995e7e into dev Nov 22, 2026
6 checks passed
@JOY
JOY (JOY) deleted the antigravity/give-320-donor-wishes branch November 22, 2026 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

line:campaigns Product line: campaigns po:agy Owned by Antigravity PO (mutual-exclusion parallel PO label)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant